Skip to content

Commit

Permalink
[CMake] Add option to specify '-module-abi-name'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rintaro committed Oct 14, 2023
1 parent 71afbc1 commit 093b895
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if(CMAKE_VERSION VERSION_LESS 3.21)
endif()
endif()

set(SWIFT_MODULE_ABI_NAME_PREFIX CACHE STRING "ABI name prefix to avoid name conflicts")

# The subdirectory into which host libraries will be installed.
set(SWIFT_HOST_LIBRARIES_SUBDIRECTORY "swift/host")

Expand Down
7 changes: 7 additions & 0 deletions cmake/modules/AddSwiftHostLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ function(add_swift_syntax_library name)
-emit-module-path;${module_file};
-emit-module-source-info-path;${module_sourceinfo_file};
-emit-module-interface-path;${module_interface_file}
>)
if(SWIFT_MODULE_ABI_NAME_PREFIX)
target_compile_options("${name}" PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:
"SHELL:-Xfrontend -module-abi-name"
"SHELL:-Xfrontend ${SWIFT_MODULE_ABI_NAME_PREFIX}${name}"
>)
endif()

if(CMAKE_VERSION VERSION_LESS 3.26.0 AND SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26)
target_compile_options(${name} PRIVATE
Expand Down

0 comments on commit 093b895

Please sign in to comment.