Skip to content

Commit bec67c7

Browse files
committed
Runtimes: ensure that we strongly resolve all symbols on Linux
Ensure that there are no undefined symbols at link time to validate that we fully specified dependencies. This is the default behaviour on Windows, but ELF targets will simply make any undefined symbols weakly defined and rely on load time symbolic resolution.
1 parent 66dc1cc commit bec67c7

File tree

8 files changed

+16
-0
lines changed

8 files changed

+16
-0
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ add_compile_options(
182182
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
183183
# a compromise, treat all linker warnings as errors.
184184
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
185+
# Ensure all symbols are fully resolved on Linux
186+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
185187

186188
add_compile_options(
187189
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>

Runtimes/Overlay/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ include(ExperimentalFeatures)
9494
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
9595
# a compromise, treat all linker warnings as errors.
9696
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
97+
# Ensure all symbols are fully resolved on Linux
98+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
9799

98100
include(ExperimentalFeatures)
99101

Runtimes/Supplemental/Differentiation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ add_compile_options(
8888
# FIXME(#83444) - enable this once we fix DLL storage for
8989
# `_fatalErrorForwardModeDifferentiationDisabled`
9090
# add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
91+
# Ensure all symbols are fully resolved on Linux
92+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
9193

9294
if(SwiftDifferentiation_ENABLE_VECTOR_TYPES)
9395
gyb_expand(SIMDDifferentiation.swift.gyb SIMDDifferentiation.swift)

Runtimes/Supplemental/Distributed/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ add_compile_options(
9898
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
9999
# a compromise, treat all linker warnings as errors.
100100
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
101+
# Ensure all symbols are fully resolved on Linux
102+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
101103

102104
add_library(swiftDistributed
103105
DistributedActor.cpp

Runtimes/Supplemental/Observation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ add_compile_options(
8383
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
8484
# a compromise, treat all linker warnings as errors.
8585
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
86+
# Ensure all symbols are fully resolved on Linux
87+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
8688

8789
add_library(swiftObservation
8890
Sources/Observation/Locking.swift

Runtimes/Supplemental/StringProcessing/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ add_compile_options(
6565
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
6666
# a compromise, treat all linker warnings as errors.
6767
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
68+
# Ensure all symbols are fully resolved on Linux
69+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
6870

6971
add_subdirectory(_RegexParser)
7072
add_subdirectory(_StringProcessing)

Runtimes/Supplemental/Synchronization/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ add_compile_options(
101101
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
102102
# a compromise, treat all linker warnings as errors.
103103
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
104+
# Ensure all symbols are fully resolved on Linux
105+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
104106

105107
gyb_expand(Atomics/AtomicIntegers.swift.gyb Atomics/AtomicIntegers.swift)
106108
gyb_expand(Atomics/AtomicStorage.swift.gyb Atomics/AtomicStorage.swift)

Runtimes/Supplemental/Volatile/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ add_compile_options(
7777
# frontend and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
7878
# a compromise, treat all linker warnings as errors.
7979
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
80+
# Ensure all symbols are fully resolved on Linux
81+
add_link_options($<$<PLATFORM_ID:Linux>:LINKER:-z,defs>)
8082

8183
add_library(swift_Volatile
8284
Volatile.swift)

0 commit comments

Comments
 (0)