Skip to content

[5.7][cmake] Prevent test failures by disabling LTO for swift runtime #59631

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
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
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
29 changes: 28 additions & 1 deletion stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,12 @@ function(add_swift_target_library name)
BACK_DEPLOYMENT_LIBRARY)
set(SWIFTLIB_multiple_parameter_options
C_COMPILE_FLAGS
C_COMPILE_FLAGS_IOS
C_COMPILE_FLAGS_OSX
C_COMPILE_FLAGS_TVOS
C_COMPILE_FLAGS_WATCHOS
C_COMPILE_FLAGS_LINUX
C_COMPILE_FLAGS_WINDOWS
DEPENDS
FILE_DEPENDS
FRAMEWORK_DEPENDS
Expand Down Expand Up @@ -1867,7 +1873,7 @@ function(add_swift_target_library name)
${SWIFTLIB_FRAMEWORK_DEPENDS_IOS_TVOS})
endif()

# Collect architecutre agnostic compiler flags
# Collect architecture agnostic swift compiler flags
set(swiftlib_swift_compile_flags_all ${SWIFTLIB_SWIFT_COMPILE_FLAGS})
if(${sdk} STREQUAL OSX)
list(APPEND swiftlib_swift_compile_flags_all
Expand Down Expand Up @@ -2023,6 +2029,27 @@ function(add_swift_target_library name)
set(swiftlib_c_compile_flags_all ${SWIFTLIB_C_COMPILE_FLAGS})
set(swiftlib_link_flags_all ${SWIFTLIB_LINK_FLAGS})

# Collect architecture agnostic c compiler flags
if(${sdk} STREQUAL OSX)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_OSX})
elseif(${sdk} STREQUAL IOS OR ${sdk} STREQUAL IOS_SIMULATOR)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_IOS})
elseif(${sdk} STREQUAL TVOS OR ${sdk} STREQUAL TVOS_SIMULATOR)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_TVOS})
elseif(${sdk} STREQUAL WATCHOS OR ${sdk} STREQUAL WATCHOS_SIMULATOR)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_WATCHOS})
elseif(${sdk} STREQUAL LINUX)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_LINUX})
elseif(${sdk} STREQUAL WINDOWS)
list(APPEND swiftlib_c_compile_flags_all
${SWIFTLIB_C_COMPILE_FLAGS_WINDOWS})
endif()

# Add flags to prepend framework search paths for the parallel framework
# hierarchy rooted at /System/iOSSupport/...
# These paths must come before their normal counterparts so that when compiling
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,14 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)
list(APPEND swift_demangling_cflags -DSWIFT_STDLIB_HAS_TYPE_PRINTING)
endif()

# Gold LTO is unsupported. To prevent tests from failing when building
# with LTO, force swiftDemangling library to compile without LTO for Linux.
add_swift_target_library(swiftDemangling OBJECT_LIBRARY
${swiftDemanglingSources}
C_COMPILE_FLAGS
-DswiftCore_EXPORTS
${swift_demangling_cflags}
C_COMPILE_FLAGS_LINUX -fno-lto
INSTALL_IN_COMPONENT never_install)

add_swift_target_library(swiftDemanglingCR OBJECT_LIBRARY
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ foreach(sdk ${SWIFT_SDKS})
endforeach()


# Gold LTO is unsupported. To prevent tests from failing when building
# with LTO, force swift runtime to compile without LTO for Linux.
add_swift_target_library(swiftImageRegistrationObjectELF
OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE
SwiftRT-ELF.cpp
C_COMPILE_FLAGS ${SWIFT_RUNTIME_CORE_CXX_FLAGS}
C_COMPILE_FLAGS_LINUX -fno-lto
LINK_FLAGS ${SWIFT_RUNTIME_CORE_LINK_FLAGS}
TARGET_SDKS ${ELFISH_SDKS}
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
Expand Down