Skip to content

Add lipoless target dependency and link_directory to _add_swift_execu… #14843

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1917,9 +1917,16 @@ function(_add_swift_executable_single name)
set(c_compile_flags)
set(link_flags)

# Prepare linker search directories.
set(library_search_directories
# Prepare linker search directories. On Darwin, we want the fat library paths. On
# non-Darwin we want the architecture specific versions.
is_darwin_based_sdk("${SWIFTEXE_SINGLE_SDK}" IS_DARWIN)
if (IS_DARWIN)
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
else()
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}/${SWIFTEXE_SINGLE_ARCHITECTURE}")
endif()

# Add variant-specific flags.
_add_variant_c_compile_flags(
Expand All @@ -1945,7 +1952,6 @@ function(_add_swift_executable_single name)
list(APPEND link_flags "-Wl,-no_pie")
endif()

is_darwin_based_sdk("${SWIFTEXE_SINGLE_SDK}" IS_DARWIN)
if(IS_DARWIN)
list(APPEND link_flags
"-Xlinker" "-rpath"
Expand All @@ -1954,12 +1960,19 @@ function(_add_swift_executable_single name)

# Find the names of dependency library targets.
#
# We don't add the ${ARCH} to the target suffix because we want to link
# We don't add the ${ARCH} to the target suffix on Darwin because we want to link
# against fat libraries.
_list_add_string_suffix(
"${SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES}"
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}"
SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES_TARGETS)
if (IS_DARWIN)
_list_add_string_suffix(
"${SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES}"
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}"
SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES_TARGETS)
else()
_list_add_string_suffix(
"${SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES}"
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}-${SWIFTEXE_SINGLE_ARCHITECTURE}"
SWIFTEXE_SINGLE_LINK_FAT_LIBRARIES_TARGETS)
endif()

handle_swift_sources(
dependency_target
Expand Down Expand Up @@ -2069,12 +2082,19 @@ function(add_swift_target_executable name)
add_dependencies("swift-test-stdlib${VARIANT_SUFFIX}" ${VARIANT_NAME})
endif()

# Don't add the ${arch} to the suffix. We want to link against fat
# On Darwin, don't add the ${arch} to the suffix. We want to link against fat
# libraries.
_list_add_string_suffix(
"${SWIFTEXE_TARGET_DEPENDS}"
"-${SWIFT_SDK_${sdk}_LIB_SUBDIR}"
SWIFTEXE_TARGET_DEPENDS_with_suffix)
if (IS_DARWIN)
_list_add_string_suffix(
"${SWIFTEXE_TARGET_DEPENDS}"
"-${SWIFT_SDK_${sdk}_LIB_SUBDIR}"
SWIFTEXE_TARGET_DEPENDS_with_suffix)
else()
_list_add_string_suffix(
"${SWIFTEXE_TARGET_DEPENDS}"
"${VARIANT_SUFFIX}"
SWIFTEXE_TARGET_DEPENDS_with_suffix)
endif()
_add_swift_executable_single(
${VARIANT_NAME}
${SWIFTEXE_TARGET_SOURCES}
Expand Down