Skip to content

Enable -experimental-hermetic-seal-at-link for the stdlib on 'freestanding' #39961

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
Nov 2, 2021
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: 5 additions & 1 deletion stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ option(SWIFT_FREESTANDING_FLAVOR
"When building the FREESTANDING stdlib, which build style to use (options: apple, linux)")

option(SWIFT_STDLIB_ENABLE_PRESPECIALIZATION
"Should stdlib be built with generic metadata prespecialization enabled. Defaults to On on Darwin and on "
"Should stdlib be built with generic metadata prespecialization enabled. Defaults to On on Darwin and on Linux."
"${SWIFT_STDLIB_ENABLE_PRESPECIALIZATION_default}")

option(SWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK
"Should stdlib be built with -experimental-hermetic-seal-at-link"
FALSE)

set(SWIFT_STDLIB_ENABLE_LTO OFF CACHE STRING "Build Swift stdlib with LTO. One
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
option only affects the standard library and runtime, not tools.")
Expand Down
4 changes: 4 additions & 0 deletions stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ function(_compile_swift_files
list(APPEND swift_flags "-Xfrontend" "-disable-objc-interop")
endif()

if(SWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK)
list(APPEND swift_flags "-experimental-hermetic-seal-at-link")
endif()

list(APPEND swift_flags ${SWIFT_EXPERIMENTAL_EXTRA_FLAGS})

if(SWIFTFILE_OPT_FLAGS)
Expand Down
2 changes: 2 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ if run_vendor == 'apple':
# it's a very desired behavior, let's enable it for all executable tests.
swift_execution_tests_extra_flags += ' -Xlinker -dead_strip'

swift_execution_tests_extra_flags += ' -experimental-hermetic-seal-at-link -lto=llvm-full'

# Build a resource dir for freestanding tests.
new_resource_dir = os.path.join(config.test_exec_root, "resource_dir")
if not os.path.exists(new_resource_dir): os.mkdir(new_resource_dir)
Expand Down
3 changes: 3 additions & 0 deletions test/stdlib/KeyPathMultiModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

// REQUIRES: executable_test

// Freestanding stdlib is built with -experimental-hermetic-seal-at-link which doesn't allow -enable-library-evolution
// UNSUPPORTED: freestanding

import KeyPathMultiModule_b
import StdlibUnittest

Expand Down
1 change: 1 addition & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,7 @@ extra-cmake-options=
-DSWIFT_STDLIB_ENABLE_PRESPECIALIZATION:BOOL=FALSE
-DSWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR:BOOL=TRUE
-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS:BOOL=FALSE
-DSWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK:BOOL=TRUE

[preset: stdlib_S_standalone_minimal_macho_x86_64,build]
mixin-preset=
Expand Down