aboutsummaryrefslogtreecommitdiffhomepage
path: root/compileopts
AgeCommit message (Collapse)Author
2024-11-20runtime: implement race-free signals using futexesAyke van Laethem
This requires an API introduced in MacOS 11. I think that's fine, since the version before that (MacOS 10.15) is EOL since 2022. Though if needed, we could certainly work around it by using an older and slightly less nice API.
2024-11-20cgo: support errno value as second return parameterAyke van Laethem
Making this work on all targets was interesting but there's now a test in place to make sure this works on all targets that have the CGo test enabled (which is almost all targets).
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-23runtime: add support for os/signalAyke van Laethem
This adds support for enabling and listening to signals on Linux and MacOS.
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-18support -extldflagsDamian Gryski
Fixes #4320
2024-09-05mips: use MIPS32 (instead of MIPS32R2) as the instruction setAyke van Laethem
This should widen compatibility a bit, so that older CPUs can also execute programs built by TinyGo. The performance may be lower, if that's an issue we can look into implementing the proposal here: https://github.com/golang/go/issues/60072 This still wouldn't make programs usable on MIPS II CPUs, I suppose we can lower compatiblity down to that CPU if needed. I tried setting the -cpu flag in the QEMU command line to be able to test this, but it looks like there are no QEMU CPU models that are mips32r1 and have a FPU. So it's difficult to test this.
2024-09-04darwin: replace custom syscall package with Go native syscall packageAyke van Laethem
This required a few compiler and runtime tricks to work, but I ran a bunch of tests and it seems fine. (CI will of course do more exhaustive testing). The main benefit here is that we don't need to maintain the darwin version of the syscall package, and reduce extra risks for bugs (because we reuse the well-tested syscall package). For example, Go 1.23 needed a bunch of new constants in the syscall package. That would have been avoided if we had used the native syscall package on MacOS.
2024-08-22mips: fix big-endian (GOARCH=mips) supportAyke van Laethem
I made an awkward mistake, mixing up GOOS and GOARCH. So here is a fix, with an associated test.
2024-08-15os/user: use stdlib version of this packageAyke van Laethem
I tried implementing enough CGo support to get the native os/user package to work. But I hit a few bugs, probably in CGo itself. Then I realized I could just as well set the osusergo build tag to disable CGo for this specific case. This actually gets the os/user package to work correctly on Linux (I confirmed it returns my name/uid/homedir etc). On other systems, it probably just returns an error if it can't determine these kinds of things. But that's no worse than the current behavior which just doesn't do anything at all.
2024-08-15unix: print a message when a fatal signal happensAyke van Laethem
Print a message for SIGBUS, SIGSEGV, and SIGILL when they happen. These signals are always fatal, but it's very useful to know which of them happened. Also, it prints the location in the binary which can then be parsed by `tinygo run` (see https://github.com/tinygo-org/tinygo/pull/4383). While this does add some extra binary size, it's for Linux and MacOS (systems that typically have plenty of RAM/storage) and could be very useful when debugging some low-level crash such as a runtime bug.
2024-08-14arm: support softfloat in GOARM environment variableAyke van Laethem
This adds softfloat support to GOARM, as proposed here: https://github.com/golang/go/issues/61588 This is similar to https://github.com/tinygo-org/tinygo/pull/4189 but with a few differences: * It is based on the work to support MIPS softfloat. * It fixes the issue that the default changed to softfloat everywhere. This PR defaults to softfloat on ARMv5 and hardfloat on ARMv6 and ARMv7. * It also compiles the C libraries (compiler-rt, musl) using the same soft/hard floating point support. This is important because otherwise a GOARM=7,softfloat binary could still contain hardware floating point instructions.
2024-08-14linux: use -musleabi* instead of -gnueabi* (or nothing)Ayke van Laethem
This more accurately describes the libc we are using. This also adds the environment to _all_ Linux systems, not just ARM. And selects the correct ABI (soft/hardfloat) that's in use. I don't know whether it has any practical implications, but LLVM appears to be using this information so it seems wise to use the correct values.
2024-08-12GNUmakefile: add spellfix target, use it. (#4387)dkegel-fastly
TODO: Remove the go.mod/go.sum in internal/tools once doing so doesn't break CI (e.g. once we drop support for go 1.19) * builder/cc1as.h: fix typo found by 'make spell' * GNUmakefile: remove exception for inbetween, fix instance now found by 'make spell' * GNUmakefile: remove exception for programmmer, fix instance now found by 'make spell' * go.mod: use updated misspell. GNUmakefile: add spellfix target, use it. * ignore directories properly when invoking spellchecker. * make spell: give internal/tools its own go.mod, as misspell requires newer go * make lint: depend on tools and run the installed revive (which was perhaps implied by the change that added revive to internal/tools, but not required in GNUmakefile until we gave internal/tools its own temporary go.mod) * .github: now that 'make spell' works well, run it from CI * GNUmakefile: make spell now aborts if it finds misspelt words, so what it finds doesn't get lost in CI logs * GNUmakefile: tools: avoid -C option on go generate to make test-llvm15-go119 circleci job happy, see https://cs.opensource.google/go/go/+/2af48cbb7d85e5fdc635e75b99f949010c607786 * internal/tools/go.mod: fix format of go version to leave out patchlevel, else go complains.
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-12compileopts: refactor defaultTarget functionAyke van Laethem
Move triple calculation into defaultTarget. It was separate for historic reasons that no longer apply. Merging the code makes future changes easier (in particular, softfloat support). The new code is actually shorter than the old code even though it has more comments.
2024-08-07compileopts: add CanonicalArchName to centralize arch detectionAyke van Laethem
It's possible to detect the architecture from the target triple, but there are a number of exceptions that make it unpleasant to use for this purpose. There are just too many weird exceptions (like mips vs mipsel, and armv6m vs thumv6m vs arm64 vs aarch64) so it's better to centralize these to canonical architecture names. I picked the architecture names that happen to match the musl architecture names, because those seem the most natural to me.
2024-07-22all: add linux/mipsle supportAyke van Laethem
This adds linux/mipsle (little endian Mips) support to TinyGo. It also adds experimental linux/mips (big-endian) support. It doesn't quite work yet, some parts of the standard library (like the reflect package) currently seem to assume a little-endian system.
2024-07-02wasi preview 2 support (#4027)Damian Gryski
* all: wasip2 support Co-authored-by: Randy Reddig <[email protected]>
2024-05-24LLVM 18 supportAyke van Laethem
2024-04-27compileopts: fix race conditionAyke van Laethem
Appending to a slice can lead to a race condition if the capacity of the slice is larger than the length (and therefore the returned slice will overwrite some fields in the underlying array). This fixes that race condition. I don't know how severe this particular one is. It shouldn't be that severe, but it is a bug and it makes it easier to hunt for possibly more serious race conditions.
2024-04-19Run Nick G's spellchecker github.com/client9/misspell, carefuly fix what it ↵dkegel-fastly
found (#4235)
2024-04-17compileopts: apply OpenOCD commands after target configurationElias Naur
The openocd-commands option cannot refer to commands defined by the target configuration. Lift this restriction by moving the commands to after target loading.
2024-03-28nix: fix wasi-libc include headersAyke van Laethem
Apparently Nix really doesn't like --sysroot, so we have to use `-nostdlibinc` and `-isystem` instead.
2024-03-26wasm-unknown: add math and memory builtins that LLVM needsAyke van Laethem
This new library is needed for wasm targets that aren't WASI and don't need/want a libc, but still need some intrinsics that are generated by LLVM.
2024-02-19compileopts: remove workaround for LLVM 16Ayke van Laethem
This workaround is no longer needed now that we've switched to LLVM 17 where this bug has been fixed upstream: https://github.com/espressif/llvm-project/pull/84
2024-02-19compileopts: always enable CGoAyke van Laethem
CGo is needed for the rp2040 and for macOS (GOOS=darwin), without it these targets just won't work. And there really isn't a benefit from disabling CGo: we don't need any external linkers for example. This avoids a somewhat common issue of people having CGO_ENABLED=0 somewhere in their environment and not understanding why things don't work. See for example: https://github.com/tinygo-org/tinygo/issues/3450
2024-02-11compileopts: set 'purego' build tag by defaultAyke van Laethem
This is needed for various crypto libraries.
2024-01-31Allow larger systems to have a larger max stack allocDamian Gryski
Fixes #3331
2024-01-19loader: make sure Go version is plumbed throughAyke van Laethem
This fixes the new loop variable behavior in Go 1.22. Specifically: * The compiler (actually, the x/tools/go/ssa package) now correctly picks up the Go version. * If a module doesn't specify the Go version, the current Go version (from the `go` tool and standard library) is used. This fixes `go run`. * The tests in testdata/ that use a separate directory are now actually run in that directory. This makes it possible to use a go.mod file there. * There is a test to make sure old Go modules still work with the old Go behavior, even on a newer Go version.
2024-01-05all: statically link to LLVM 17 instead of LLVM 16Ayke van Laethem
We can now finally do it, now that Espressif has updated their fork.
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-10-25compileopts: add cflag '-isystem' for resource directory search since needed ↵deadprogram
for Xtensa Signed-off-by: deadprogram <[email protected]>
2023-10-14all: add Nix flake fileAyke van Laethem
This adds a flake.nix file that makes it possible to quickly create a development environment. You can download Nix here, for use on your Linux or macOS system: https://nixos.org/download.html After you have installed Nix, you can enter the development environment as follows: nix develop This drops you into a bash shell, where you can install TinyGo simply using the following command: go install That's all! Assuming you've set up your $PATH correctly, you can now use the tinygo command as usual: tinygo version You can also do many other things from this environment. Building and flashing should work as you're used to: it's not a VM or container so there are no access restrictions.
2023-10-14builder: refactor clang include headersAyke van Laethem
Set -resource-dir in a central place instead of passing the header path around everywhere and adding it using the `-I` flag. I believe this is closer to how Clang is intended to be used. This change was inspired by my attempt to add a Nix flake file to TinyGo.
2023-10-04targets: increase default stack size to 64k for wasi/wasm targetsdeadprogram
Signed-off-by: deadprogram <[email protected]>
2023-10-04all: use the new LLVM pass managerAyke van Laethem
The old LLVM pass manager is deprecated and should not be used anymore. Moreover, the pass manager builder (which we used to set up a pass pipeline) is actually removed from LLVM entirely in LLVM 17: https://reviews.llvm.org/D145387 https://reviews.llvm.org/D145835 The new pass manager does change the binary size in many cases: both growing and shrinking it. However, on average the binary size remains more or less the same. This is needed as a preparation for LLVM 17.
2023-09-18all: switch to LLVM 16Ayke van Laethem
This commit adds support for LLVM 16 and switches to it by default. That means three LLVM versions are supported at the same time: LLVM 14, 15, and 16. This commit includes work by QuLogic: * Part of this work was based on a PR by QuLogic: https://github.com/tinygo-org/tinygo/pull/3649 But I also had parts of this already implemented in an old branch I already made for LLVM 16. * QuLogic also provided a CGo fix here, which is also incorporated in this commit: https://github.com/tinygo-org/tinygo/pull/3869 The difference with the original PR by QuLogic is that this commit is more complete: * It switches to LLVM 16 by default. * It updates some things to also make it work with a self-built LLVM. * It fixes the CGo bug in a slightly different way, and also fixes another one not included in the original PR. * It does not keep compiler tests passing on older LLVM versions. I have found this to be quite burdensome and therefore don't generally do this - the smoke tests should hopefully catch most regressions.
2023-09-17targets: increase default stack size to 32k for wasi/wasm targetsdeadprogram
Signed-off-by: deadprogram <[email protected]>
2023-08-17wasm: add support for GOOS=wasip1Ayke van Laethem
This adds true GOOS=wasip1 support in addition to our existing -target=wasi support. The old support for WASI isn't removed, but should be treated as deprecated and will likely be removed eventually to reduce the test burden.
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-06-17wasm: remove i64 workaround, use BigInt insteadAyke van Laethem
Browsers previously didn't support the WebAssembly i64 type, so we had to work around that limitation by converting the LLVM i64 type to something else. Some people used a pair of i32 values, but we used a pointer to a stack allocated i64. Now however, all major browsers and Node.js do support WebAssembly BigInt integration so that i64 values can be passed back and forth between WebAssembly and JavaScript easily. Therefore, I think the time has come to drop support for this workaround. For more information: https://v8.dev/features/wasm-bigint (note that TinyGo has used a slightly different way of passing i64 values between JS and Wasm). For information on browser support: https://webassembly.org/roadmap/
2023-06-06main: add -internal-nodwarf flagAyke van Laethem
This can be useful during development to avoid generating debug information in IR.
2023-05-17compileopts: don't filter build tags, use specific build tags insteadAyke van Laethem
This basically reverts https://github.com/tinygo-org/tinygo/pull/3357 and replaces it with a different mechanism to get to the same goal. I do not think filtering tags like this is a good idea: it's the wrong part of the compiler to be concerned with such tags (that part sets tags, but doesn't modify existing tags). Instead, I've written the //go:build lines in such a way that it has the same effect: WASI defaults to leveldb, everything else defaults to fnv, and it's possible to override the default using build tags.
2023-04-17targets: make msd-volume-name an arrayKenneth Bell
2023-04-12testing: add -test.shuffle to order randomize test and benchmark orderDamian Gryski
2023-03-31testing: add test.skipDamian Gryski
Fixes #3056