mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ClangImporter] Drop the version from Clang's resource directory.
Background: Clang has a set of base headers distributed with the compiler that contain things like vector operations, stddef.h, and tgmath.h. Swift also needs these headers in order to import C and Objective-C (not really a surprise), so we symlink to them from lib/swift/clang/. When we build installable packages, we actually copy them in. Now the tricky part. Clang's headers are actually at a path like "include/clang/3.6.0/include/tgmath.h". That "3.6.0" is the Clang version, which allows multiple Clangs to be installed on a single system. Swift currently links to the top-level directory, but of course it's only guaranteed to work with a specific version of the Clang headers. So the version number here is always the version of Clang we use to build Swift. Rather than leave the (relatively meaningless) version number here, just make the symlink point at the "3.6.0" directory rather than the "clang" directory. This means Swift doesn't have to think about the version number here at all. rdar://problem/23223066
This commit is contained in:
@@ -486,7 +486,7 @@ addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,
|
||||
// assuming that the Clang resource directory is located next to it is that
|
||||
// Swift, when installed separately, should not need to install files in
|
||||
// directories that are not "owned" by it.
|
||||
llvm::sys::path::append(resourceDir, "clang", CLANG_VERSION_STRING);
|
||||
llvm::sys::path::append(resourceDir, "clang");
|
||||
|
||||
// Set the Clang resource directory to the path we computed.
|
||||
invocationArgStrs.push_back("-resource-dir");
|
||||
|
||||
@@ -36,17 +36,21 @@ add_custom_command_target(unused_var
|
||||
COMMENT "Copying SwiftShims module to ${output_dir}")
|
||||
|
||||
# Symlink in the Clang headers.
|
||||
# First extract the "version" used for Clang's resource directory.
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
||||
${LLVM_PACKAGE_VERSION})
|
||||
set(clang_headers_locations
|
||||
"${LLVM_LIBRARY_DIR}/clang"
|
||||
"${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}"
|
||||
|
||||
# FIXME: if we want to support separate Clang builds and mix different
|
||||
# build configurations of Clang and Swift, this line should be adjusted.
|
||||
"${SWIFT_PATH_TO_CLANG_BUILD}/${CMAKE_CFG_INTDIR}/lib/clang")
|
||||
"${SWIFT_PATH_TO_CLANG_BUILD}/${CMAKE_CFG_INTDIR}/lib/clang/${CLANG_VERSION}")
|
||||
|
||||
set(clang_headers_location)
|
||||
foreach(loc ${clang_headers_locations})
|
||||
if("${clang_headers_location}" STREQUAL "" AND EXISTS "${loc}")
|
||||
if(EXISTS "${loc}")
|
||||
set(clang_headers_location "${loc}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if("${clang_headers_location}" STREQUAL "")
|
||||
|
||||
Reference in New Issue
Block a user