[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)
commit5f3f254ed1d601c60d03e4437f75783774b03583
tree8fc03098b16f399244caa09cf6f89943758c8b34
parentc305163d14a2522dc871573647f225474249aba4
[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221591 91177308-0d34-0410-b5e6-96231b3b80d8
tools/llvm-shlib/CMakeLists.txt