ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.79k stars 2.47k forks source link

Support -Bsymbolic-functions #18804

Closed theoparis closed 1 month ago

theoparis commented 7 months ago

This seems to be a blocker in my fork of zig-bootstrap when rebuilding LLVM 17.0.6 with zig.

...
error: unsupported linker arg: -Bsymbolic-functions
[4360/4881] Building CXX object tools/lld/COFF/CMakeFiles/lldCOFF.dir/InputFiles.cpp.o
ninja: build stopped: subcommand failed.

See https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/clang/tools/clang-shlib/CMakeLists.txt#L54

The current solution is to either patch LLVM or to disable shared libraries entirely with -DLLVM_ENABLE_PIC=OFF.

kassane commented 7 months ago
# archlinux (lld llvm-16)
$> ld.lld --help | grep -e "Bsymbolic-functions"
  --Bsymbolic-functions   Bind default visibility defined function symbols locally for -shared
# zig v0.12.0-dev/master
$>  zig ld.lld --help | grep -e "Bsymbolic-functions"
  --Bsymbolic-functions   Bind default visibility defined function symbols locally for -shared
# GNU ld (GNU Binutils) 2.42.0
$>  ld --help | grep -e "Bsymbolic-functions"
  -Bsymbolic-functions        Bind global function references locally
kassane commented 7 months ago

@theoparis , see https://github.com/ziglang/zig-bootstrap/commit/451966c163c7a2e9769d62fd77585af1bc9aca4b

theoparis commented 7 months ago

yeah, patching clang with that patch solves it.

xdqi commented 2 months ago

Using zig c++ to compile LLVM 18.1.8 (latest) fails with this problem as well. Why would zig patches LLVM source code instead of fixing this bug?

andrewrk commented 1 month ago

The use case described here is not compelling because the purpose of zig-bootstrap is to build a static zig compiler, which makes this flag irrelevant. However the feature is still OK to support.

xdqi commented 1 month ago

Okay that seems to make sense.