aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
AgeCommit message (Collapse)Author
2024-11-01main: parse extldflags early so we can report the error messageAyke van Laethem
This avoids some weird behavior when the -extldflags flag cannot be parsed by TinyGo.
2024-10-28tinygo: revise and simplify wasmtime argument handling (#4555)Randy Reddig
2024-10-04wasm: add `//go:wasmexport` support (#4451)Ayke
This adds support for the `//go:wasmexport` pragma as proposed here: https://github.com/golang/go/issues/65199 It is currently implemented only for wasip1 and wasm-unknown, but it is certainly possible to extend it to other targets like GOOS=js and wasip2.
2024-09-28main: rework usage (#4467)leongross
main: rework usage * remove unused switch case statement and improve/add command specific usage. * limit help to 80 col width * remove inconsistent ':' * remove trailing spaces * rmove spaces woth tabs * reworkd build command Signed-off-by: leongross <[email protected]>
2024-09-18main: add -ldflags='-extldflags=...' supportAyke van Laethem
This matches upstream Go. Example: $ go test -ldflags='-extldflags=-foobar' os # os.test /usr/local/go1.23.1/pkg/tool/linux_arm64/link: running gcc failed: exit status 1 /usr/bin/gcc -s -o $WORK/b001/os.test -rdynamic /tmp/go-link-914594215/go.o /tmp/go-link-914594215/000000.o /tmp/go-link-914594215/000001.o /tmp/go-link-914594215/000002.o /tmp/go-link-914594215/000003.o /tmp/go-link-914594215/000004.o /tmp/go-link-914594215/000005.o /tmp/go-link-914594215/000006.o /tmp/go-link-914594215/000007.o /tmp/go-link-914594215/000008.o /tmp/go-link-914594215/000009.o /tmp/go-link-914594215/000010.o /tmp/go-link-914594215/000011.o /tmp/go-link-914594215/000012.o /tmp/go-link-914594215/000013.o /tmp/go-link-914594215/000014.o /tmp/go-link-914594215/000015.o /tmp/go-link-914594215/000016.o /tmp/go-link-914594215/000017.o /tmp/go-link-914594215/000018.o /tmp/go-link-914594215/000019.o /tmp/go-link-914594215/000020.o /tmp/go-link-914594215/000021.o -O2 -g -O2 -g -lresolv -O2 -g -lpthread -foobar gcc: error: unrecognized command-line option ‘-foobar’ FAIL os [build failed] FAIL And TinyGo, with this patch: $ tinygo test -ldflags='-extldflags=-foobar' os FAIL os 0.000s ld.lld: error: unknown argument '-foobar' Also note that Go doesn't support the `-extldflags` directly (which was previously the case with TinyGo): $ go test -extldflags='-foobar' os flag provided but not defined: -extldflags [...]
2024-09-18support -extldflagsDamian Gryski
Fixes #4320
2024-09-17tinygo: add relative and absolute --dir options to wasmtime args (#4431)Randy Reddig
main: add relative and absolute --dir options to wasmtime args
2024-09-13Fix #4421: Add `-C DIR` flag (#4422)archie2x
feature: Fix #4421: Add `-C DIR` flag Signed-off-by: Roger Standridge <[email protected]>
2024-08-20tinygo: detect GOOS=wasip1 for relative WASI paths via config instead of ↵Randy Reddig
target name (#4423)
2024-08-15compiler: fixup Sprintf usesDamian Gryski
2024-08-15make spellfix: fix top level files, too.Dan Kegel
Do manual fix in GNUmakefile, since spellchecking that is just too meta.
2024-08-12mips: add GOMIPS=softfloat supportAyke van Laethem
Previously, the compiler would default to hardfloat. This is not supported by some MIPS CPUs. This took me much longer than it should have because of a quirk in the LLVM Mips backend: if the target-features string is not set (like during LTO), the Mips backend picks the first function in the module and uses that. Unfortunately, in the case of TinyGo this first function is `llvm.dbg.value`, which is an LLVM intrinsic and doesn't have the target-features string. I fixed it by adding a `-mllvm -mattr=` flag to the linker.
2024-08-11builder: interpret linker error messagesAyke van Laethem
This shows nicely formatted error messages for missing symbol names and for out-of-flash, out-of-RAM conditions (on microcontrollers with limited flash/RAM). Unfortunately the missing symbol name errors aren't available on Windows and WebAssembly because the linker doesn't report source locations yet. This is something that I could perhaps improve in LLD.
2024-08-06main: show runtime panic addresses for `tinygo run`Ayke van Laethem
This adds the same panic locations that are already present for `tinygo flash -monitor`, but for `tinygo run` and `tinygo test`. For example, this is the output that I get while working on some GC code. It now shows the source location instead of just an address: $ tinygo test -v archive/zip === RUN TestReader === RUN TestReader/test.zip panic: runtime error at 0x000000000024d9b4: goroutine stack overflow [tinygo: panic at /home/ayke/src/tinygo/tinygo/src/internal/task/task_stack.go:58:15] FAIL archive/zip 0.139s (This particular location isn't all that useful, but it shows that the feature works).
2024-08-06ci: don't include prebuilt libraries in the releaseAyke van Laethem
These libraries will be automatically built when needed and cached. The main reason these were needed is for play.tinygo.org, but I've now prebuilt them there directly (so they don't need to be built for every tarball).
2024-07-20diagnostics: move diagnostic printing to a new packageAyke van Laethem
This is a refactor, which should (in theory) not change the behavior of the compiler. But since this is a pretty large change, there is a chance there will be some regressions. For that reason, the previous commits added a bunch of tests to make sure most error messages will not be changed due to this refactor.
2024-07-15add chromeos 9p supportTai Groot
2024-07-13loader: handle `go list` errors inside TinyGoAyke van Laethem
Instead of exiting with an error, handle these errors internally. This will enable a few improvements in the future.
2024-07-13all: add testing for compiler error messagesAyke van Laethem
This is needed for some improvements I'm going to make next. This commit also refactors error handling slightly to make it more easily testable, this should hopefully not result in any actual changes in behavior.
2024-07-09fix: remove message after test binary builtDmitry Shemin
2024-07-02wasi preview 2 support (#4027)Damian Gryski
* all: wasip2 support Co-authored-by: Randy Reddig <[email protected]>
2024-05-24main: add -serial=rtt flag as possible optionAyke van Laethem
I added this a while ago but forgot to change the help documentation.
2024-05-14Support UF2 drives with space in their name on LinuxMateusz Nowak
Some devices, such as Seeed Studio XIAO with Adafruit bootloader, use complex names for UF2 device. With this fix applied, /proc/mounts should be parsed correctly
2024-03-27targets: add wasi.json that inherits wasip1.jsonRandy Reddig
PR feedback
2024-03-27all: replace target=wasi with target=wasip1Randy Reddig
This eliminates the 'wasi' build tag in favor of 'GOOS=wasip1', introduced in Go 1.21. For backwards compatablity, -target=wasi is a synonym for -target=wasip1.
2024-02-23main: make `ports` subcommand more verboseAyke van Laethem
By listing column headers and printing a message when no ports are found, it should be a bit easier to use.
2024-02-23main: change `monitor -info` to `ports`Ayke van Laethem
I believe this provides a better UX.
2023-12-23main: add -serial=rtt supportAyke van Laethem
2023-11-02compileopts, targets, main: support Wasmtime v14 (#3972)Randy Reddig
compileopts, targets, main: support Wasmtime v14
2023-11-02main, compileopts: move GetTargetSpecs() to compileopts packagesago35
2023-11-02main: add -info option to tinygo monitorsago35
2023-10-15refactor: rm io/ioutil funcsginglis13
io/ioutil has been deprecated since Go 1.16 https://pkg.go.dev/io/ioutil Signed-off-by: ginglis13 <[email protected]>
2023-10-04all: refactor goenv.Version to add the git sha1 if neededAyke van Laethem
Previously all (except one!) usage of goenv.Version manually added the git sha1 hash, leading to duplicate code. I've moved this to do it all in one place, to avoid this duplication.
2023-09-21build: #3893 do not return LLVM structs from BuildKenneth Bell
2023-08-13main: add target JSON file in `tinygo info` outputAyke van Laethem
It looks like this on my system, for example: { "target": { "llvm-target": "aarch64-unknown-linux", "cpu": "generic", "features": "+neon", "goos": "linux", "goarch": "arm64", "build-tags": [ "linux", "arm64" ], "gc": "precise", "scheduler": "tasks", "linker": "ld.lld", "rtlib": "compiler-rt", "libc": "musl", "default-stack-size": 65536, "ldflags": [ "--gc-sections" ], "extra-files": [ "src/runtime/asm_arm64.S", "src/internal/task/task_stack_arm64.S" ], "gdb": [ "gdb" ], "flash-1200-bps-reset": "false" }, "goroot": "/home/ayke/.cache/tinygo/goroot-23c311bcaa05f188affa3c42310aba343acc82562d5e5f04dea9d5b79ac35f7e", "goos": "linux", "goarch": "arm64", "goarm": "6", ... } This can be very useful while working on the automatically generated target object for example (in my case, GOOS=wasip1).
2023-07-07main: use `go env` instead of doing all detection manuallyAyke van Laethem
This replaces our own manual detection of various variables (GOROOT, GOPATH, Go version) with a simple call to `go env`. If the `go` command is not found: error: could not find 'go' command: executable file not found in $PATH If the Go version is too old: error: requires go version 1.18 through 1.20, got go1.17 If the Go tool itself outputs an error (using GOROOT=foobar here): go: cannot find GOROOT directory: foobar This does break the case where `go` wasn't available in $PATH but we would detect it anyway (via some hardcoded OS-dependent paths). I'm not sure we want to fix that: I think it's better to tell users "make sure `go version` prints the right value" than to do some automagic detection of Go binary locations.
2023-07-03main: improve detection of filesystemsAyke van Laethem
This is a rewrite of how filesystems are detected. Specifically, it fixes an issue on Linux where the location of the FAT filesystem can vary between distributions (for example, we supported most distros by checking two different paths, but NixOS uses a different path): it now uses the data in /proc/mounts instead which should be universal.
2023-06-06main: add -internal-nodwarf flagAyke van Laethem
This can be useful during development to avoid generating debug information in IR.
2023-06-06main: rename some flags to make them explicitly internalAyke van Laethem
These flags shouldn't be used by users, but they are occasionally helpful for developers.
2023-05-16windows: re-enable parallelismAyke van Laethem
This reverts https://github.com/tinygo-org/tinygo/pull/3525, because that change didn't seem to stop the CI failures we have been seeing. Instead, I've added thread support in https://github.com/tinygo-org/tinygo/pull/3130 which IIRC fixed most of the CI crashes. Re-enabling parallelism should improve the performance of TinyGo a bit on Windows.
2023-04-26main: print source location when a panic happens in -monitorAyke van Laethem
The previous commit started printing the instruction address for runtime panics. This commit starts using this address to print the source location. Here is an example where this feature is very useful. There is a heap allocation in the Bluetooth package, but we don't know where exactly. Printing the instruction address of the panic is already useful, but what is even more useful is looking up this address in the DWARF debug information that's part of the binary: $ tinygo flash -target=circuitplay-bluefruit -monitor ./examples/heartrate Connected to /dev/ttyACM0. Press Ctrl-C to exit. tick 00:00.810 tick 00:01.587 tick 00:02.387 tick 00:03.244 panic: runtime error at 0x00027c4d: alloc in interrupt [tinygo: panic at /home/ayke/src/tinygo/bluetooth/adapter_sd.go:74:4] To be clear, this path isn't stored on the microcontroller. It's stored as part of the build, and `-monitor` just looks up the path from the panic message. Possible enhancements: - Print such an address for regular panics as well. I'm not sure that's so useful, as it's usually a lot easier to look up panics just by their message. - Use runtimePanicAt (instead of runtimePanic) in other locations, if that proves to be beneficial. - Print the TinyGo-generated output in some other color, to distinguish it from the regular console output. - Print more details when panicking (registers, stack values), and print an actual backtrace.
2023-04-25Revert "all: better errors when multiple mcus share VID/PID"Ron Evans
This reverts commit af9f19615bb2f79d29a9cfaa1088890fbc154aad.
2023-04-25Revert "all: honour port for `-monitor` flash flag"Ron Evans
This reverts commit 7aac1a1391f7420fc3ebc7afe996c98e3c09c687.
2023-04-25all: honour port for `-monitor` flash flagKenneth Bell
2023-04-25all: better errors when multiple mcus share VID/PIDKenneth Bell
2023-04-17targets: make msd-volume-name an arrayKenneth Bell
2023-04-16main: don't print `ok` for a successful compile-onlyDamian Gryski
2023-04-12testing: add -test.shuffle to order randomize test and benchmark orderDamian Gryski
2023-03-31main: fix typos in flag usage messagesDamian Gryski
2023-03-31testing: add test.skipDamian Gryski
Fixes #3056