aboutsummaryrefslogtreecommitdiffhomepage
path: root/cgo/cgo_test.go
AgeCommit message (Collapse)Author
2024-01-18cgo: add file AST for fake C file locationsAyke van Laethem
This is needed for the type checker, otherwise it doesn't know which Go version it should use for type checking.
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-01-17builder: add support for Go 1.20Ayke van Laethem
Not all features work yet, but allow it to compile with this Go version.
2022-09-26cgo: fixes panic when FuncType.Results is nil (#3136)Crypt Keeper
* cgo: fixes panic when FuncType.Results is nil FuncType.Results can be nil. This fixes the comparison and backfills relevant tests. Signed-off-by: Adrian Cole <[email protected]> Co-authored-by: Ayke <[email protected]>
2022-09-16cgo: implement support for static functionsAyke van Laethem
2022-08-30all: drop support for Go 1.16 and Go 1.17Ayke van Laethem
2022-08-07all: update _test.go files for ioutil changesDamian Gryski
2022-02-12loader: only add Clang header path for CGoAyke van Laethem
It should only be added at the point that it is needed, for example when using libclang or using the built-in Clang. It isn't needed when running an external tool.
2021-11-24cgo: add //go: pragmas to generated functions and globalsAyke van Laethem
This patch adds //go: pragmas directly to declared functions and globals found during CGo processing. This simplifies the logic in the compiler: it no longer has to consider special "C." prefixed function names. It also makes the cgo pass more flexible in the pragmas it emits for functions and global variables.
2021-09-28builder, cgo: support function definitions in CGo headersAyke van Laethem
For example, the following did not work before but does work with this change: // int add(int a, int b) { // return a + b; // } import "C" func main() { println("add:", C.add(3, 5)) } Even better, the functions in the header are compiled together with the rest of the Go code and so they can be optimized together! Currently, inlining is not yet allowed but const-propagation across functions works. This should be improved in the future.
2021-09-28build: normalize target triples to match ClangAyke van Laethem
This commit changes a target triple like "armv6m-none-eabi" to "armv6m-unknown-unknow-eabi". The reason is that while the former is correctly parsed in Clang (due to normalization), it wasn't parsed correctly in LLVM meaning that the environment wasn't set to EABI. This change normalizes all target triples and uses the EABI environment (-eabi in the triple) for Cortex-M targets. This change also drops the `--target=` flag in the target JSON files, the flag is now added implicitly in `(*compileopts.Config).CFlags()`. This removes some duplication in target JSON files. Unfortunately, this change also increases code size for Cortex-M targets. It looks like LLVM now emits calls like __aeabi_memmove instead of memmove, which pull in slightly more code (they basically just call the regular C functions) and the calls themself don't seem to be as efficient as they could be. Perhaps this is a LLVM bug that will be fixed in the future, as this is a very common occurrence.
2021-09-27all: fix staticcheck warningsAyke van Laethem
This is a loose collection of small fixes flagged by staticcheck: - dead code - regexp expressions not using backticks (`foobar` / "foobar") - redundant types of slice and map initializers - misc other fixes Not all of these seem very useful to me, but in particular dead code is nice to fix. I've fixed them all just so that if there are problems, they aren't hidden in the noise of less useful issues.
2021-09-09cgo: don't normalize CGo tests anymoreAyke van Laethem
Normalization was required because previously we supported Go 1.13 and Go 1.14 at the same time. Now we've dropped support for both so this normalization is not necessary anymore. CGo support remains the same. It's just the test outputs that aren't normalized anymore.
2021-04-06cgo: add support for CFLAGS in .c filesAyke van Laethem
This patch adds support for passing CFLAGS added in #cgo lines of the CGo preprocessing phase to the compiler when compiling C files inside packages. This is expected and convenient but didn't work before.
2021-03-21builder, compiler: compile and cache packages in parallelAyke van Laethem
This commit switches from the previous behavior of compiling the whole program at once, to compiling every package in parallel and linking the LLVM bitcode files together for further whole-program optimization. This is a small performance win, but it has several advantages in the future: - There are many more things that can be done per package in parallel, avoiding the bottleneck at the end of the compiler phase. This should speed up the compiler futher. - This change is a necessary step towards a non-LTO build mode for fast incremental builds that only rebuild the changed package, when compiler speed is more important than binary size. - This change refactors the compiler in such a way that it will be easier to inspect the IR for one package only. Inspecting this IR will be very helpful for compiler developers.
2021-03-09all: replace strings.Replace with strings.ReplaceAllAyke van Laethem
This was an addition to Go 1.13 and results in slightly easier to read code.
2021-02-19Add support for Go 1.16.Elliott Sales de Andrade
2020-05-21cgo: Add LDFlags supportLucas Teske
2020-04-12cgo: normalize test resultsElliott Sales de Andrade
This makes the result consistent across Go versions, by running a regex on the CGo output that wraps all single-line functions in a consistent way. Originally written by Elliott Sales de Andrade and modified by Ayke van Laethem.
2020-01-03cgo: add support for symbolsAyke van Laethem
2019-12-08cgo: don't run tests in parallelAyke van Laethem
Since LLVM 9, CGo sometimes randomly breaks with weird error messages on Windows. I'm not sure why this is the case, but it might be related to concurrency. Disable concurrency for now, and hope that will make the errors go away.
2019-11-25cgo: implement #cgo CFLAGSAyke van Laethem
This implementation is still very limited but provides a base to build upon. Limitations: * CGO_CFLAGS etc is not taken into account. * These CFLAGS are not used in C files compiled with the package. * Other flags (CPPFLAGS, LDFAGS, ...) are not yet implemented.
2019-11-25cgo: add tests for errorsAyke van Laethem
This commit adds tests for CGo preprocessing. There are various errors that can be reported while preprocessing, and they should integrate well with the compiler (including accurate source location tracking). Also allow CGo preprocessing to continue after Clang encountered an error, for a better view of what happened.
2019-11-08cgo: add -update flag to testsAyke van Laethem
When this flag is set, the testdata/*.out.go files will be updated when they have changed. This is very convenient for updating these files after the expected output changes. Of course, the updated output must still be checked for validity.
2019-11-06cgo: do type checking in CGo testingAyke van Laethem
Such type checking should hopefully catch more bugs. This commit also fixes some existing type errors.
2019-11-03cgo: add tests for most C typesAyke van Laethem
2019-11-03cgo: add bare-bones testAyke van Laethem