Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 1.41 KB

README.md

File metadata and controls

66 lines (42 loc) · 1.41 KB

llvm-ebc-lddump

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.

Supported Platforms

  • Linux (GNU ld, lld)
  • Windows (lld)

How to Build

Linux

cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build

Windows

cmake -B build && cmake --build build --config Release

How to Use

Linux

lld

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

GNU ld

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

Windows

lld

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

Output

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.