Skip to content

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

Open
@mrexodia

Description

@mrexodia

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.linkingzig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions