Skip to content

Commit 83a9913

Browse files
authored
[test] Propagate CMake shared linker flags for tests to use (#85623)
The same that some setups needs the `CMAKE_EXE_LINKER_FLAGS` propagated for the test to compile plugins in the same configuration as the compiler was using, the `CMAKE_SHARED_LINKER_FLAGS` needs to be propagated if one wants to match the configuration used by CMake to create libraries during the tests. Add a new `config` value derived from `CMAKE_EXE_LINKER_FLAGS`, turn that value into a substitution for the `Macros` tests, and use the substibution in one test that creates a shared object. This allows the shared object to be linked in the same way that it has been configured in CMake.
1 parent 51d2f2b commit 83a9913

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

test/Macros/lit.local.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ else:
3131
)
3232
config.substitutions.append(('%c-flags', config.c_flags))
3333
config.substitutions.append(('%exe-linker-flags', config.exe_linker_flags))
34+
config.substitutions.append(('%shared-linker-flags', config.shared_linker_flags))

test/Macros/macro_plugin_server_mod.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
// RUN: %cmake-c-compiler \
2626
// RUN: %c-flags -target %host_triple -isysroot %host_sdk \
27+
// RUN: %shared-linker-flags \
2728
// RUN: -shared -o %t/plugins/libCrashOnLoad.dylib \
2829
// RUN: %t/CrashOnLoad.c
2930

test/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ config.cmake_c_compiler = r'''@CMAKE_C_COMPILER@'''
5252
config.cmake_cxx_compiler = r'''@CMAKE_CXX_COMPILER@'''
5353
config.c_flags = r'''@CMAKE_C_FLAGS@'''
5454
config.exe_linker_flags = r'''@CMAKE_EXE_LINKER_FLAGS@'''
55+
config.shared_linker_flags = r'''@CMAKE_SHARED_LINKER_FLAGS@'''
5556

5657
# --- Darwin ---
5758
config.darwin_xcrun_toolchain = "@SWIFT_DARWIN_XCRUN_TOOLCHAIN@"

0 commit comments

Comments
 (0)