Skip to content

Commit da05f0e

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 (cherry picked from commit 093b895)
1 parent d3fe9e7 commit da05f0e

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
@@ -15,6 +15,8 @@ project(SwiftSyntax LANGUAGES C Swift)
1515
set(SWIFT_VERSION 5)
1616
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION})
1717

18+
set(SWIFT_MODULE_ABI_NAME_PREFIX CACHE STRING "ABI name prefix to avoid name conflicts")
19+
1820
# The subdirectory into which host libraries will be installed.
1921
set(SWIFT_HOST_LIBRARIES_SUBDIRECTORY "swift/host")
2022

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ function(add_swift_host_library name)
5454
-emit-module-path;${module_file};
5555
-emit-module-source-info-path;${module_sourceinfo_file};
5656
-emit-module-interface-path;${module_interface_file}
57+
>)
58+
if(SWIFT_MODULE_ABI_NAME_PREFIX)
59+
target_compile_options("${name}" PRIVATE
60+
$<$<COMPILE_LANGUAGE:Swift>:
61+
"SHELL:-Xfrontend -module-abi-name"
62+
"SHELL:-Xfrontend ${SWIFT_MODULE_ABI_NAME_PREFIX}${name}"
5763
>)
64+
endif()
5865

5966
# NOTE: workaround for CMake not setting up include flags yet
6067
set_target_properties(${name} PROPERTIES

0 commit comments

Comments
 (0)