-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cmake] Work around relocation R_X86_64_PC32 link error #2012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -801,6 +801,19 @@ function(_add_swift_library_single target name) | |
list(APPEND link_flags "-fuse-ld=gold") | ||
endif() | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) | ||
INCLUDE(CheckCXXCompilerFlag) | ||
SET(CMAKE_REQUIRED_FLAGS "-Wl,-z,nocopyreloc") | ||
CHECK_CXX_COMPILER_FLAG("" LINKER_SUPPORTS_NOCOPYRELOC) | ||
IF(LINKER_SUPPORTS_NOCOPYRELOC) | ||
list(APPEND link_flags ${CMAKE_REQUIRED_FLAGS}) | ||
ENDIF() | ||
SET(CMAKE_REQUIRED_FLAGS "-Wl,-z,noextern-protected-data") | ||
CHECK_CXX_COMPILER_FLAG("" LINKER_SUPPORTS_NOEXTERN_PROTECTED_DATA) | ||
IF(LINKER_SUPPORTS_NOEXTERN_PROTECTED_DATA) | ||
list(APPEND link_flags ${CMAKE_REQUIRED_FLAGS}) | ||
ENDIF() | ||
|
||
# Configure plist creation for OS X. | ||
set(PLIST_INFO_PLIST "Info.plist" CACHE STRING "Plist name") | ||
if(APPLE AND SWIFTLIB_SINGLE_IS_STDLIB) | ||
|
@@ -1416,6 +1429,18 @@ function(_add_swift_executable_single name) | |
list(APPEND link_flags "-fuse-ld=gold") | ||
endif() | ||
|
||
INCLUDE(CheckCXXCompilerFlag) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually don't think this block is required. I merely included it because I think it might be. Someone who understands the CMake scripts a little better might be able to quickly deduce its necessity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this block is necessary. This function is used to configure compiler executables, which don't have any Swift code in them. |
||
SET(CMAKE_REQUIRED_FLAGS "-Wl,-z,nocopyreloc") | ||
CHECK_CXX_COMPILER_FLAG("" LINKER_SUPPORTS_NOCOPYRELOC) | ||
IF(LINKER_SUPPORTS_NOCOPYRELOC) | ||
list(APPEND link_flags ${CMAKE_REQUIRED_FLAGS}) | ||
ENDIF() | ||
SET(CMAKE_REQUIRED_FLAGS "-Wl,-z,noextern-protected-data") | ||
CHECK_CXX_COMPILER_FLAG("" LINKER_SUPPORTS_NOEXTERN_PROTECTED_DATA) | ||
IF(LINKER_SUPPORTS_NOEXTERN_PROTECTED_DATA) | ||
list(APPEND link_flags ${CMAKE_REQUIRED_FLAGS}) | ||
ENDIF() | ||
|
||
# Find the names of dependency library targets. | ||
# | ||
# We don't add the ${ARCH} to the target suffix because we want to link | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should
include()
or run tests in this function. This function is executed many times.You should run the test once in the top-level CMakeLists.txt.
Also, our CMake code uses lowercase for function names, and two spaces for indentation, could you make it consistent?