-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Un-revert][Glibc] Configure modulemap for target, not host #1704
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
Merged
modocache
merged 1 commit into
swiftlang:master
from
modocache:unrevert-target-specific-glibc
Mar 16, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,44 +3,57 @@ set(sources | |
Misc.c | ||
) | ||
|
||
set(output_dir "${SWIFTLIB_DIR}/glibc") | ||
# When cross-compiling the stdlib on Unix platforms, we'll need a separate | ||
# glibc for each target. | ||
foreach(SDK ${SWIFT_SDKS}) | ||
foreach(arch ${SWIFT_SDK_${SDK}_ARCHITECTURES}) | ||
# Don't generate Glibc module maps for Darwin targets. | ||
if("${SDK}" STREQUAL "LINUX" OR "${SDK}" STREQUAL "FREEBSD") | ||
set(output_dir "${SWIFTLIB_DIR}/${SWIFT_SDK_${SDK}_LIB_SUBDIR}/${arch}") | ||
|
||
# Set correct paths to glibc headers | ||
set(GLIBC_INCLUDE_PATH "/usr/include") | ||
if(CMAKE_LIBRARY_ARCHITECTURE) | ||
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
else() | ||
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}") | ||
endif() | ||
if (NOT EXISTS "${GLIBC_ARCH_INCLUDE_PATH}/sys") | ||
message(FATAL_ERROR "Glibc headers were not found.") | ||
endif() | ||
# Determine the location of glibc based on the target. | ||
set(GLIBC_INCLUDE_PATH "/usr/include") | ||
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}") | ||
if(("${SDK}" STREQUAL "LINUX" OR "${SDK}" STREQUAL "FREEBSD") AND CMAKE_LIBRARY_ARCHITECTURE) | ||
# FIXME: Some distributions install headers in | ||
# "/usr/include/x86_64-linux-gnu/sys/...". Here we use the host | ||
# machine's path, regardless of the SDK target we're building for. | ||
# This will break if cross-compiling from a distro that uses the | ||
# architecture as part of the path to a distro that does not. | ||
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
endif() | ||
|
||
# Generate module.map | ||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
configure_file(module.map.in "${CMAKE_CURRENT_BINARY_DIR}/module.map" @ONLY) | ||
endif() | ||
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") | ||
configure_file(module.freebsd.map.in "${CMAKE_CURRENT_BINARY_DIR}/module.map" @ONLY) | ||
endif() | ||
# Configure the module map based on the target. Each platform needs to | ||
# reference different headers, based on what's available in their glibc. | ||
set(modulemap_path "${CMAKE_CURRENT_BINARY_DIR}/${SWIFT_SDK_${SDK}_LIB_SUBDIR}/${arch}/module.map") | ||
if("${SDK}" STREQUAL "FREEBSD") | ||
configure_file(module.freebsd.map.in "${modulemap_path}" @ONLY) | ||
else() | ||
configure_file(module.map.in "${modulemap_path}" @ONLY) | ||
endif() | ||
|
||
add_custom_command_target(unused_var | ||
COMMAND | ||
"${CMAKE_COMMAND}" "-E" "make_directory" "${output_dir}" | ||
COMMAND | ||
"${CMAKE_COMMAND}" "-E" "copy_if_different" | ||
"${CMAKE_CURRENT_BINARY_DIR}/module.map" | ||
"${output_dir}/module.map" | ||
CUSTOM_TARGET_NAME "copy_glibc_module" | ||
OUTPUT "${output_dir}/module.map" "${output_dir}" | ||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/module.map" | ||
COMMENT "Copying Glibc module to ${output_dir}") | ||
set(VARIANT_SUFFIX "-${SWIFT_SDK_${SDK}_LIB_SUBDIR}-${arch}") | ||
add_custom_command_target(unused_var | ||
COMMAND | ||
"${CMAKE_COMMAND}" "-E" "make_directory" "${output_dir}" | ||
COMMAND | ||
"${CMAKE_COMMAND}" "-E" "copy_if_different" | ||
"${modulemap_path}" | ||
"${output_dir}/glibc.modulemap" | ||
CUSTOM_TARGET_NAME "copy_glibc_module${VARIANT_SUFFIX}" | ||
OUTPUT "${output_dir}/glibc.modulemap" "${output_dir}" | ||
DEPENDS "${modulemap_path}" | ||
COMMENT "Copying Glibc module to ${output_dir}") | ||
|
||
swift_install_in_component(stdlib | ||
FILES "${output_dir}/module.map" | ||
DESTINATION "lib/swift/glibc") | ||
swift_install_in_component(stdlib | ||
FILES "${output_dir}/glibc.modulemap" | ||
DESTINATION "${output_dir}") | ||
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 think, this line was the problem. 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. |
||
|
||
add_swift_library(swiftGlibc IS_SDK_OVERLAY | ||
${sources} | ||
FILE_DEPENDS copy_glibc_module "${output_dir}" | ||
INSTALL_IN_COMPONENT stdlib-experimental) | ||
add_swift_library(swiftGlibc IS_SDK_OVERLAY | ||
${sources} | ||
FILE_DEPENDS "copy_glibc_module${VARIANT_SUFFIX}" "${output_dir}" | ||
TARGET_SDKS "${SDK}" | ||
INSTALL_IN_COMPONENT stdlib-experimental) | ||
endif() | ||
endforeach() | ||
endforeach() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This
if()
statement is the only difference between this and #1679. ☝️