Skip to content

Commit 4bc78e2

Browse files
committed
Discover supported targets instead of hard coding them.
1 parent 972f34b commit 4bc78e2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/LLVM.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@ let
3333

3434
global const libllvm_version = Base.libllvm_version::VersionNumber
3535

36+
# figure out the supported targets by looking at initialization routines
37+
lib = Libdl.dlopen(libllvm)
38+
llvm_targets = [:AArch64, :AMDGPU, :ARC, :ARM, :AVR, :BPF, :Hexagon, :Lanai, :MSP430,
39+
:Mips, :NVPTX, :PowerPC, :RISCV, :Sparc, :SystemZ, :WebAssembly, :X86,
40+
:XCore]
41+
@show global const libllvm_targets = filter(llvm_targets) do target
42+
sym = Libdl.dlsym_e(lib, Symbol("LLVMInitialize$(target)Target"))
43+
sym !== nothing
44+
end
3645
# TODO: figure out the name of the native target
37-
global const libllvm_targets = [:NVPTX, :AMDGPU]
3846

3947
@debug "Found LLVM v$libllvm_version at $libllvm with support for $(join(libllvm_targets, ", "))"
4048

0 commit comments

Comments
 (0)