aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder
AgeCommit message (Collapse)Author
2024-08-17ci: use Go 1.23Ayke van Laethem
2024-08-15builder: os.SEEK_CUR -> io.SeekCurrentDamian Gryski
2024-08-15misspell.csv: add new misspellings; also check in result of 'make spellfix'.Dan Kegel
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-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-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-10cgo: add support for printfAyke van Laethem
The C printf function is sometimes needed for C files included using CGo. This commit makes sure they're available on all systems where CGo is fully supported (that is, everywhere except on AVR). For baremetal systems using picolibc, I've picked the integer-only version of printf to save on flash size. We might want to consider providing a way to pick the floating point version instead, if needed.
2024-08-10builtins: add GENERIC_TF_SOURCESAyke van Laethem
This addes GENERIC_TF_SOURCES, which contains long double floating point builtins (80 bit, 128 bit, etc). This is needed for full printf support.
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-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-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-21build: add package ID to compiler and optimization error messagesAyke van Laethem
This improves error reporting slightly.
2024-07-13builder: remove workaround for generics race conditionAyke van Laethem
This commit reverts commit 13a8eae0d. It appars that the race has been fixed by https://github.com/golang/tools/commit/db513b091504, which we now use because it fixes another race condition as well. See: https://github.com/tinygo-org/tinygo/issues/4206
2024-07-02wasi preview 2 support (#4027)Damian Gryski
* all: wasip2 support Co-authored-by: Randy Reddig <[email protected]>
2024-06-12all: drop support for Go 1.18Ayke van Laethem
Go 1.18 has been unsupported for quite a while now (the oldest supported version is Go 1.21). But more importantly, the golang.org/x/tools module now requires Go 1.19 or later. So we'll drop this older version.
2024-05-31builder: make sure wasm-opt command line is printed if askedDamian Gryski
2024-05-31builder: keep un-wasm-opt'd .wasm if -work was passedDamian Gryski
2024-05-24LLVM 18 supportAyke van Laethem
2024-04-30Add 'make spell' target, fix what it finds. In .go files, only checks comments.Dan Kegel
2024-03-27all: change references of 'wasi' to 'wasip1'; test hygieneRandy Reddig
2024-03-26builder: add check for error on creating needed directory as suggested by ↵deadprogram
@b0ch3nski Signed-off-by: deadprogram <[email protected]>
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-03-19wasm: fix symbol table index for archivesAyke van Laethem
The symbol table was generated incorrectly. The correct way is to use the custom linking WebAssembly section, which I implemented in go-wasm for this purpose. This fixes https://github.com/tinygo-org/tinygo/issues/4114 and is a prerequisite for https://github.com/tinygo-org/tinygo/pull/4176.
2024-03-19all: move -panic=trap support to the compiler/runtimeAyke van Laethem
Support for `-panic=trap` was previously a pass in the optimization pipeline. This change moves it to the compiler and runtime, which in my opinion is a much better place. As a side effect, it also fixes https://github.com/tinygo-org/tinygo/issues/4161 by trapping inside runtime.runtimePanicAt and not just runtime.runtimePanic. This change also adds a test for the list of imported functions. This is a more generic test where it's easy to add more tests for WebAssembly file properties, such as exported functions.
2024-02-17builder: add 'wasm-unknown' to list of targets for clang features verificationdeadprogram
Signed-off-by: deadprogram <[email protected]>
2024-01-31Allow larger systems to have a larger max stack allocDamian Gryski
Fixes #3331
2024-01-19all: support Go 1.22Ayke van Laethem
This adds initial support for Go 1.22. Not all new features are supported yet.
2024-01-19runtime: add runtime.rand functionAyke van Laethem
This function is needed for Go 1.22, and is used from various packages like math/rand. When there is no random number generator available, it falls back to a static sequence of numbers. I think this is fine, because as far as I can see it is only used for non-cryptographic needs.
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-09builder/picolib: add needed file for compiling math functions with error ↵deadprogram
support. Thanks to @aykevl for actually finding and providing this fix, I really just reported the problem and tested the fix. Signed-off-by: deadprogram <[email protected]>
2023-11-24refactor: reuse OptLevel() to get the opt levelRado M
2023-10-15builder: generalize build ID fallback to darwinAyke van Laethem
This is to support NixOS, who have added -no_uuid to the linker. Upstream bug report: https://github.com/NixOS/nixpkgs/issues/178366
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-06avr: don't compile large parts of picolibc (math, stdio)Ayke van Laethem
These parts aren't critical and lead to crashes on small chips without long jumps (like the attiny85) with LLVM 17. (Older LLVM versions would emit long jumps regardless, even if the chip didn't support those). For more information, see: https://github.com/llvm/llvm-project/issues/67042
2023-10-04build: avoid sharing GlobalValues between build instancesAyke van Laethem
This happens with `tinygo test` for example when testing multiple packages at the same time. I found this because the compiler crashed in `make tinygo-test-fast`: fatal error: concurrent map writes fatal error: concurrent map read and map write goroutine 15 [running]: github.com/tinygo-org/tinygo/builder.Build({0x40002d0be0, 0xa}, {0x0, 0x0}, {0x4000398048, 0x14}, 0x40003b0000) /home/ayke/src/tinygo/tinygo/builder/build.go:131 +0x388 main.buildAndRun({0x40002d0be0, 0xa}, 0x40003b0000, {0x8bc178, 0x40003a4090}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...) /home/ayke/src/tinygo/tinygo/main.go:856 +0x45c main.Test({0x40002d0be0, 0xa}, {0x8bc118, 0x40000b3a08}, {0x0?, 0x0?}, 0x40001e6000, {0x0, 0x0}) /home/ayke/src/tinygo/tinygo/main.go:270 +0x758 main.main.func3() /home/ayke/src/tinygo/tinygo/main.go:1718 +0xe4 created by main.main in goroutine 1 /home/ayke/src/tinygo/tinygo/main.go:1712 +0x34ec My solution is essentially to copy the map over instead of modifying it directly. I've also moved the code up a little, because I think that's a more sensible place (out of the way of the whole package compile logic).
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-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-10-01all: remove LLVM 14 supportAyke van Laethem
This is a big change: apart from removing LLVM 14 it also removes typed pointer support (which was only fully supported in LLVM up to version 14). This removes about 200 lines of code, but more importantly removes a ton of special cases for LLVM 14.
2023-09-20build: build Go SSA serially [issue 3895]Dan Kegel
From https://github.com/tinygo-org/tinygo/pull/3915#issuecomment-1724405109 According to Ayke, it slows down the build but seems to reliably fix https://github.com/tinygo-org/tinygo/issues/3895
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-16atsamd21, atsamd51: add support for USB INTERRUPT OUTsago35
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-09builder: update message for max supported Go versiondeadprogram
Signed-off-by: deadprogram <[email protected]>
2023-08-04all: Go 1.21 supportAyke van Laethem
2023-08-04testing: add Testing functionAyke van Laethem
This is new in Go 1.21.
2023-07-31compiler: add compiler-rt and wasm symbols to tableCharlie Haley
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-06-18example: simplify pininterruptYurii Soldak