Skip to content

[cxx-interop][SwiftCompilerSources] Include Clang headers #60967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions SwiftCompilerSources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ function(add_swift_compiler_modules_library name)
if (add_to_syntaxparse)
set(syntaxparse_obj_files ${syntaxparse_obj_files} ${module_obj_file})
endif()
set(c_include_paths
# LLVM modules and headers.
"${LLVM_MAIN_INCLUDE_DIR}"
# Generated LLVM headers.
"${LLVM_INCLUDE_DIR}"
# Clang modules and headers.
${CLANG_INCLUDE_DIRS}
# Bridging modules and headers.
"${SWIFT_MAIN_INCLUDE_DIR}"
# Generated C headers.
"${CMAKE_CURRENT_BINARY_DIR}/../include")
set(c_include_paths_args)
foreach(c_include_path ${c_include_paths})
list(APPEND c_include_paths_args "-Xcc" "-I" "-Xcc" "${c_include_path}")
endforeach()

# Compile the module into an object file
add_custom_command_target(dep_target OUTPUT ${module_obj_file}
Expand All @@ -173,14 +188,7 @@ function(add_swift_compiler_modules_library name)
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
"-parse-as-library" ${sources}
"-wmo" ${swift_compile_options}
# LLVM modules and headers.
"-Xcc" "-I" "-Xcc" "${LLVM_MAIN_INCLUDE_DIR}"
# Generated LLVM headers.
"-Xcc" "-I" "-Xcc" "${LLVM_INCLUDE_DIR}"
# Bridging modules and headers.
"-Xcc" "-I" "-Xcc" "${SWIFT_SOURCE_DIR}/include"
# Generated C headers.
"-Xcc" "-I" "-Xcc" "${CMAKE_CURRENT_BINARY_DIR}/../include"
${c_include_paths_args}
# Generated swift modules.
"-I" "${build_dir}"
COMMENT "Building swift module ${module}")
Expand Down
2 changes: 2 additions & 0 deletions SwiftCompilerSources/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ private extension Target {
"-Xcc", "-I", "-Xcc", "../include",
// LLVM modules and headers
"-Xcc", "-I", "-Xcc", "../../llvm-project/llvm/include",
// Clang modules and headers
"-Xcc", "-I", "-Xcc", "../../llvm-project/clang/include",
"-cross-module-optimization"
]),
]
Expand Down