Skip to content
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

-Wl,-mllvm causes unsupported linker arg: -mllvm #22291

Open
mrexodia opened this issue Dec 22, 2024 · 2 comments
Open

-Wl,-mllvm causes unsupported linker arg: -mllvm #22291

mrexodia opened this issue Dec 22, 2024 · 2 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. linking zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@mrexodia
Copy link

mrexodia commented Dec 22, 2024

Zig Version

0.14.0-dev.2546+0ff0bdb4a

Steps to Reproduce and Observed Behavior

Compile simple main.cpp:

zig c++ -target x86_64-linux-gnu main.cpp -o main -flto -fuse-ld=lld -v -Wl,-mllvm,-lto-embed-bitcode=optimized

Expected Behavior

Zig should include -mllvm -lto-embed-bitcode=optimized in the ld.lld command line.

Using the following command line on Linux works fine:

clang++ main.cpp -o main -flto -fuse-ld=lld -v -Wl,-mllvm,-lto-embed-bitcode=optimized

An alternative command line (also rejected) is: -Wl,--plugin-opt=-lto-embed-bitcode=optimized

This option is used to add a .llvmbc section to the final executable, which contains all of the bitcode, but there are other options as well. Related issue: #11204, related pull request llvm/llvm-project#79390 (attempt to add the linker command line as well as the working directory to this embedded bitcode file, which would allow reproducing the linking process after modifying the bitcode).

@mrexodia mrexodia added the bug Observed behavior contradicts documented or intended behavior label Dec 22, 2024
@alexrp alexrp added zig cc Zig as a drop-in C compiler feature linking enhancement Solving this issue will likely involve adding new logic or components to the codebase. and removed bug Observed behavior contradicts documented or intended behavior labels Dec 22, 2024
@alexrp alexrp added this to the 0.15.0 milestone Dec 22, 2024
@alexrp
Copy link
Member

alexrp commented Dec 22, 2024

Note that we're planning on dropping the LLD dependency Real Soon Now, so this option would only be supportable when using LLD through the Zig build system, and with Zig's LLVM backend. Usage of Zig's self-hosted linker and/or self-hosted backend(s) is fundamentally incompatible with this.

(Does Apple still require apps to ship with embedded bitcode?)

@mrexodia
Copy link
Author

Yeah this is for usage with zig c++ only. I do not need to embed the bitcode for Apple, it's to do my own post-processing on bitcode of the whole binary and zig is the most convenient cross compiler to play around with things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. linking zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

2 participants