[CMake] Let llvm-shlib work on Linux with --whole-archive.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 10 Nov 2014 15:04:02 +0000 (15:04 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 10 Nov 2014 15:04:02 +0000 (15:04 +0000)
commitc8abc4c20150ddb0acb52d42bce7a53780215240
treeb92d0e5f5bf3ef8a055708dca5c6bea67f93f661
parente1e5274a88f98467a4712d9d34d8c28b458f0f1b
[CMake] Let llvm-shlib work on Linux with --whole-archive.

FIXME: It should work on not only Linux but elf-targeting gnu ld.

For example if LLVM_DYLIB_COMPONENTS is "BitWriter Support", CMake emits the command line like;

  -Wl,--whole-archive
    lib/libLLVMBitWriter.a
    lib/libLLVMSupport.a *1
  -Wl,--no-whole-archive
  lib/libLLVMCore.a
  lib/libLLVMSupport.a   *2
  -lrt -ldl -ltinfo -lpthread -lm

It works since symbols in LLVMCore is resolved with not *2 but *1.

Unfortunately, --gc-sections is not powerful in this case to prune unused "visibility(default)" entries.

I am still experimenting other way not to rely on --whole-archive.

llvm-svn: 221591
llvm/tools/llvm-shlib/CMakeLists.txt