I'm hoping to get pointed in the right direction for the most idiomatic way to link and compile LLVM bitcode (.bc) files generated by different compilers using the Meson build system.
In a nutshell (from ISPC FAQ):
$ ispc --emit-llvm -o foo_ispc.bc foo.ispc
$ clang -O2 -c -emit-llvm -o foo_cpp.bc foo.cpp
$ llvm-link foo_ispc.bc foo_cpp.bc -o - | opt -O3 -o foo_opt.bc
$ llc -filetype=obj foo_opt.bc -o foo.o
The purpose is to facilitate inlining and cross-function optimizations in code compiled with Intel's ISPC compiler and vanilla clang.
I've found examples of defining a generator
for ISPC, the gap in knowledge is how to best link/optimize/compile LLVM bitcode (.bc) files using LLVM's bitcode linker (llvm-link
), optimizer (opt
), and static compiler (llc
). I cannot find any meson build scripts in the wild that that achieve this.
I can see that assembler (.S) and LLVM IR (.ll) files are supported by library()
and executable()
, but cannot find any mentions of LLVM bitcode in the docs nor the source.
Thanks a bunch!
If you are looking for a way to make
library()
andexecutable()
work with .bc files, sadly, your only option is to submit an upstream change. There's a similar question in the FAQ that sums up the reasoning:https://mesonbuild.com/FAQ.html#i-have-proprietary-compiler-toolchain-x-that-does-not-work-with-meson-how-can-i-make-it-work
Your question is about linking and not compiling but I think the answer is still the same.