summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2017-01-09 17:06:24 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2017-01-09 17:06:24 +0000
commit7820b29869c6f7dcbe2362159922315bfafce8ce (patch)
treefe23fcf06a487b91b07074dfcca806f871543401 /tools
parentf0e69d8f972711dcdb5faf499480967fdf2e81e7 (diff)
[clang] Enable using --section-ordering-file option of ld.gold
This diffs enables using --section-ordering-file option of ld.gold via the variable CLANG_ORDER_FILE. Differential revision: https://reviews.llvm.org/D28461 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/driver/CMakeLists.txt20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
index 49bde947f4..f6e26fa11f 100644
--- a/tools/driver/CMakeLists.txt
+++ b/tools/driver/CMakeLists.txt
@@ -72,7 +72,7 @@ endforeach()
# Configure plist creation for OS X.
set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
-if (APPLE)
+if (APPLE)
if (CLANG_VENDOR)
set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
else()
@@ -82,20 +82,19 @@ if (APPLE)
set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
set(TOOL_INFO_VERSION "${CLANG_VERSION}")
set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
-
+
set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
target_link_libraries(clang
"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
-
+
set(TOOL_INFO_UTI)
set(TOOL_INFO_NAME)
set(TOOL_INFO_VERSION)
set(TOOL_INFO_BUILD_VERSION)
endif()
-# the linker -order_file flag is only supported by ld64
-if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
+if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE))
include(CMakePushCheckState)
function(check_linker_flag flag out_var)
@@ -105,9 +104,14 @@ if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
cmake_pop_check_state()
endfunction()
+ if (LD64_EXECUTABLE)
+ set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
+ elseif (GOLD_EXECUTABLE)
+ set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
+ endif()
+
# 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)
+ check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
# Passing an empty order file disables some linker layout optimizations.
# To work around this and enable workflows for re-linking when the order file
@@ -117,7 +121,7 @@ if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
if("${ORDER_FILE}" STREQUAL "\n")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE})
elseif(LINKER_ORDER_FILE_WORKS)
- target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+ target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION})
set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
endif()
endif()