Skip to content

Commit 6c7edd3

Browse files
committed
clean up Include dir handling
1 parent c8e6833 commit 6c7edd3

File tree

1 file changed

+15
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+15
-5
lines changed

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,17 @@ fn configure_cmake(
768768
.collect::<Vec<String>>()
769769
.join(" ")
770770
.into();
771+
772+
// If we use an external clang as opposed to building our own llvm_clang, than that clang will
773+
// come with it's own set of default include directories, which are based on a potentially older
774+
// LLVM. This can cause issues, so we overwrite it to include headers based on our
775+
// `src/llvm-project` submodule instead.
776+
// FIXME(offload): With LLVM-22 we hopefully won't need an external clang anymore.
777+
let base = builder.llvm_out(target).join("include");
778+
let inc_dir = base.display();
779+
if builder.config.llvm_offload && !builder.config.llvm_clang {
780+
cflags.push(format!(" -I {inc_dir}"));
781+
}
771782
if let Some(ref s) = builder.config.llvm_cflags {
772783
cflags.push(" ");
773784
cflags.push(s);
@@ -778,11 +789,8 @@ fn configure_cmake(
778789
if builder.config.llvm_clang_cl.is_some() {
779790
cflags.push(format!(" --target={target}"));
780791
}
781-
// Manuel
782-
let base = builder.llvm_out(target).join("include");
783-
let inc_dir = base.display();
784-
cflags.push(format!(" -I {inc_dir}"));
785792
cfg.define("CMAKE_C_FLAGS", cflags);
793+
786794
let mut cxxflags: OsString = builder
787795
.cc_handled_clags(target, CLang::Cxx)
788796
.into_iter()
@@ -795,7 +803,9 @@ fn configure_cmake(
795803
.collect::<Vec<String>>()
796804
.join(" ")
797805
.into();
798-
cxxflags.push(format!(" -I {inc_dir}"));
806+
if builder.config.llvm_offload && !builder.config.llvm_clang {
807+
cxxflags.push(format!(" -I {inc_dir}"));
808+
}
799809
if let Some(ref s) = builder.config.llvm_cxxflags {
800810
cxxflags.push(" ");
801811
cxxflags.push(s);

0 commit comments

Comments
 (0)