Skip to content

Commit d6bcfd9

Browse files
committed
[CMake] Fix issues when running build-tooling-libs
There were three different issues going on here, all of these were triggered by #61618 which stared including `AST/AnyFunctionRef.h` from the ASTBridging modulemap - We did not find the clang include dirs because the unified build that build-tooling-libs is using does not import ClangConfig, setting `CLANG_INCLUDE_DIRS` in `swift_common_unified_build_config` fixed this problem. - Some of the headers in `swift-ast-generated-headers` import generated headers from clang that might not have been created yet. Making `swift-ast-generated-headers` depend on the clang generated headers fixes this problem. This just lowers the dependency because `swiftAST` depends on `swift-ast-generated-headers` - If a Swift compiler from Xcode is used, the SwiftShims don’t live next to the compiler but in the SDK. Adding the SDKs lib to the include paths fixes this problem
1 parent 9dfb6ea commit d6bcfd9

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ function(add_swift_compiler_modules_library name)
127127
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
128128

129129
# Let Swift discover SwiftShims headers which are included by some headers
130-
# under `include/swift`.
130+
# under `include/swift`. These are either located next to the compiler (in case of open source toolchains) or
131+
# in the SDK (in case a Swift compiler from Xcode)
131132
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
132-
set(sdk_option ${sdk_option} "-I" "${swift_exec_bin_dir}/../lib")
133+
set(sdk_option ${sdk_option} "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
133134

134135
set(all_obj_files)
135136
set(all_module_targets)

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ macro(swift_common_unified_build_config product)
274274
set(${product}_NATIVE_CLANG_TOOLS_PATH "${CMAKE_BINARY_DIR}/bin")
275275
set(LLVM_PACKAGE_VERSION ${PACKAGE_VERSION})
276276
set(LLVM_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")
277+
set(CLANG_INCLUDE_DIRS
278+
"${CLANG_MAIN_INCLUDE_DIR}"
279+
"${CLANG_BUILD_INCLUDE_DIR}"
280+
)
277281

278282
# If cmark was checked out into tools/cmark, expect to build it as
279283
# part of the unified build.

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ endif()
179179
# where intrinsics and attributes are declared. swiftAST depends on these
180180
# headers.
181181
# For more information see the comment at the top of lib/CMakeLists.txt.
182-
add_dependencies(swiftAST intrinsics_gen clang-tablegen-targets)
182+
add_dependencies(swift-ast-generated-headers intrinsics_gen clang-tablegen-targets)
183183
add_dependencies(swiftAST swift-ast-generated-headers)
184184

185185
set_swift_llvm_is_available(swiftAST)

0 commit comments

Comments
 (0)