Skip to content

Commit 99fb4e1

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 99fb4e1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ 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 "")
74-
message(FATAL_ERROR
75-
"LLVM_PACKAGE_VERSION must be set before including subdirectories")
73+
if (NOT CLANG_VERSION_MAJOR)
74+
if (NOT LLVM_VERSION_MAJOR)
75+
message(FATAL_ERROR
76+
"CLANG_VERSION_MAJOR or LLVM_VERSION_MAJOR must be set
77+
in order to infer the path to clang headers")
78+
else()
79+
message(WARNING
80+
"CLANG_VERSION_MAJOR is not defined, falling back to
81+
LLVM_VERSION_MAJOR to inder the path to clang headers")
82+
set(CLANG_VERSION_MAJOR "${LLVM_VERSION_MAJOR}")
83+
endif()
7684
endif()
7785

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}")
86+
# Symlink in the Clang headers from either the provided clang...
8287
if(NOT SWIFT_INCLUDE_TOOLS AND
8388
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
8489
if(SWIFT_COMPILER_IS_MSVC_LIKE)
@@ -94,7 +99,8 @@ if(NOT SWIFT_INCLUDE_TOOLS AND
9499
endif()
95100
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
96101
else()
97-
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
102+
# ... or the one we just built
103+
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}")
98104
endif()
99105

100106
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
@@ -205,7 +211,7 @@ if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG)
205211
# toolchain was built with SWIFT_INCLUDE_TOOLS.
206212
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default ${clang_headers_location})
207213
else()
208-
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION}")
214+
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION_MAJOR}")
209215
endif()
210216

211217
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET

0 commit comments

Comments
 (0)