Skip to content

Commit 617171e

Browse files
committed
Remove cg_clif_build_sysroot
1 parent 377f44d commit 617171e

File tree

3 files changed

+31
-118
lines changed

3 files changed

+31
-118
lines changed

build_system/build_sysroot.rs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::env;
21
use std::fs;
32
use std::path::{Path, PathBuf};
43
use std::process::{self, Command};
@@ -22,25 +21,21 @@ pub(crate) fn build_sysroot(
2221
fs::create_dir_all(target_dir.join("lib")).unwrap();
2322

2423
// Copy the backend
25-
for file in ["cg_clif", "cg_clif_build_sysroot"] {
26-
try_hard_link(
27-
cg_clif_build_dir.join(get_file_name(file, "bin")),
28-
target_dir.join("bin").join(get_file_name(file, "bin")),
29-
);
30-
}
31-
3224
let cg_clif_dylib = get_file_name("rustc_codegen_cranelift", "dylib");
25+
let cg_clif_dylib_path = target_dir
26+
.join(if cfg!(windows) {
27+
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
28+
// binaries.
29+
"bin"
30+
} else {
31+
"lib"
32+
})
33+
.join(&cg_clif_dylib);
34+
try_hard_link(cg_clif_build_dir.join(cg_clif_dylib), &cg_clif_dylib_path);
35+
3336
try_hard_link(
34-
cg_clif_build_dir.join(&cg_clif_dylib),
35-
target_dir
36-
.join(if cfg!(windows) {
37-
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
38-
// binaries.
39-
"bin"
40-
} else {
41-
"lib"
42-
})
43-
.join(cg_clif_dylib),
37+
cg_clif_build_dir.join(get_file_name("cg_clif", "bin")),
38+
target_dir.join("bin").join(get_file_name("cg_clif", "bin")),
4439
);
4540

4641
// Build and copy cargo wrapper
@@ -117,7 +112,13 @@ pub(crate) fn build_sysroot(
117112
}
118113
}
119114
SysrootKind::Clif => {
120-
build_clif_sysroot_for_triple(channel, target_dir, host_triple, None);
115+
build_clif_sysroot_for_triple(
116+
channel,
117+
target_dir,
118+
host_triple,
119+
&cg_clif_dylib_path,
120+
None,
121+
);
121122

122123
if host_triple != target_triple {
123124
// When cross-compiling it is often necessary to manually pick the right linker
@@ -126,7 +127,13 @@ pub(crate) fn build_sysroot(
126127
} else {
127128
None
128129
};
129-
build_clif_sysroot_for_triple(channel, target_dir, target_triple, linker);
130+
build_clif_sysroot_for_triple(
131+
channel,
132+
target_dir,
133+
target_triple,
134+
&cg_clif_dylib_path,
135+
linker,
136+
);
130137
}
131138

132139
// Copy std for the host to the lib dir. This is necessary for the jit mode to find
@@ -145,6 +152,7 @@ fn build_clif_sysroot_for_triple(
145152
channel: &str,
146153
target_dir: &Path,
147154
triple: &str,
155+
cg_clif_dylib_path: &Path,
148156
linker: Option<&str>,
149157
) {
150158
match fs::read_to_string(Path::new("build_sysroot").join("rustc_version")) {
@@ -178,7 +186,8 @@ fn build_clif_sysroot_for_triple(
178186
// Build sysroot
179187
let mut build_cmd = Command::new("cargo");
180188
build_cmd.arg("build").arg("--target").arg(triple).current_dir("build_sysroot");
181-
let mut rustflags = "--clif -Zforce-unstable-if-unmarked".to_string();
189+
let mut rustflags = "-Zforce-unstable-if-unmarked -Cpanic=abort".to_string();
190+
rustflags.push_str(&format!(" -Zcodegen-backend={}", cg_clif_dylib_path.to_str().unwrap()));
182191
if channel == "release" {
183192
build_cmd.arg("--release");
184193
rustflags.push_str(" -Zmir-opt-level=3");
@@ -188,10 +197,6 @@ fn build_clif_sysroot_for_triple(
188197
write!(rustflags, " -Clinker={}", linker).unwrap();
189198
}
190199
build_cmd.env("RUSTFLAGS", rustflags);
191-
build_cmd.env(
192-
"RUSTC",
193-
env::current_dir().unwrap().join(target_dir).join("bin").join("cg_clif_build_sysroot"),
194-
);
195200
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
196201
spawn_and_wait(build_cmd);
197202

build_system/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn main() {
8686
arg => arg_error!("Unexpected argument {}", arg),
8787
}
8888
}
89+
target_dir = std::env::current_dir().unwrap().join(target_dir);
8990

9091
let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") {
9192
host_triple

src/bin/cg_clif_build_sysroot.rs

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)