aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
AgeCommit message (Collapse)Author
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
2023-03-31main: set WASMTIME_BACKTRACE_DETAILS when running in wasmtime.Damian Gryski
I find myself consistently running tests, seeing them panic, and then immediately running them again with this environment variable set. It's easier to just have tinygo do this for me.
2023-03-31main: make sure all testing output goes to the same placeDamian Gryski
2023-03-31main: fix tests with default TestConfig.Count=0 doesn't skip all testsDamian Gryski
2023-03-31testing: make test output unbuffered when verboseDamian Gryski
Fixes #3579
2023-03-31main: stuff test runner options into their own structDamian Gryski
Fixes #2406
2023-03-31testing: support -test.countDamian Gryski
This makes running benchmarks repeatedly easier.
2023-03-06windows: disable parallelism on WindowsAyke van Laethem
This is an attempt to figure out why the Windows CI keeps crashing. It should be removed before the next release, by which point we should know whether this has helped or not.
2023-02-19main: support qemu-user debuggingAyke van Laethem
Running binaries in QEMU (when debugging on Linux for example) did not work correctly as qemu-user expects the `-g` flag to be first on the command line before the program name. Putting it after will make it a command line parameter for the emulated program, which is not what we want. I don't think this ever worked correctly.
2023-01-19Allows the emulator to expand {tmpDir}Adrian Cole
This allows you to expand {tmpDir} in the json "emulator" field, and uses it in wasmtime instead of custom TMPDIR mapping logic. Before, we had custom logic for wasmtime to create a separate tmpDir when running go tests. This overwrite the TMPDIR variable when running, after making a mount point. A simpler way to accomplish the end goal of writing temp files is to use wasmtime's map-dir instead. When code is compiled to wasm with the wasi target, tempDir is always /tmp, so we don't need to add variables (since we know what it is). Further, the test code is the same between normal go and run through wasmtime. So, we don't need to make a separate temp dir first, and avoiding that reduces logic, as well makes it easier to swap out the emulator (for wazero which has no depedencies). To map the correct directory, this introduces a {tmpDir} token whose value is the host-specific value taken from `os.TempDir()`. The motivation I have for this isn't so much to clean up the wasmtime code, but allow wazero to execute the same tests. After this change, the only thing needed to pass tests is to change the emulator, due to differences in how wazero deals with relative lookups (they aren't restricted by default, so there's not a huge amount of custom logic needed). In other words, installing wazero from main, `make tinygo-test-wasi` works with no other changes except this PR and patching `targets/wasi.json`. ```json "emulator": "wazero run -mount=.:/ -mount={tmpDir}:/tmp {}", ``` On that note, if there's a way to override the emulator via arg or env, this would be even better, but in any case patching json is fine. Signed-off-by: Adrian Cole <[email protected]>
2023-01-15test: print package name when compilation failedAyke van Laethem
Before this patch, a compile error would prevent the 'ok' or 'FAIL' line to be printed. That's unexpected. This patch changes the code in such a way that it's obvious a test result line is printed in all cases. To be able to also print the package name, I had to make sure the build result is passed through everywhere even on all the failure paths. This results in a bit of churn, but it's all relatively straightforward. Found while working on Go 1.20.
2022-12-22wasi: makes wasmtime "run" explicitAdrian Cole
wasmtime by default will assume the subcommand is "run" vs one of its others, but being explicit helps clarify the actual command invoked. For example, we pass similar looking args to wasmtime and also wasi. Signed-off-by: Adrian Cole <[email protected]>
2022-12-19compileopts: replace 'retries' with more correct 'timeout' paramdeadprogram
Signed-off-by: deadprogram <[email protected]>
2022-11-13compileopts: add 'retries' flag to allow setting the number of times to ↵deadprogram
retry locating the MSD volume when flashing Signed-off-by: deadprogram <[email protected]>
2022-11-06main: fix -work flagAyke van Laethem
I broke this flag in f866d5cc38319b1abcfd2e7302b2b8ed7d89cdad. This commit fixes it.
2022-11-04wasm: remove -wasm-abi= flagAyke van Laethem
This flag controls whether to convert external i64 parameters for use in a browser-like environment. This flag was needed in the past because back then we only supported wasm on browsers but no WASI. Now, I can't think of a reason why anybody would want to change the default. For `-target=wasm` (used for browser-like environments), the wasm_exec.js file expects this i64-via-stack ABI. For WASI, there is no limitation on i64 values and `-wasm-abi=generic` is the default.
2022-10-26fix printing of benchmark outputDamian Gryski
2022-10-22main: fix outputting .ll filesAyke van Laethem
This command didn't work anymore since the refactor in #3211. The reason it doesn't work anymore is that before the refactor, the code in the callback wasn't executed for .ll, .bc and .o files but after the refactor it is, which causes a spurious error. This commit fixes this oversight. Example that didn't work anymore and is fixed with this change: tinygo build -o test.ll examples/serial
2022-10-19Print PASS on pass when running standalone test binaries (#3229)Fred Goya
* Add test.batch flag so standalone tests print PASS on pass * Add comment; use single-dash flag style to match usage elsewhere * Don't add test.batch for wasmtime * Skip test.batch unless emulator name is blank * Remove test.batch flag; buffer test output and show only on verbose or failure * Remove FAIL when all tests fail to match go test output
2022-10-16main: fix error message when a serial port can't be accessedAyke van Laethem
Old message: error: failed to reset port /tmp/tinygo1441085170/main.uf2: opening port: Permission denied new message: error: failed to reset port /dev/ttyACM0: opening port: Permission denied
2022-10-16main: fix USB vid/pid lookupAyke van Laethem
I introduced a bug in #3207: looking up a VID/PID pair would result in a slice out of bounds panic. This is a trivial fix for that bug.
2022-10-16builder: refactor Build function to not use a callbackAyke van Laethem
The only reason a callback was used, was so that the temporary directory gets removed once `Build` returns. But that is honestly a really bad reason: the parent function can simply create a temporary function and remove it when it returns. It wasn't worth the code complexity that this callback created. This change should not cause any observable differences in behavior (it should be a non-functional change). I have no reason to do this now, but this unclean code has been bugging me and I just wanted to get it fixed.
2022-10-16targets: remove "acm:"` prefix for USB vid/pid pairAyke van Laethem
This prefix isn't actually used and only adds noise, so remove it. It may have been useful on Linux that makes a distinction between /dev/ttyACM* and /dev/ttyUSB* but it isn't now. Also, it's unlikely that the same vid/pid pair will be shared between an acm and usb driver anyway.
2022-09-24main: allow setting the baud rate for serial monitors (#3190)sago35
* main: allow setting the baud rate for serial monitors with default baudrate of 115200 bps
2022-09-20main: restore support for flashing Espressif chipsAyke van Laethem
This reverts commit 303410d3fcfcf3df45bfe6c927a5b963caf3a394 and also removes the unnecessary fallback.
2022-09-16main: add serial port monitoring functionalitysago35
Co-authored-by: Ayke <[email protected]>