Skip to content

Commit 367b4c1

Browse files
authored
Enable -experimental-hermetic-seal-at-link for the stdlib on 'freestanding' (#39961)
1 parent de0aaec commit 367b4c1

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

stdlib/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ option(SWIFT_FREESTANDING_FLAVOR
143143
"When building the FREESTANDING stdlib, which build style to use (options: apple, linux)")
144144

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

149+
option(SWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK
150+
"Should stdlib be built with -experimental-hermetic-seal-at-link"
151+
FALSE)
152+
149153
set(SWIFT_STDLIB_ENABLE_LTO OFF CACHE STRING "Build Swift stdlib with LTO. One
150154
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
151155
option only affects the standard library and runtime, not tools.")

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ function(_compile_swift_files
502502
list(APPEND swift_flags "-Xfrontend" "-disable-objc-interop")
503503
endif()
504504

505+
if(SWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK)
506+
list(APPEND swift_flags "-experimental-hermetic-seal-at-link")
507+
endif()
508+
505509
list(APPEND swift_flags ${SWIFT_EXPERIMENTAL_EXTRA_FLAGS})
506510

507511
if(SWIFTFILE_OPT_FLAGS)

test/lit.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,8 @@ if run_vendor == 'apple':
950950
# it's a very desired behavior, let's enable it for all executable tests.
951951
swift_execution_tests_extra_flags += ' -Xlinker -dead_strip'
952952

953+
swift_execution_tests_extra_flags += ' -experimental-hermetic-seal-at-link -lto=llvm-full'
954+
953955
# Build a resource dir for freestanding tests.
954956
new_resource_dir = os.path.join(config.test_exec_root, "resource_dir")
955957
if not os.path.exists(new_resource_dir): os.mkdir(new_resource_dir)

test/stdlib/KeyPathMultiModule.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
// REQUIRES: executable_test
1717

18+
// Freestanding stdlib is built with -experimental-hermetic-seal-at-link which doesn't allow -enable-library-evolution
19+
// UNSUPPORTED: freestanding
20+
1821
import KeyPathMultiModule_b
1922
import StdlibUnittest
2023

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,7 @@ extra-cmake-options=
24932493
-DSWIFT_STDLIB_ENABLE_PRESPECIALIZATION:BOOL=FALSE
24942494
-DSWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR:BOOL=TRUE
24952495
-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS:BOOL=FALSE
2496+
-DSWIFT_STDLIB_EXPERIMENTAL_HERMETIC_SEAL_AT_LINK:BOOL=TRUE
24962497

24972498
[preset: stdlib_S_standalone_minimal_macho_x86_64,build]
24982499
mixin-preset=

0 commit comments

Comments
 (0)