Skip to content

Commit 8ee35be

Browse files
committed
cleanup
1 parent e82a408 commit 8ee35be

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
@@ -892,6 +892,17 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
892892
.or_else(|| env::var_os(var_base))
893893
}
894894

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

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

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

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

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

1000+
// FIXME(offload): Once we move from OMP to Offload (Ol) APIs, we should drop the openmp
1001+
// runtime to simplify our build. We should also re-evaluate the LLVM_Root and try to get
1002+
// rid of the Clang_DIR, once we upgrade to LLVM-22.
9991003
cfg.out_dir(&out_dir)
10001004
.profile(profile)
10011005
.env("LLVM_CONFIG_REAL", &host_llvm_config)
10021006
.define("LLVM_ENABLE_ASSERTIONS", "ON")
10031007
.define("LLVM_ENABLE_RUNTIMES", "openmp;offload")
10041008
.define("LLVM_INCLUDE_TESTS", "OFF")
10051009
.define("OFFLOAD_INCLUDE_TESTS", "OFF")
1006-
//.define("CMAKE_C_COMPILER", cc)
1007-
//.define("CMAKE_CXX_COMPILER", cxx)
10081010
.define("OPENMP_STANDALONE_BUILD", "ON")
1009-
.define("LLVM_ROOT", root)
1011+
.define("LLVM_ROOT", builder.llvm_out(target).join("build"))
10101012
.define("LLVM_DIR", builder.llvm_out(target).join("lib").join("cmake").join("llvm"));
10111013
if let Some(p) = clang_dir {
10121014
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,
@@ -606,9 +603,6 @@ impl Config {
606603
ldflags: llvm_ldflags,
607604
use_libcxx: llvm_use_libcxx,
608605
use_linker: llvm_use_linker,
609-
offload_cc: llvm_offload_cc,
610-
offload_cxx: llvm_offload_cxx,
611-
root_offload: llvm_root_offload,
612606
clang_dir: llvm_clang_dir,
613607
allow_old_toolchain: llvm_allow_old_toolchain,
614608
offload: llvm_offload,
@@ -1372,7 +1366,6 @@ impl Config {
13721366
llvm_enable_warnings: llvm_enable_warnings.unwrap_or(false),
13731367
llvm_enzyme: llvm_enzyme.unwrap_or(false),
13741368
llvm_experimental_targets,
1375-
llvm_root_offload: llvm_root_offload.map(PathBuf::from),
13761369
llvm_from_ci,
13771370
llvm_ldflags,
13781371
llvm_libunwind_default: rust_llvm_libunwind
@@ -1387,8 +1380,6 @@ impl Config {
13871380
.or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)),
13881381
),
13891382
llvm_offload: llvm_offload.unwrap_or(false),
1390-
llvm_offload_cc: llvm_offload_cc.map(PathBuf::from),
1391-
llvm_offload_cxx: llvm_offload_cxx.map(PathBuf::from),
13921383
llvm_optimize: llvm_optimize.unwrap_or(true),
13931384
llvm_plugins: llvm_plugin.unwrap_or(false),
13941385
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)