summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-02-12 21:36:55 +0000
committerChris Bieneman <beanz@apple.com>2016-02-12 21:36:55 +0000
commit3878bc4a33fd4461c8e2b3d80259a6b9a3b3277d (patch)
treefa0ff5f27dc41658aacbe0f4d40a40c364c85889 /clang/tools
parentbb49490de1dea43b036ecb9db09b4e6cce0b04b6 (diff)
downloadbcm5719-llvm-3878bc4a33fd4461c8e2b3d80259a6b9a3b3277d.tar.gz
bcm5719-llvm-3878bc4a33fd4461c8e2b3d80259a6b9a3b3277d.zip
[CMake] Improve the clang order-file generation workflow
Summary: This commit re-lands r259862. The underlying cause of the build breakage was an incorrectly written capabilities test. In tools/Driver/CMakeLists.txt I was attempting to check if a linker flag worked, the test was passing it to the compiler, not the linker. CMake doesn't have a linker test, so we have a hand-rolled one. Original Patch Review: http://reviews.llvm.org/D16896 Original Summary: With this change generating clang order files using dtrace uses the following workflow: cmake <whatever options you want> ninja generate-order-file ninja clang This patch works by setting a default path to the order file (which can be overridden by the user). If the order file doesn't exist during configuration CMake will create an empty one. CMake then ties up the dependencies between the clang link job and the order file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order file. Reviewers: bogner Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16999 llvm-svn: 260742
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/driver/CMakeLists.txt20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index bb631db79c3..d8bdd702482 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -87,8 +87,24 @@ if (APPLE)
set(TOOL_INFO_BUILD_VERSION)
endif()
-if(CLANG_ORDER_FILE AND EXISTS CLANG_ORDER_FILE)
- target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+if(CLANG_ORDER_FILE)
+ include(CMakePushCheckState)
+
+ function(check_linker_flag flag out_var)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
+ check_cxx_compiler_flag("" ${out_var})
+ cmake_pop_check_state()
+ endfunction()
+
+ # This is a test to ensure the actual order file works with the linker.
+ check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
+ LINKER_ORDER_FILE_WORKS)
+
+ if(LINKER_ORDER_FILE_WORKS)
+ target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+ set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
+ endif()
endif()
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
OpenPOWER on IntegriCloud