Skip to content

Commit 093b895

Browse files
committed
[CMake] Add option to specify '-module-abi-name'
Add 'SWIFT_MODULE_ABI_NAME_PREFIX' CMake variable. This can be used from compiler's CMake so its swift-syntax libraries can have unique names. That avoids symbol name conflicts when compiler libraries (e.g. sourcekitdInProc) is used from binaries linking with swift-syntax (e.g. via SwiftPM) swiftlang/swift#68812 rdar://116951101
1 parent 71afbc1 commit 093b895

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if(CMAKE_VERSION VERSION_LESS 3.21)
2222
endif()
2323
endif()
2424

25+
set(SWIFT_MODULE_ABI_NAME_PREFIX CACHE STRING "ABI name prefix to avoid name conflicts")
26+
2527
# The subdirectory into which host libraries will be installed.
2628
set(SWIFT_HOST_LIBRARIES_SUBDIRECTORY "swift/host")
2729

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ function(add_swift_syntax_library name)
7777
-emit-module-path;${module_file};
7878
-emit-module-source-info-path;${module_sourceinfo_file};
7979
-emit-module-interface-path;${module_interface_file}
80+
>)
81+
if(SWIFT_MODULE_ABI_NAME_PREFIX)
82+
target_compile_options("${name}" PRIVATE
83+
$<$<COMPILE_LANGUAGE:Swift>:
84+
"SHELL:-Xfrontend -module-abi-name"
85+
"SHELL:-Xfrontend ${SWIFT_MODULE_ABI_NAME_PREFIX}${name}"
8086
>)
87+
endif()
8188

8289
if(CMAKE_VERSION VERSION_LESS 3.26.0 AND SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26)
8390
target_compile_options(${name} PRIVATE

0 commit comments

Comments
 (0)