Fake linker plugin compatible with lld and GNU ld, which dumps the linker's
command-line in a file. This is meant to be used with clang's -fembed-bitcode
on platforms where bitcode embedding doesn't include linker options.
Disclaimer: the code works as is but isn't meant to be production-ready.
- Linux (GNU ld, lld)
- Windows (lld)
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build
cmake -B build && cmake --build build --config Release
When using clang with lld, you can use the plugin like so:
clang -O2 -fuse-ld=lld -fembed-bitcode -Wl,-mllvm=-load=/path/to/libplugin.so file.c
When using clang with GNU ld, you can use the plugin like so:
clang -O2 -fembed-bitcode -Wl,-plugin=/path/to/libplugin.so file.c
When using clang with lld, you can use the plugin like so:
clang -O2 -fuse-ld=lld -fembed-bitcode -Wl,/mllvm:-load=C:\\path\\to\\plugin.dll file.c
The linker options are dumped into a file located next to the output
executable, with the .llvmldcmd
extension.
Much like the .llvmcmd
section generated by the linker, the output file
generated by the plugin contains each command-line argument separated by NUL
chars. However, please note that the first argument will be the linker's file
path.