Skip to content

Commit c6c88ce

Browse files
authored
[cmake] Allow overriding Clang resource symlink target (#41301)
When building with a prebuilt Clang, the changes introduced in #40707 supposed that the toolchain was in its final path. When building in stages (first the toolchain, then the standard library), the toolchain might not be in the final path, and the created symlink will point to a machine-local path that does not make sense. The changes introduced should not modify the existing behaviour introduced by #40707, but should allow customizing the final installation target using the CMake cached variable for those setups that need the flexibility.
1 parent b20f015 commit c6c88ce

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,23 @@ endif()
203203
if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG)
204204
# This will still link against the Swift-forked clang headers if the Swift
205205
# toolchain was built with SWIFT_INCLUDE_TOOLS.
206-
set(symlink_dir ${clang_headers_location})
206+
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default ${clang_headers_location})
207207
else()
208-
set(symlink_dir "../clang/${CLANG_VERSION}")
208+
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION}")
209209
endif()
210210

211+
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET
212+
${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default} CACHE STRING "The target of the installed symlink at lib/swift/clang")
213+
211214
swift_install_symlink_component(clang-resource-dir-symlink
212215
LINK_NAME clang
213-
TARGET ${symlink_dir}
216+
TARGET ${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET}
214217
DESTINATION "lib/swift")
215218

216219
if(SWIFT_BUILD_STATIC_STDLIB)
217220
swift_install_symlink_component(clang-resource-dir-symlink
218221
LINK_NAME clang
219-
TARGET ${symlink_dir}
222+
TARGET ${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET}
220223
DESTINATION "lib/swift_static")
221224
endif()
222225

0 commit comments

Comments
 (0)