Skip to content

[CMake] Don't pass -embed-bitcode to module generation commands. #6113

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
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
6 changes: 4 additions & 2 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,12 @@ function(_add_swift_library_single target name)
"${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}/${SWIFTLIB_SINGLE_ARCHITECTURE}")

# Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_DONT_EMBED_BITCODE)
set(embed_bitcode_arg)
if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "TVOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "WATCHOS")
list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS "-fembed-bitcode")
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-embed-bitcode")
list(APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-bitcode_bundle" "-Xlinker" "-bitcode_hide_symbols" "-Xlinker" "-lto_library" "-Xlinker" "${LLVM_LIBRARY_DIR}/libLTO.dylib")
set(embed_bitcode_arg EMBED_BITCODE)
endif()
endif()

Expand Down Expand Up @@ -722,6 +723,7 @@ function(_add_swift_library_single target name)
${SWIFTLIB_SINGLE_IS_STDLIB_keyword}
${SWIFTLIB_SINGLE_IS_STDLIB_CORE_keyword}
${SWIFTLIB_SINGLE_IS_SDK_OVERLAY_keyword}
${embed_bitcode_arg}
INSTALL_IN_COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}")
add_swift_source_group("${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}")

Expand Down
15 changes: 12 additions & 3 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(handle_swift_sources
dependency_module_target_out_var_name
sourcesvar externalvar name)
cmake_parse_arguments(SWIFTSOURCES
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY"
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE"
"SDK;ARCHITECTURE;INSTALL_IN_COMPONENT"
"DEPENDS;API_NOTES;COMPILE_FLAGS;MODULE_NAME"
${ARGN})
Expand All @@ -20,6 +20,8 @@ function(handle_swift_sources
IS_STDLIB_CORE_arg)
translate_flag(${SWIFTSOURCES_IS_SDK_OVERLAY} "IS_SDK_OVERLAY"
IS_SDK_OVERLAY_arg)
translate_flag(${SWIFTSOURCES_EMBED_BITCODE} "EMBED_BITCODE"
EMBED_BITCODE_arg)

if(SWIFTSOURCES_IS_MAIN)
set(SWIFTSOURCES_INSTALL_IN_COMPONENT never_install)
Expand Down Expand Up @@ -94,6 +96,7 @@ function(handle_swift_sources
${IS_STDLIB_arg}
${IS_STDLIB_CORE_arg}
${IS_SDK_OVERLAY_arg}
${EMBED_BITCODE_arg}
${STATIC_arg}
INSTALL_IN_COMPONENT "${SWIFTSOURCES_INSTALL_IN_COMPONENT}")
set("${dependency_target_out_var_name}" "${dependency_target}" PARENT_SCOPE)
Expand Down Expand Up @@ -138,11 +141,12 @@ endfunction()
# [MODULE_NAME] # The module name.
# [IS_STDLIB] # Install produced files.
# [EMIT_SIB] # Emit the file as a sib file instead of a .o
# [EMBED_BITCODE] # Embed LLVM bitcode into the .o files
# )
function(_compile_swift_files
dependency_target_out_var_name dependency_module_target_out_var_name)
cmake_parse_arguments(SWIFTFILE
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMIT_SIB"
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMIT_SIB;EMBED_BITCODE"
"OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT"
"SOURCES;FLAGS;DEPENDS;SDK;ARCHITECTURE;API_NOTES;OPT_FLAGS;MODULE_DIR"
${ARGN})
Expand Down Expand Up @@ -362,6 +366,11 @@ function(_compile_swift_files
set(output_option "-o" ${first_output})
endif()

set(embed_bitcode_option)
if (SWIFTFILE_EMBED_BITCODE)
set(embed_bitcode_option "-embed-bitcode")
endif()

set(main_command "-c")
if (SWIFTFILE_EMIT_SIB)
# Change the command to emit-sib if we are asked to emit sib
Expand Down Expand Up @@ -429,7 +438,7 @@ function(_compile_swift_files
COMMAND
"${line_directive_tool}" "${source_files}" --
"${swift_compiler_tool}" "${main_command}" ${swift_flags}
${output_option} "${source_files}"
${output_option} ${embed_bitcode_option} "${source_files}"
${command_touch_standard_outputs}
OUTPUT ${standard_outputs}
DEPENDS
Expand Down