llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

FFI fails to build on FreeBSD against llvm20

Open oaken-source opened this issue 2 months ago • 1 comments

building ffi fails on FreeBSD 15 with the following error message:

      >>> referenced by Program.cpp
      >>>               Program.cpp.o:(Execute(llvm::sys::ProcessInfo&, llvm::StringRef,
      llvm::ArrayRef<llvm::StringRef>, std::__1::optional<llvm::ArrayRef<llvm::StringRef>>,
      llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, unsigned int, std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char>>*, llvm::BitVector*, bool)) in archive
      /usr/local/llvm20/lib/libLLVMSupport.a
      c++: error: linker command failed with exit code 1 (use -v to see invocation)

which breaks installation when attempting to build the wheel.

the root cause for this seems to be that the environ symbol is not available from libc when building a library, and instead is resolved when linking the application. there seem to have been a number of similar build issues reported for other projects over the years, where the typical fix seems to have been to add -Wl,--warn-unresolved-symbols to the linker flags.

in the case of ffi, the appropriate spot seems to be FORCED_LINK_FLAGS for non-apple UNIXes in CMakeLists.txt

oaken-source avatar Dec 09 '25 21:12 oaken-source

Thanks for the report and analysis! Are you able to provide a PR with the changes that worked for you, or a diff of the changes? We don't have a FreeBSD setup to test on but do want to help those who want to build on other platforms to be able to do so smoothly and with minimum issues.

gmarkall avatar Dec 12 '25 14:12 gmarkall