From 3ede5a03dfdc6da370fd7755dd904c9cf09ea108 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Sat, 14 Oct 2023 06:17:40 +0000 Subject: [PATCH] [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) https://github.com/apple/swift/issues/68812 rdar://116951101 (cherry picked from commit 093b895952c96533bfda5a32ca28404ad09bcd25) (cherry picked from commit d8c86952281b50012766e0bcbf201c2ad16278ed) --- cmake/modules/AddSwiftHostLibrary.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/modules/AddSwiftHostLibrary.cmake b/cmake/modules/AddSwiftHostLibrary.cmake index cd13e47df88..73b69ad1bb2 100644 --- a/cmake/modules/AddSwiftHostLibrary.cmake +++ b/cmake/modules/AddSwiftHostLibrary.cmake @@ -54,7 +54,15 @@ function(add_swift_host_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) + # ABI name prefix. this can be used to avoid name conflicts. + target_compile_options("${name}" PRIVATE + $<$: + "SHELL:-Xfrontend -module-abi-name" + "SHELL:-Xfrontend ${SWIFT_MODULE_ABI_NAME_PREFIX}${name}" >) + endif() # NOTE: workaround for CMake not setting up include flags yet set_target_properties(${name} PROPERTIES