Skip to content

Commit 0fead56

Browse files
authored
Merge pull request swiftlang#37542 from gottesmm/pr-6f3b3e9945ec7bdb2fd4172287d645d428186efd
[cmake] Fix a couple of small issues with building host side tools in Swift.
2 parents 1114f1b + 0c1d8a6 commit 0fead56

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,19 @@ function(add_swift_host_library name)
519519
target_link_options(${name} PRIVATE
520520
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
521521
endif()
522+
523+
# For now turn off in swift targets, debug info if we are compiling a static
524+
# library.
525+
if (ASHL_STATIC)
526+
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-gnone>)
527+
endif()
522528
endif()
523529
530+
# If we are compiling in release or release with deb info, compile swift code
531+
# with -cross-module-optimization enabled.
532+
target_compile_options(${name} PRIVATE
533+
$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-cross-module-optimization>)
534+
524535
add_dependencies(dev ${name})
525536
if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
526537
swift_install_in_component(TARGETS ${name}
@@ -566,6 +577,9 @@ function(add_swift_host_tool executable)
566577
_add_host_variant_c_compile_link_flags(${executable})
567578
target_link_directories(${executable} PRIVATE
568579
${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
580+
# Force executables linker language to be CXX so that we do not link using the
581+
# host toolchain swiftc.
582+
set_target_properties(${executable} PROPERTIES LINKER_LANGUAGE CXX)
569583
add_dependencies(${executable} ${LLVM_COMMON_DEPENDS})
570584
571585
set_target_properties(${executable} PROPERTIES

0 commit comments

Comments
 (0)