-
Notifications
You must be signed in to change notification settings - Fork 7
Add LLVM 21 support while keeping LLVM 19 as default #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
24c2781
cf30809
fc31d00
6003353
0ed2f56
c8a913f
f80af7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,10 @@ package llvm | |
| #include <stdlib.h> | ||
| */ | ||
| import "C" | ||
| import "unsafe" | ||
| import "errors" | ||
| import ( | ||
| "errors" | ||
| "unsafe" | ||
| ) | ||
|
|
||
| func LinkInMCJIT() { C.LLVMLinkInMCJIT() } | ||
| func LinkInInterpreter() { C.LLVMLinkInInterpreter() } | ||
|
|
@@ -110,6 +112,17 @@ func NewInterpreter(m Module) (ee ExecutionEngine, err error) { | |
| return | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Without this, callers cannot distinguish between the two JIT constructors in the package. |
||
|
|
||
| func NewJITCompiler(m Module, optLevel int) (ee ExecutionEngine, err error) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| var cmsg *C.char | ||
| fail := C.LLVMCreateJITCompilerForModule(&ee.C, m.C, C.uint(optLevel), &cmsg) | ||
| if fail != 0 { | ||
| ee.C = nil | ||
| err = errors.New(C.GoString(cmsg)) | ||
| C.LLVMDisposeMessage(cmsg) | ||
| } | ||
| return | ||
| } | ||
|
zhouguangyuan0718 marked this conversation as resolved.
|
||
|
|
||
| func NewMCJITCompilerOptions() MCJITCompilerOptions { | ||
| var options C.struct_LLVMMCJITCompilerOptions | ||
| C.LLVMInitializeMCJITCompilerOptions(&options, C.size_t(unsafe.Sizeof(C.struct_LLVMMCJITCompilerOptions{}))) | ||
|
|
@@ -159,6 +172,12 @@ func (ee ExecutionEngine) FindFunction(name string) (f Value) { | |
| return | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider mirroring the pattern of Additionally, per LLVM docs, |
||
| } | ||
|
|
||
| func (ee ExecutionEngine) GetFunctionAddress(name string) uint64 { | ||
| cname := C.CString(name) | ||
| defer C.free(unsafe.Pointer(cname)) | ||
| return uint64(C.LLVMGetFunctionAddress(ee.C, cname)) | ||
| } | ||
|
|
||
| func (ee ExecutionEngine) RecompileAndRelinkFunction(f Value) unsafe.Pointer { | ||
| return C.LLVMRecompileAndRelinkFunction(ee.C, f.C) | ||
| } | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:build !byollvm && llvm14 | ||
|
|
||
| package llvm | ||
|
|
||
| // #cgo darwin,amd64 CPPFLAGS: -I/usr/local/opt/llvm@14/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,amd64 CXXFLAGS: -std=c++14 | ||
| // #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@14/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo darwin,arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@14/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,arm64 CXXFLAGS: -std=c++14 | ||
| // #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@14/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo linux CPPFLAGS: -I/usr/lib/llvm-14/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo linux CXXFLAGS: -std=c++14 | ||
| // #cgo linux LDFLAGS: -L/usr/lib/llvm-14/lib -lLLVM-14 | ||
| import "C" | ||
|
|
||
| type run_build_sh int |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:build !byollvm && llvm15 | ||
|
|
||
| package llvm | ||
|
|
||
| // #cgo darwin,amd64 CPPFLAGS: -I/usr/local/opt/llvm@15/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,amd64 CXXFLAGS: -std=c++14 | ||
| // #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@15/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo darwin,arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@15/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,arm64 CXXFLAGS: -std=c++14 | ||
| // #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@15/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo linux CPPFLAGS: -I/usr/lib/llvm-15/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo linux CXXFLAGS: -std=c++14 | ||
| // #cgo linux LDFLAGS: -L/usr/lib/llvm-15/lib -lLLVM-15 | ||
| import "C" | ||
|
|
||
| type run_build_sh int |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:build !byollvm && llvm16 | ||
|
|
||
| package llvm | ||
|
|
||
| // #cgo darwin,amd64 CPPFLAGS: -I/usr/local/opt/llvm@16/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,amd64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@16/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo darwin,arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@16/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,arm64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@16/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo linux CPPFLAGS: -I/usr/lib/llvm-16/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo linux CXXFLAGS: -std=c++17 | ||
| // #cgo linux LDFLAGS: -L/usr/lib/llvm-16/lib -lLLVM-16 | ||
| import "C" | ||
|
|
||
| type run_build_sh int |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:build !byollvm && llvm17 | ||
|
|
||
| package llvm | ||
|
|
||
| // #cgo darwin,amd64 CPPFLAGS: -I/usr/local/opt/llvm@17/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,amd64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@17/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo darwin,arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@17/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,arm64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@17/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo linux CPPFLAGS: -I/usr/include/llvm-17 -I/usr/include/llvm-c-17 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo linux CXXFLAGS: -std=c++17 | ||
| // #cgo linux LDFLAGS: -L/usr/lib/llvm-17/lib -lLLVM-17 | ||
| import "C" | ||
|
|
||
| type run_build_sh int |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:build !byollvm && llvm18 | ||
|
|
||
| package llvm | ||
|
|
||
| // #cgo darwin,amd64 CPPFLAGS: -I/usr/local/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,amd64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo darwin,arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo darwin,arm64 CXXFLAGS: -std=c++17 | ||
| // #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm | ||
| // #cgo linux CPPFLAGS: -I/usr/include/llvm-18 -I/usr/include/llvm-c-18 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
| // #cgo linux CXXFLAGS: -std=c++17 | ||
| // #cgo linux LDFLAGS: -L/usr/lib/llvm-18/lib -lLLVM-18 | ||
| import "C" | ||
|
|
||
| type run_build_sh int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
brew updateguard was moved fromllvm == 20tollvm == 21, but not extended to cover 20. If the LLVM 20 Homebrew formula drifts or becomes unavailable without abrew update, macOS CI for LLVM 20 will silently fail or use a stale index. The original intent was to runbrew updatefor the newest/freshest version. Now that 21 is the newest, consider whether 20 also still needs it, or document why only 21 requires this step.