Skip to content

Commit 6b3ecfb

Browse files
committed
[CMake] adjust clang resource dir symlinks to new path
As a result of llvm/llvm-project@e1b88c8a09be we should expect it to contain only the major version, not the full one -- that is, we should expect it to be ``` ../lib/clang/CLANG_VERSION_MAJOR ``` instead of ``` ../lib/clang/CLANG_VERSION_MAJOR.CLANG_VERSION_MINOR.CLANG_VERSION_PATCH ``` Also update the logic to levarage directly the Clang version -- this can be different from the LLVM one (as per llvm/llvm-project@ebfc680) Addresses rdar://111452821
1 parent 62a0475 commit 6b3ecfb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

stdlib/public/SwiftShims/swift/shims/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ add_custom_target("copy_shim_headers" ALL
7070
DEPENDS "${outputs}"
7171
COMMENT "Copying SwiftShims module to ${output_dir}")
7272

73-
if ("${LLVM_PACKAGE_VERSION}" STREQUAL "")
73+
if (NOT CLANG_VERSION_MAJOR)
7474
message(FATAL_ERROR
75-
"LLVM_PACKAGE_VERSION must be set before including subdirectories")
75+
"CLANG_VERSION_MAJOR must be set in order to infer the path to clang headers")
7676
endif()
7777

78-
# Symlink in the Clang headers.
79-
# First extract the "version" used for Clang's resource directory.
80-
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
81-
"${LLVM_PACKAGE_VERSION}")
78+
# Symlink in the Clang headers from either the provided clang...
8279
if(NOT SWIFT_INCLUDE_TOOLS AND
8380
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
8481
if(SWIFT_COMPILER_IS_MSVC_LIKE)
@@ -94,7 +91,8 @@ if(NOT SWIFT_INCLUDE_TOOLS AND
9491
endif()
9592
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
9693
else()
97-
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
94+
# ... or the one we just built
95+
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}")
9896
endif()
9997

10098
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
@@ -205,7 +203,7 @@ if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG)
205203
# toolchain was built with SWIFT_INCLUDE_TOOLS.
206204
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default ${clang_headers_location})
207205
else()
208-
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION}")
206+
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION_MAJOR}")
209207
endif()
210208

211209
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET

0 commit comments

Comments
 (0)