Skip to content

Commit d1904e5

Browse files
committed
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20
1 parent 86daae2 commit d1904e5

32 files changed

+453
-506
lines changed

Cargo.lock

Lines changed: 37 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ crate-type = ["dylib"]
88

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

2121
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
2222
indexmap = "1.8.0"
2323
libloading = { version = "0.6.0", optional = true }
24+
once_cell = "1.10.0"
2425
smallvec = "1.6.1"
2526

2627
[patch.crates-io]

build_sysroot/Cargo.lock

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_sysroot/Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ compiler_builtins = { version = "0.1.39", default-features = false, features = [
1414
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
1515
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
1616
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
17-
compiler_builtins = { path = "./compiler-builtins" }
1817

1918
[profile.dev]
2019
lto = "off"
@@ -23,3 +22,14 @@ lto = "off"
2322
debug = true
2423
incremental = true
2524
lto = "off"
25+
26+
# Mandatory for correctly compiling compiler-builtins
27+
[profile.dev.package.compiler_builtins]
28+
debug-assertions = false
29+
overflow-checks = false
30+
codegen-units = 10000
31+
32+
[profile.release.package.compiler_builtins]
33+
debug-assertions = false
34+
overflow-checks = false
35+
codegen-units = 10000

build_system/prepare.rs

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,33 @@ pub(crate) fn prepare() {
1414
eprintln!("[INSTALL] hyperfine");
1515
Command::new("cargo").arg("install").arg("hyperfine").spawn().unwrap().wait().unwrap();
1616

17-
clone_repo(
17+
clone_repo_shallow_github(
18+
"rand",
19+
"rust-random",
1820
"rand",
19-
"https://github.com/rust-random/rand.git",
2021
"0f933f9c7176e53b2a3c7952ded484e1783f0bf1",
2122
);
2223
apply_patches("rand", Path::new("rand"));
2324

24-
clone_repo(
25+
clone_repo_shallow_github(
26+
"regex",
27+
"rust-lang",
2528
"regex",
26-
"https://github.com/rust-lang/regex.git",
2729
"341f207c1071f7290e3f228c710817c280c8dca1",
2830
);
2931

30-
clone_repo(
32+
clone_repo_shallow_github(
33+
"portable-simd",
34+
"rust-lang",
3135
"portable-simd",
32-
"https://github.com/rust-lang/portable-simd",
3336
"b8d6b6844602f80af79cd96401339ec594d472d8",
3437
);
3538
apply_patches("portable-simd", Path::new("portable-simd"));
3639

37-
clone_repo(
40+
clone_repo_shallow_github(
41+
"simple-raytracer",
42+
"ebobby",
3843
"simple-raytracer",
39-
"https://github.com/ebobby/simple-raytracer",
4044
"804a7a21b9e673a482797aa289a18ed480e4d813",
4145
);
4246

@@ -74,29 +78,12 @@ fn prepare_sysroot() {
7478
git_init_cmd.arg("init").arg("-q").current_dir(&sysroot_src);
7579
spawn_and_wait(git_init_cmd);
7680

77-
let mut git_add_cmd = Command::new("git");
78-
git_add_cmd.arg("add").arg(".").current_dir(&sysroot_src);
79-
spawn_and_wait(git_add_cmd);
80-
81-
let mut git_commit_cmd = Command::new("git");
82-
git_commit_cmd
83-
.arg("commit")
84-
.arg("-m")
85-
.arg("Initial commit")
86-
.arg("-q")
87-
.current_dir(&sysroot_src);
88-
spawn_and_wait(git_commit_cmd);
81+
init_git_repo(&sysroot_src);
8982

9083
apply_patches("sysroot", &sysroot_src);
91-
92-
clone_repo(
93-
"build_sysroot/compiler-builtins",
94-
"https://github.com/rust-lang/compiler-builtins.git",
95-
"0.1.70",
96-
);
97-
apply_patches("compiler-builtins", Path::new("build_sysroot/compiler-builtins"));
9884
}
9985

86+
#[allow(dead_code)]
10087
fn clone_repo(target_dir: &str, repo: &str, rev: &str) {
10188
eprintln!("[CLONE] {}", repo);
10289
// Ignore exit code as the repo may already have been checked out
@@ -111,6 +98,57 @@ fn clone_repo(target_dir: &str, repo: &str, rev: &str) {
11198
spawn_and_wait(checkout_cmd);
11299
}
113100

101+
fn clone_repo_shallow_github(target_dir: &str, username: &str, repo: &str, rev: &str) {
102+
if cfg!(windows) {
103+
// Older windows doesn't have tar or curl by default. Fall back to using git.
104+
clone_repo(target_dir, &format!("https://github.com/{}/{}.git", username, repo), rev);
105+
return;
106+
}
107+
108+
let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", username, repo, rev);
109+
let archive_file = format!("{}.tar.gz", rev);
110+
let archive_dir = format!("{}-{}", repo, rev);
111+
112+
eprintln!("[DOWNLOAD] {}/{} from {}", username, repo, archive_url);
113+
114+
// Remove previous results if they exists
115+
let _ = std::fs::remove_file(&archive_file);
116+
let _ = std::fs::remove_dir_all(&archive_dir);
117+
let _ = std::fs::remove_dir_all(target_dir);
118+
119+
// Download zip archive
120+
let mut download_cmd = Command::new("curl");
121+
download_cmd.arg("--location").arg("--output").arg(&archive_file).arg(archive_url);
122+
spawn_and_wait(download_cmd);
123+
124+
// Unpack tar archive
125+
let mut unpack_cmd = Command::new("tar");
126+
unpack_cmd.arg("xf").arg(&archive_file);
127+
spawn_and_wait(unpack_cmd);
128+
129+
// Rename unpacked dir to the expected name
130+
std::fs::rename(archive_dir, target_dir).unwrap();
131+
132+
init_git_repo(Path::new(target_dir));
133+
134+
// Cleanup
135+
std::fs::remove_file(archive_file).unwrap();
136+
}
137+
138+
fn init_git_repo(repo_dir: &Path) {
139+
let mut git_init_cmd = Command::new("git");
140+
git_init_cmd.arg("init").arg("-q").current_dir(repo_dir);
141+
spawn_and_wait(git_init_cmd);
142+
143+
let mut git_add_cmd = Command::new("git");
144+
git_add_cmd.arg("add").arg(".").current_dir(repo_dir);
145+
spawn_and_wait(git_add_cmd);
146+
147+
let mut git_commit_cmd = Command::new("git");
148+
git_commit_cmd.arg("commit").arg("-m").arg("Initial commit").arg("-q").current_dir(repo_dir);
149+
spawn_and_wait(git_commit_cmd);
150+
}
151+
114152
fn get_patches(crate_name: &str) -> Vec<OsString> {
115153
let mut patches: Vec<_> = fs::read_dir("patches")
116154
.unwrap()

0 commit comments

Comments
 (0)