Skip to content

Commit e460234

Browse files
committed
clean up Include dir handling
1 parent 7895f56 commit e460234

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
@@ -769,6 +769,17 @@ fn configure_cmake(
769769
.collect::<Vec<String>>()
770770
.join(" ")
771771
.into();
772+
773+
// If we use an external clang as opposed to building our own llvm_clang, than that clang will
774+
// come with it's own set of default include directories, which are based on a potentially older
775+
// LLVM. This can cause issues, so we overwrite it to include headers based on our
776+
// `src/llvm-project` submodule instead.
777+
// FIXME(offload): With LLVM-22 we hopefully won't need an external clang anymore.
778+
let base = builder.llvm_out(target).join("include");
779+
let inc_dir = base.display();
780+
if builder.config.llvm_offload && !builder.config.llvm_clang {
781+
cflags.push(format!(" -I {inc_dir}"));
782+
}
772783
if let Some(ref s) = builder.config.llvm_cflags {
773784
cflags.push(" ");
774785
cflags.push(s);
@@ -779,11 +790,8 @@ fn configure_cmake(
779790
if builder.config.llvm_clang_cl.is_some() {
780791
cflags.push(format!(" --target={target}"));
781792
}
782-
// Manuel
783-
let base = builder.llvm_out(target).join("include");
784-
let inc_dir = base.display();
785-
cflags.push(format!(" -I {inc_dir}"));
786793
cfg.define("CMAKE_C_FLAGS", cflags);
794+
787795
let mut cxxflags: OsString = builder
788796
.cc_handled_clags(target, CLang::Cxx)
789797
.into_iter()
@@ -796,7 +804,9 @@ fn configure_cmake(
796804
.collect::<Vec<String>>()
797805
.join(" ")
798806
.into();
799-
cxxflags.push(format!(" -I {inc_dir}"));
807+
if builder.config.llvm_offload && !builder.config.llvm_clang {
808+
cxxflags.push(format!(" -I {inc_dir}"));
809+
}
800810
if let Some(ref s) = builder.config.llvm_cxxflags {
801811
cxxflags.push(" ");
802812
cxxflags.push(s);

0 commit comments

Comments
 (0)