Skip to content

Commit e8ad199

Browse files
committed
Merge commit '57845a397ec15e4e6a561ed2c4bfa3dcf49144fb' into sync_cg_clif-2024-12-06
1 parent 7174bcc commit e8ad199

29 files changed

+396
-428
lines changed

Cargo.lock

+49-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ crate-type = ["dylib"]
88

99
[dependencies]
1010
# These have to be in sync with each other
11-
cranelift-codegen = { version = "0.113.0", default-features = false, features = ["std", "unwind", "all-native-arch"] }
12-
cranelift-frontend = { version = "0.113.0" }
13-
cranelift-module = { version = "0.113.0" }
14-
cranelift-native = { version = "0.113.0" }
15-
cranelift-jit = { version = "0.113.0", optional = true }
16-
cranelift-object = { version = "0.113.0" }
11+
cranelift-codegen = { version = "0.114.0", default-features = false, features = ["std", "unwind", "all-native-arch"] }
12+
cranelift-frontend = { version = "0.114.0" }
13+
cranelift-module = { version = "0.114.0" }
14+
cranelift-native = { version = "0.114.0" }
15+
cranelift-jit = { version = "0.114.0", optional = true }
16+
cranelift-object = { version = "0.114.0" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.31", default-features = false, features = ["write"] }
1919
object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

build_system/abi_cafe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::path::{Dirs, RelPath};
1+
use crate::path::Dirs;
22
use crate::prepare::GitRepo;
33
use crate::utils::{CargoProject, Compiler, spawn_and_wait};
44
use crate::{CodegenBackend, SysrootKind, build_sysroot};
@@ -20,7 +20,7 @@ pub(crate) fn run(
2020
rustup_toolchain_name: Option<&str>,
2121
bootstrap_host_compiler: &Compiler,
2222
) {
23-
RelPath::DOWNLOAD.ensure_exists(dirs);
23+
std::fs::create_dir_all(&dirs.download_dir).unwrap();
2424
ABI_CAFE_REPO.fetch(dirs);
2525
ABI_CAFE_REPO.patch(dirs);
2626

build_system/bench.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::Write;
33
use std::path::Path;
44
use std::process::Command;
55

6-
use crate::path::{Dirs, RelPath};
6+
use crate::path::Dirs;
77
use crate::prepare::GitRepo;
88
use crate::rustc_info::get_file_name;
99
use crate::utils::{Compiler, spawn_and_wait};
@@ -39,11 +39,11 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
3939
};
4040

4141
eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
42-
let cargo_clif = RelPath::DIST
43-
.to_path(dirs)
42+
let cargo_clif = dirs
43+
.dist_dir
4444
.join(get_file_name(&bootstrap_host_compiler.rustc, "cargo_clif", "bin").replace('_', "-"));
4545
let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml");
46-
let target_dir = RelPath::BUILD.join("simple_raytracer").to_path(dirs);
46+
let target_dir = dirs.build_dir.join("simple_raytracer");
4747

4848
let clean_cmd = format!(
4949
"RUSTC=rustc cargo clean --manifest-path {manifest_path} --target-dir {target_dir}",
@@ -68,7 +68,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
6868
target_dir = target_dir.display(),
6969
);
7070

71-
let bench_compile_markdown = RelPath::DIST.to_path(dirs).join("bench_compile.md");
71+
let bench_compile_markdown = dirs.dist_dir.join("bench_compile.md");
7272

7373
let bench_compile = hyperfine_command(
7474
1,
@@ -92,7 +92,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
9292

9393
eprintln!("[BENCH RUN] ebobby/simple-raytracer");
9494

95-
let bench_run_markdown = RelPath::DIST.to_path(dirs).join("bench_run.md");
95+
let bench_run_markdown = dirs.dist_dir.join("bench_run.md");
9696

9797
let raytracer_cg_llvm = Path::new(".").join(get_file_name(
9898
&bootstrap_host_compiler.rustc,
@@ -120,7 +120,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
120120
],
121121
&bench_run_markdown,
122122
);
123-
bench_run.current_dir(RelPath::BUILD.to_path(dirs));
123+
bench_run.current_dir(&dirs.build_dir);
124124
spawn_and_wait(bench_run);
125125

126126
if let Some(gha_step_summary) = gha_step_summary.as_mut() {

build_system/build_backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::rustc_info::get_file_name;
66
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
77
use crate::utils::{CargoProject, Compiler, LogGroup};
88

9-
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
9+
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::source("."), "cg_clif");
1010

1111
pub(crate) fn build_backend(
1212
dirs: &Dirs,

build_system/build_sysroot.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ pub(crate) fn build_sysroot(
2222

2323
eprintln!("[BUILD] sysroot {:?}", sysroot_kind);
2424

25-
let dist_dir = RelPath::DIST.to_path(dirs);
25+
let dist_dir = &dirs.dist_dir;
2626

27-
ensure_empty_dir(&dist_dir);
27+
ensure_empty_dir(dist_dir);
2828
fs::create_dir_all(dist_dir.join("bin")).unwrap();
2929
fs::create_dir_all(dist_dir.join("lib")).unwrap();
3030

@@ -55,7 +55,7 @@ pub(crate) fn build_sysroot(
5555
let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
5656
let wrapper_path = dist_dir.join(&wrapper_name);
5757
build_cargo_wrapper_cmd
58-
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
58+
.arg(dirs.source_dir.join("scripts").join(&format!("{wrapper}.rs")))
5959
.arg("-o")
6060
.arg(&wrapper_path)
6161
.arg("-Cstrip=debuginfo");
@@ -85,7 +85,7 @@ pub(crate) fn build_sysroot(
8585
&cg_clif_dylib_path,
8686
sysroot_kind,
8787
);
88-
host.install_into_sysroot(&dist_dir);
88+
host.install_into_sysroot(dist_dir);
8989

9090
if !is_native {
9191
build_sysroot_for_triple(
@@ -99,7 +99,7 @@ pub(crate) fn build_sysroot(
9999
&cg_clif_dylib_path,
100100
sysroot_kind,
101101
)
102-
.install_into_sysroot(&dist_dir);
102+
.install_into_sysroot(dist_dir);
103103
}
104104

105105
let mut target_compiler = {
@@ -143,10 +143,10 @@ impl SysrootTarget {
143143
}
144144
}
145145

146-
static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib");
146+
static STDLIB_SRC: RelPath = RelPath::build("stdlib");
147147
static STANDARD_LIBRARY: CargoProject =
148-
CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target");
149-
static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");
148+
CargoProject::new(&RelPath::build("stdlib/library/sysroot"), "stdlib_target");
149+
static RTSTARTUP_SYSROOT: RelPath = RelPath::build("rtstartup");
150150

151151
fn build_sysroot_for_triple(
152152
dirs: &Dirs,
@@ -247,6 +247,7 @@ fn build_clif_sysroot_for_triple(
247247
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
248248
build_cmd.arg("--release");
249249
build_cmd.arg("--features").arg("backtrace panic-unwind compiler-builtins-no-f16-f128");
250+
build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display()));
250251
build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true");
251252
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
252253
if compiler.triple.contains("apple") {
@@ -281,13 +282,14 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
281282
return None;
282283
}
283284

284-
RTSTARTUP_SYSROOT.ensure_fresh(dirs);
285+
let rtstartup_sysroot = RTSTARTUP_SYSROOT.to_path(dirs);
286+
ensure_empty_dir(&rtstartup_sysroot);
285287

286288
let rtstartup_src = STDLIB_SRC.to_path(dirs).join("library").join("rtstartup");
287289
let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };
288290

289291
for file in ["rsbegin", "rsend"] {
290-
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
292+
let obj = rtstartup_sysroot.join(format!("{file}.o"));
291293
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
292294
build_rtstartup_cmd
293295
.arg("--target")

build_system/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,11 @@ fn main() {
185185
frozen,
186186
};
187187

188-
path::RelPath::BUILD.ensure_exists(&dirs);
188+
std::fs::create_dir_all(&dirs.build_dir).unwrap();
189189

190190
{
191191
// Make sure we always explicitly specify the target dir
192-
let target =
193-
path::RelPath::BUILD.join("target_dir_should_be_set_explicitly").to_path(&dirs);
192+
let target = dirs.build_dir.join("target_dir_should_be_set_explicitly");
194193
env::set_var("CARGO_TARGET_DIR", &target);
195194
let _ = std::fs::remove_file(&target);
196195
std::fs::File::create(target).unwrap();

0 commit comments

Comments
 (0)