Browse Source

cgo: add a check that we don't use different LLVM versions

pull/2959/head
Ayke van Laethem 2 years ago
committed by Ron Evans
parent
commit
27162ebe32
  1. 13
      cgo/libclang.go

13
cgo/libclang.go

@ -13,10 +13,13 @@ import (
"strconv" "strconv"
"strings" "strings"
"unsafe" "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 <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 <stdlib.h>
#include <stdint.h> #include <stdint.h>
@ -76,6 +79,16 @@ var diagnosticSeverity = [...]string{
// theory decoupled from Clang) can also use this type. // theory decoupled from Clang) can also use this type.
type clangCursor = C.GoCXCursor 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)) { func (f *cgoFile) readNames(fragment string, cflags []string, filename string, callback func(map[string]clangCursor)) {
index := C.clang_createIndex(0, 0) index := C.clang_createIndex(0, 0)
defer C.clang_disposeIndex(index) defer C.clang_disposeIndex(index)

Loading…
Cancel
Save