diff options
author | Ayke van Laethem <[email protected]> | 2022-07-04 13:40:22 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-07-04 14:54:39 +0200 |
commit | 27162ebe320088647ca6c169e91528810ab4c57f (patch) | |
tree | 3e5a64cf8248d8c494f0928621892d5907a8adeb /cgo | |
parent | b347aea450e5344edad3623b6b76d49f4e4600e9 (diff) | |
download | tinygo-27162ebe320088647ca6c169e91528810ab4c57f.tar.gz tinygo-27162ebe320088647ca6c169e91528810ab4c57f.zip |
cgo: add a check that we don't use different LLVM versions
Diffstat (limited to 'cgo')
-rw-r--r-- | cgo/libclang.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cgo/libclang.go b/cgo/libclang.go index f7aca9689..9afef323f 100644 --- a/cgo/libclang.go +++ b/cgo/libclang.go @@ -13,10 +13,13 @@ import ( "strconv" "strings" "unsafe" + + "tinygo.org/x/go-llvm" ) /* #include <clang-c/Index.h> // If this fails, libclang headers aren't available. Please take a look here: https://tinygo.org/docs/guides/build/ +#include <llvm/Config/llvm-config.h> #include <stdlib.h> #include <stdint.h> @@ -76,6 +79,16 @@ var diagnosticSeverity = [...]string{ // theory decoupled from Clang) can also use this type. type clangCursor = C.GoCXCursor +func init() { + // Check that we haven't messed up LLVM versioning. + // This can happen when llvm_config_*.go files in either this or the + // tinygo.org/x/go-llvm packages is incorrect. It should not ever happen + // with byollvm. + if C.LLVM_VERSION_STRING != llvm.Version { + panic("incorrect build: using LLVM version " + llvm.Version + " in the tinygo.org/x/llvm package, and version " + C.LLVM_VERSION_STRING + " in the ./cgo package") + } +} + func (f *cgoFile) readNames(fragment string, cflags []string, filename string, callback func(map[string]clangCursor)) { index := C.clang_createIndex(0, 0) defer C.clang_disposeIndex(index) |