[llvm] r316059 - Statically link llvm-cfi-verify's libraries.
Vlad Tsyrklevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 21:27:53 PDT 2017
Author: vlad.tsyrklevich
Date: Tue Oct 17 21:27:53 2017
New Revision: 316059
URL: http://llvm.org/viewvc/llvm-project?rev=316059&view=rev
Log:
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
Modified:
llvm/trunk/tools/llvm-cfi-verify/lib/CMakeLists.txt
llvm/trunk/unittests/tools/llvm-cfi-verify/CMakeLists.txt
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/CMakeLists.txt?rev=316059&r1=316058&r2=316059&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cfi-verify/lib/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-cfi-verify/lib/CMakeLists.txt Tue Oct 17 21:27:53 2017
@@ -1,9 +1,12 @@
-add_llvm_library(LLVMCFIVerify
+add_library(LLVMCFIVerify
+ STATIC
FileAnalysis.cpp
- FileAnalysis.h
+ FileAnalysis.h)
- LINK_COMPONENTS
+llvm_update_compile_flags(LLVMCFIVerify)
+llvm_map_components_to_libnames(libs
MC
MCParser
Object
Support)
+target_link_libraries(LLVMCFIVerify ${libs})
Modified: llvm/trunk/unittests/tools/llvm-cfi-verify/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-cfi-verify/CMakeLists.txt?rev=316059&r1=316058&r2=316059&view=diff
==============================================================================
--- llvm/trunk/unittests/tools/llvm-cfi-verify/CMakeLists.txt (original)
+++ llvm/trunk/unittests/tools/llvm-cfi-verify/CMakeLists.txt Tue Oct 17 21:27:53 2017
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
AllTargetsDescs
AllTargetsDisassemblers
AllTargetsInfos
- CFIVerify
MC
MCParser
Object
@@ -15,4 +14,5 @@ list(FIND LLVM_TARGETS_TO_BUILD "X86" x8
if (NOT x86_idx LESS 0)
add_llvm_unittest(CFIVerifyTests
FileAnalysis.cpp)
+ target_link_libraries(CFIVerifyTests LLVMCFIVerify)
endif()
More information about the llvm-commits
mailing list