Skip to content

Commit 4767cce

Browse files
committed
Auto merge of rust-lang#95142 - bjorn3:sync_cg_clif-2022-03-20, r=bjorn3
Sync rustc_codegen_cranelift r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 9bd5371 + ce7f5ec commit 4767cce

33 files changed

+454
-506
lines changed

compiler/rustc_codegen_cranelift/Cargo.lock

+37-30
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = 3
44

55
[[package]]
66
name = "anyhow"
7-
version = "1.0.53"
7+
version = "1.0.56"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
9-
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
9+
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
1010

1111
[[package]]
1212
name = "ar"
@@ -15,9 +15,9 @@ source = "git+https://github.com/bjorn3/rust-ar.git?branch=do_not_remove_cg_clif
1515

1616
[[package]]
1717
name = "autocfg"
18-
version = "1.0.1"
18+
version = "1.1.0"
1919
source = "registry+https://github.com/rust-lang/crates.io-index"
20-
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
20+
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
2121

2222
[[package]]
2323
name = "bitflags"
@@ -33,18 +33,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
3333

3434
[[package]]
3535
name = "cranelift-bforest"
36-
version = "0.81.0"
36+
version = "0.82.1"
3737
source = "registry+https://github.com/rust-lang/crates.io-index"
38-
checksum = "71447555acc6c875c52c407d572fc1327dc5c34cba72b4b2e7ad048aa4e4fd19"
38+
checksum = "d16922317bd7dd104d509a373887822caa0242fc1def00de66abb538db221db4"
3939
dependencies = [
4040
"cranelift-entity",
4141
]
4242

4343
[[package]]
4444
name = "cranelift-codegen"
45-
version = "0.81.0"
45+
version = "0.82.1"
4646
source = "registry+https://github.com/rust-lang/crates.io-index"
47-
checksum = "ec9a10261891a7a919b0d4f6aa73582e88441d9a8f6173c88efbe4a5a362ea67"
47+
checksum = "8b80bf40380256307b68a3dcbe1b91cac92a533e212b5b635abc3e4525781a0a"
4848
dependencies = [
4949
"cranelift-bforest",
5050
"cranelift-codegen-meta",
@@ -59,30 +59,30 @@ dependencies = [
5959

6060
[[package]]
6161
name = "cranelift-codegen-meta"
62-
version = "0.81.0"
62+
version = "0.82.1"
6363
source = "registry+https://github.com/rust-lang/crates.io-index"
64-
checksum = "815755d76fcbcf6e17ab888545b28ab775f917cb12ce0797e60cd41a2288692c"
64+
checksum = "703d0ed7d3bc6c7a814ca12858175bf4e93167a3584127858c686e4b5dd6e432"
6565
dependencies = [
6666
"cranelift-codegen-shared",
6767
]
6868

6969
[[package]]
7070
name = "cranelift-codegen-shared"
71-
version = "0.81.0"
71+
version = "0.82.1"
7272
source = "registry+https://github.com/rust-lang/crates.io-index"
73-
checksum = "23ea92f2a67335a2e4d3c9c65624c3b14ae287d595b0650822c41824febab66b"
73+
checksum = "80f52311e1c90de12dcf8c4b9999c6ebfd1ed360373e88c357160936844511f6"
7474

7575
[[package]]
7676
name = "cranelift-entity"
77-
version = "0.81.0"
77+
version = "0.82.1"
7878
source = "registry+https://github.com/rust-lang/crates.io-index"
79-
checksum = "bd25847875e388c500ad3624b4d2e14067955c93185194a7222246a25b91c975"
79+
checksum = "66bc82ef522c1f643baf7d4d40b7c52643ee4549d8960b0e6a047daacb83f897"
8080

8181
[[package]]
8282
name = "cranelift-frontend"
83-
version = "0.81.0"
83+
version = "0.82.1"
8484
source = "registry+https://github.com/rust-lang/crates.io-index"
85-
checksum = "308bcfb7eb47bdf5ff6e1ace262af4ed39ec19f204c751fffb037e0e82a0c8bf"
85+
checksum = "3cc35e4251864b17515845ba47447bca88fec9ca1a4186b19fe42526e36140e8"
8686
dependencies = [
8787
"cranelift-codegen",
8888
"log",
@@ -92,9 +92,9 @@ dependencies = [
9292

9393
[[package]]
9494
name = "cranelift-jit"
95-
version = "0.81.0"
95+
version = "0.82.1"
9696
source = "registry+https://github.com/rust-lang/crates.io-index"
97-
checksum = "f560b3a314b8d15facf411e5d29b917c3e787a2bbc3fcdc5183bc0c5b7d4fe01"
97+
checksum = "93c66d594ad3bfe4e58b1fbd8d17877a7c6564a5f2d6f78cbbf4b0182af1927f"
9898
dependencies = [
9999
"anyhow",
100100
"cranelift-codegen",
@@ -110,19 +110,19 @@ dependencies = [
110110

111111
[[package]]
112112
name = "cranelift-module"
113-
version = "0.81.0"
113+
version = "0.82.1"
114114
source = "registry+https://github.com/rust-lang/crates.io-index"
115-
checksum = "3a57aba9e603d694d1430ff38bd914bae23ef9c2e44b25a65e318905807e654c"
115+
checksum = "bf356697c40232aa09e1e3fb8a350ee894e849ccecc4eac56ff0570a4575c325"
116116
dependencies = [
117117
"anyhow",
118118
"cranelift-codegen",
119119
]
120120

121121
[[package]]
122122
name = "cranelift-native"
123-
version = "0.81.0"
123+
version = "0.82.1"
124124
source = "registry+https://github.com/rust-lang/crates.io-index"
125-
checksum = "12cdc799aee673be2317e631d4569a1ba0a7e77a07a7ce45557086d2e02e9514"
125+
checksum = "b882b2251c9845d509d92aebfdb6c8bb3b3b48e207ac951f21fbd20cfe7f90b3"
126126
dependencies = [
127127
"cranelift-codegen",
128128
"libc",
@@ -131,9 +131,9 @@ dependencies = [
131131

132132
[[package]]
133133
name = "cranelift-object"
134-
version = "0.81.0"
134+
version = "0.82.1"
135135
source = "registry+https://github.com/rust-lang/crates.io-index"
136-
checksum = "502a7333836052fcdf4425d7f7a21264d99f862d32b9c3a0e47cd920487a9b60"
136+
checksum = "2d3f1a88e654e567d2591169239ed157ab290811a729a6468f53999c01001263"
137137
dependencies = [
138138
"anyhow",
139139
"cranelift-codegen",
@@ -145,9 +145,9 @@ dependencies = [
145145

146146
[[package]]
147147
name = "crc32fast"
148-
version = "1.3.1"
148+
version = "1.3.2"
149149
source = "registry+https://github.com/rust-lang/crates.io-index"
150-
checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"
150+
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
151151
dependencies = [
152152
"cfg-if",
153153
]
@@ -179,9 +179,9 @@ dependencies = [
179179

180180
[[package]]
181181
name = "libc"
182-
version = "0.2.116"
182+
version = "0.2.119"
183183
source = "registry+https://github.com/rust-lang/crates.io-index"
184-
checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
184+
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
185185

186186
[[package]]
187187
name = "libloading"
@@ -228,6 +228,12 @@ dependencies = [
228228
"memchr",
229229
]
230230

231+
[[package]]
232+
name = "once_cell"
233+
version = "1.10.0"
234+
source = "registry+https://github.com/rust-lang/crates.io-index"
235+
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
236+
231237
[[package]]
232238
name = "regalloc"
233239
version = "0.0.34"
@@ -272,6 +278,7 @@ dependencies = [
272278
"indexmap",
273279
"libloading",
274280
"object",
281+
"once_cell",
275282
"smallvec",
276283
"target-lexicon",
277284
]
@@ -284,9 +291,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
284291

285292
[[package]]
286293
name = "target-lexicon"
287-
version = "0.12.2"
294+
version = "0.12.3"
288295
source = "registry+https://github.com/rust-lang/crates.io-index"
289-
checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff"
296+
checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1"
290297

291298
[[package]]
292299
name = "winapi"

compiler/rustc_codegen_cranelift/Cargo.toml

+7-6
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]

compiler/rustc_codegen_cranelift/build_sysroot/Cargo.lock

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ dependencies = [
5656

5757
[[package]]
5858
name = "compiler_builtins"
59-
version = "0.1.70"
59+
version = "0.1.71"
60+
source = "registry+https://github.com/rust-lang/crates.io-index"
61+
checksum = "163437f05ca8f29d7e9128ea728dedf5eb620e445fbca273641d3a3050305f23"
6062
dependencies = [
6163
"rustc-std-workspace-core",
6264
]
@@ -132,9 +134,9 @@ dependencies = [
132134

133135
[[package]]
134136
name = "libc"
135-
version = "0.2.119"
137+
version = "0.2.121"
136138
source = "registry+https://github.com/rust-lang/crates.io-index"
137-
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
139+
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
138140
dependencies = [
139141
"rustc-std-workspace-core",
140142
]

compiler/rustc_codegen_cranelift/build_sysroot/Cargo.toml

+11-1
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

compiler/rustc_codegen_cranelift/build_system/prepare.rs

+65-27
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)