Skip to content

Commit 66af9ec

Browse files
committed
cleanup
1 parent 3c8092d commit 66af9ec

File tree

4 files changed

+29
-38
lines changed

4 files changed

+29
-38
lines changed

src/bootstrap/configure.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ def v(*args):
120120
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
121121
o("llvm-enzyme", "llvm.enzyme", "build LLVM with enzyme")
122122
o("llvm-offload", "llvm.offload", "build LLVM with gpu offload support")
123-
o("llvm-offload-clang-dir", "llvm.offload-clang-dir", "pass the absolute directory of ClangConfig.cmake")
123+
o(
124+
"llvm-offload-clang-dir",
125+
"llvm.offload-clang-dir",
126+
"pass the absolute directory of ClangConfig.cmake",
127+
)
124128
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface")
125129
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")
126130
o(

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

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,17 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
891891
.or_else(|| env::var_os(var_base))
892892
}
893893

894+
// FIXME(offload): In an ideal world, we would just enable the offload runtime in our previous LLVM
895+
// build step. For now, we still depend on the openmp runtime since we use some of it's API, so we
896+
// build both. However, when building those runtimes as part of the LLVM step, then LLVM's cmake
897+
// implicitely assumes that Clang has also been build and will try to use it. In the Rust CI, we
898+
// don't always build clang (due to compile times), but instead use a slightly older external clang.
899+
// LLVM tries to remove this build dependency of offload/openmp on Clang for LLVM-22, so in the
900+
// future we might be able to integrate this step into the LLVM step. For now, we instead introduce
901+
// a Clang_DIR bootstrap option, which allows us tell CMake to use an external clang for these two
902+
// runtimes. This external clang will try to use it's own (older) include dirs when building our
903+
// in-tree LLVM submodule, which will cause build failures. To prevent those, we now also
904+
// explicitely set our include dirs.
894905
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
895906
pub struct OmpOffload {
896907
pub target: TargetSelection,
@@ -918,11 +929,17 @@ impl Step for OmpOffload {
918929

919930
let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: self.target });
920931

932+
// Running cmake twice in the same folder is known to cause issues, like deleting existing
933+
// binaries. We therefore write our offload artifacts into it's own subfolder. We use a
934+
// subfolder, so that all the logic that processes our build artifacts (hopefully) also
935+
// automatically manages our artifacts in the subfolder.
921936
let out_dir = builder.llvm_out(target).join("offload-outdir");
922937
if std::fs::exists(&out_dir).is_ok_and(|x| x == false) {
923938
std::fs::DirBuilder::new().create(&out_dir).unwrap();
924939
dbg!("Created out subdir!");
925940
}
941+
942+
// Offload/OpenMP are just subfolders of LLVM, so we can use the LLVM sha.
926943
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
927944
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
928945
generate_smart_stamp_hash(
@@ -960,32 +977,16 @@ impl Step for OmpOffload {
960977
configure_cmake(builder, target, &mut cfg, true, LdFlags::default(), &[]);
961978

962979
// Re-use the same flags as llvm to control the level of debug information
963-
// generated by Enzyme.
964-
// FIXME(ZuseZ4): Find a nicer way to use Enzyme Debug builds.
980+
// generated for offload.
965981
let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) {
966982
(false, _) => "Debug",
967983
(true, false) => "Release",
968984
(true, true) => "RelWithDebInfo",
969985
};
970986
trace!(?profile);
971987

972-
//let cc = if let Some(p) = &builder.build.config.llvm_offload_cc {
973-
// //p.clone()
974-
// builder.cc(target)
975-
//} else {
976-
// builder.cc(target)
977-
//};
978-
//let cxx = if let Some(p) = &builder.build.config.llvm_offload_cxx {
979-
// //p.clone()
980-
// builder.cxx(target).unwrap()
981-
//} else {
982-
// builder.cxx(target).unwrap()
983-
//};
984-
let root = if let Some(p) = &builder.build.config.llvm_root_offload {
985-
p.clone()
986-
} else {
987-
builder.llvm_out(target).join("build")
988-
};
988+
// OpenMP/Offload builds currently (LLVM-21) still depend on Clang, although there are
989+
// intentions to loosen this requirement for LLVM-22. If we were to
989990
let clang_dir = if !builder.config.llvm_clang {
990991
// We must have an external clang to use.
991992
assert!(&builder.build.config.llvm_clang_dir.is_some());
@@ -995,17 +996,18 @@ impl Step for OmpOffload {
995996
None
996997
};
997998

999+
// FIXME(offload): Once we move from OMP to Offload (Ol) APIs, we should drop the openmp
1000+
// runtime to simplify our build. We should also re-evaluate the LLVM_Root and try to get
1001+
// rid of the Clang_DIR, once we upgrade to LLVM-22.
9981002
cfg.out_dir(&out_dir)
9991003
.profile(profile)
10001004
.env("LLVM_CONFIG_REAL", &host_llvm_config)
10011005
.define("LLVM_ENABLE_ASSERTIONS", "ON")
10021006
.define("LLVM_ENABLE_RUNTIMES", "openmp;offload")
10031007
.define("LLVM_INCLUDE_TESTS", "OFF")
10041008
.define("OFFLOAD_INCLUDE_TESTS", "OFF")
1005-
//.define("CMAKE_C_COMPILER", cc)
1006-
//.define("CMAKE_CXX_COMPILER", cxx)
10071009
.define("OPENMP_STANDALONE_BUILD", "ON")
1008-
.define("LLVM_ROOT", root)
1010+
.define("LLVM_ROOT", builder.llvm_out(target).join("build"))
10091011
.define("LLVM_DIR", builder.llvm_out(target).join("lib").join("cmake").join("llvm"));
10101012
if let Some(p) = clang_dir {
10111013
cfg.define("Clang_DIR", p);

src/bootstrap/src/core/config/config.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ pub struct Config {
169169
pub llvm_link_jobs: Option<u32>,
170170
pub llvm_version_suffix: Option<String>,
171171
pub llvm_use_linker: Option<String>,
172-
pub llvm_offload_cc: Option<PathBuf>,
173-
pub llvm_offload_cxx: Option<PathBuf>,
174-
pub llvm_root_offload: Option<PathBuf>,
175172
pub llvm_clang_dir: Option<PathBuf>,
176173
pub llvm_allow_old_toolchain: bool,
177174
pub llvm_polly: bool,
@@ -607,9 +604,6 @@ impl Config {
607604
ldflags: llvm_ldflags,
608605
use_libcxx: llvm_use_libcxx,
609606
use_linker: llvm_use_linker,
610-
offload_cc: llvm_offload_cc,
611-
offload_cxx: llvm_offload_cxx,
612-
root_offload: llvm_root_offload,
613607
clang_dir: llvm_clang_dir,
614608
allow_old_toolchain: llvm_allow_old_toolchain,
615609
offload: llvm_offload,
@@ -1377,7 +1371,6 @@ impl Config {
13771371
llvm_enable_warnings: llvm_enable_warnings.unwrap_or(false),
13781372
llvm_enzyme: llvm_enzyme.unwrap_or(false),
13791373
llvm_experimental_targets,
1380-
llvm_root_offload: llvm_root_offload.map(PathBuf::from),
13811374
llvm_from_ci,
13821375
llvm_ldflags,
13831376
llvm_libunwind_default: rust_llvm_libunwind
@@ -1392,8 +1385,6 @@ impl Config {
13921385
.or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)),
13931386
),
13941387
llvm_offload: llvm_offload.unwrap_or(false),
1395-
llvm_offload_cc: llvm_offload_cc.map(PathBuf::from),
1396-
llvm_offload_cxx: llvm_offload_cxx.map(PathBuf::from),
13971388
llvm_optimize: llvm_optimize.unwrap_or(true),
13981389
llvm_plugins: llvm_plugin.unwrap_or(false),
13991390
llvm_polly: llvm_polly.unwrap_or(false),

src/bootstrap/src/core/config/toml/llvm.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ define_config! {
3232
ldflags: Option<String> = "ldflags",
3333
use_libcxx: Option<bool> = "use-libcxx",
3434
use_linker: Option<String> = "use-linker",
35-
offload_cc: Option<String> = "offload-cc",
36-
offload_cxx: Option<String> = "offload-cxx",
37-
root_offload: Option<String> = "root-offload",
3835
clang_dir: Option<String> = "offload-clang-dir",
3936
allow_old_toolchain: Option<bool> = "allow-old-toolchain",
4037
offload: Option<bool> = "offload",
@@ -114,9 +111,6 @@ pub fn check_incompatible_options_for_ci_llvm(
114111
ldflags,
115112
use_libcxx,
116113
use_linker,
117-
offload_cc: _,
118-
offload_cxx: _,
119-
root_offload: _,
120114
clang_dir: _,
121115
allow_old_toolchain,
122116
offload,

0 commit comments

Comments
 (0)