OSDN Git Service

Statically link llvm-cfi-verify's libraries.
authorVlad Tsyrklevich <vlad@tsyrklevich.net>
Wed, 18 Oct 2017 04:27:53 +0000 (04:27 +0000)
committerVlad Tsyrklevich <vlad@tsyrklevich.net>
Wed, 18 Oct 2017 04:27:53 +0000 (04:27 +0000)
commit61b2faea7e8cd5285f0e2a1eedbabf4aa5a63aec
tree4a58ad93edb01db29e9c4cd04fa0cd514a117ac2
parentae96b7ff9f97c3b3d78c4212337d90d9192d7012
Statically link llvm-cfi-verify's libraries.

Summary:
llvm-cfi-verify (D38379) introduced a potential build failure when compiling with `-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON`. Specific versions of cmake seem to treat the `add_subdirectory()` rule differently. It seems as if old versions of cmake BFS these rules, adding them to the fringe for expansion later. Newer versions of cmake seem to immediately execute CMakeFiles that are present in this subdirectory.

If the subdirectory is expanded through the fringe, the globbing resultant from `llvm_add_implicit_projects()` from `cmake/modules/AddLLVM.cmake:1012` means that `tools/llvm-shlib/CMakeFile.txt` gets executed before `tools/llvm-cfi-verify/lib/CMakeFile.txt`. As the latter CMakeFile adds a new library, this expansion order means that the library files required the unit tests in `unittests/tools/llvm-cfi-verify/` are not present in the dynamic library. This causes unit tests to fail as the required functions can't be found.

This change now ensures that the libraries created by `llvm-cfi-verify` are statically linked into the unit tests. As `tools/llvm-cfi-verify/lib` no longer adds anything to `llvm-shlib`, there should be no concern about the order-of-compilation.

Reviewers: skatkov, pcc

Reviewed By: skatkov, pcc

Subscribers: llvm-commits, kcc, pcc, aheejin, vlad.tsyrklevich, mgorny

Differential Revision: https://reviews.llvm.org/D39020

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316059 91177308-0d34-0410-b5e6-96231b3b80d8
tools/llvm-cfi-verify/lib/CMakeLists.txt
unittests/tools/llvm-cfi-verify/CMakeLists.txt