Skip to content

Sync rustc_codegen_cranelift #95142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b5cbb87
Merge commit '35d9c6bf256968e1b40e0d554607928bdf9cebea' into sync_cg_…
bjorn3 Feb 23, 2022
057de8f
Merge branch 'sync_from_rust'
bjorn3 Feb 23, 2022
69bd532
Normalize main return type during mono item collection & codegen
tmiasko Feb 23, 2022
3461082
rename ErrorReported -> ErrorGuaranteed
mark-i-m Jan 23, 2022
e291495
Add -Z oom={panic,abort} command-line option
Amanieu Oct 6, 2021
c5ec4d3
Fix typo
bjorn3 Mar 4, 2022
7c1a318
Introduce `ConstAllocation`.
nnethercote Mar 1, 2022
8723fe0
Clarify `Layout` interning.
nnethercote Mar 4, 2022
2577efb
Sync from rust 67b3e8183830c7af4e06a9aa91de4d1be3c860f7
bjorn3 Mar 8, 2022
1b75d11
Rustup to rustc 1.61.0-nightly (03918badd 2022-03-07)
bjorn3 Mar 8, 2022
5841caa
Fix compiletest compilation
bjorn3 Mar 8, 2022
401b034
Fix Box deref for non-ZST allocators
bjorn3 Mar 8, 2022
3ccf12a
Update Cranelift to 0.82.0
bjorn3 Mar 8, 2022
01ffb98
Update dependencies
bjorn3 Mar 8, 2022
54920ff
Add missing clif ir comment
bjorn3 Mar 9, 2022
d2026d6
Update Cranelift to 0.82.1
bjorn3 Mar 10, 2022
e439761
Improve `AdtDef` interning.
nnethercote Mar 4, 2022
6e42ca1
Sync from rust 4800c7816ee1937d028407066d229f74b4673c92
bjorn3 Mar 13, 2022
e937265
Rustup to rustc 1.61.0-nightly (f103b2969 2022-03-12)
bjorn3 Mar 13, 2022
cfc1a2c
Remove decl_macro usage
bjorn3 Mar 13, 2022
fef517e
Remove almost all remaining feature gates
bjorn3 Mar 13, 2022
a48fea6
Add and remove some fixmes
bjorn3 Mar 13, 2022
7eb4541
Update list of ignores rustc tests
bjorn3 Mar 13, 2022
90f8aef
Mark cold blocks
bjorn3 Mar 13, 2022
d8e7501
Replace a lot of print+trap with plain trap
bjorn3 Mar 13, 2022
4ba83cb
Merge pull request #1220 from bjorn3/dont_print_on_trap
bjorn3 Mar 14, 2022
af008bd
Rustup to rustc 1.61.0-nightly (285fa7ecd 2022-03-14)
bjorn3 Mar 15, 2022
a900a52
Download tarballs from github instead of cloning full repos
bjorn3 Mar 15, 2022
88c3719
Avoid once_cell unstable feature in cg_clif.rs
bjorn3 Mar 15, 2022
5c666ea
Remove some unused feature gates
bjorn3 Mar 15, 2022
d08d32f
Trim down alloc_system.rs
bjorn3 Mar 15, 2022
64bc235
Silence warning
bjorn3 Mar 16, 2022
c56a10c
rustc_error: make ErrorReported impossible to construct
mark-i-m Jan 23, 2022
9a8da8c
Slightly speed up building of y.rs
bjorn3 Mar 16, 2022
ce577f7
Fix and re-enable some rustc tests
bjorn3 Mar 17, 2022
86daae2
Auto merge of #88098 - Amanieu:oom_panic, r=nagisa
bors Mar 18, 2022
fc80e8b
Re-enable fixed tests
bjorn3 Mar 17, 2022
d1c8cf7
Run tests with warnings
bjorn3 Mar 18, 2022
afd5946
Reorganize test list
bjorn3 Mar 18, 2022
70390a9
Merge pull request #1221 from bjorn3/run_more_rustc_tests
bjorn3 Mar 18, 2022
dab7fc6
Remove no longer necessary rand patch
bjorn3 Mar 18, 2022
6b0c411
Cleanup rand test disable patch
bjorn3 Mar 18, 2022
31329f9
Enable rand based libcore tests
bjorn3 Mar 18, 2022
ef4512b
Codegen 128bit atomic loads and stores for compiler builtins as trap
bjorn3 Mar 19, 2022
670ee7e
Sync from rust 31535841701e0bf7ef33998024376f2cedd8b3e3
bjorn3 Mar 19, 2022
8afa50c
Rustup to rustc 1.61.0-nightly (1bfe40d11 2022-03-18)
bjorn3 Mar 19, 2022
215905c
Wrap write_mir_fn call in with_no_trimmed_paths!()
bjorn3 Mar 19, 2022
e7e5016
Move test and clarify problem of some other tests
bjorn3 Mar 19, 2022
636fb02
Ignore rustc tests with needs-unwind directive
bjorn3 Mar 19, 2022
370c397
Run part of the simd test suite
bjorn3 Mar 19, 2022
ef4ce72
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_…
bjorn3 Mar 20, 2022
ce7f5ec
Add once_cell as allowed cg_clif dependency
bjorn3 Mar 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 37 additions & 30 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = 3

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

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

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

[[package]]
name = "bitflags"
Expand All @@ -33,18 +33,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71447555acc6c875c52c407d572fc1327dc5c34cba72b4b2e7ad048aa4e4fd19"
checksum = "d16922317bd7dd104d509a373887822caa0242fc1def00de66abb538db221db4"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec9a10261891a7a919b0d4f6aa73582e88441d9a8f6173c88efbe4a5a362ea67"
checksum = "8b80bf40380256307b68a3dcbe1b91cac92a533e212b5b635abc3e4525781a0a"
dependencies = [
"cranelift-bforest",
"cranelift-codegen-meta",
Expand All @@ -59,30 +59,30 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "815755d76fcbcf6e17ab888545b28ab775f917cb12ce0797e60cd41a2288692c"
checksum = "703d0ed7d3bc6c7a814ca12858175bf4e93167a3584127858c686e4b5dd6e432"
dependencies = [
"cranelift-codegen-shared",
]

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

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

[[package]]
name = "cranelift-frontend"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308bcfb7eb47bdf5ff6e1ace262af4ed39ec19f204c751fffb037e0e82a0c8bf"
checksum = "3cc35e4251864b17515845ba47447bca88fec9ca1a4186b19fe42526e36140e8"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -92,9 +92,9 @@ dependencies = [

[[package]]
name = "cranelift-jit"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f560b3a314b8d15facf411e5d29b917c3e787a2bbc3fcdc5183bc0c5b7d4fe01"
checksum = "93c66d594ad3bfe4e58b1fbd8d17877a7c6564a5f2d6f78cbbf4b0182af1927f"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -110,19 +110,19 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a57aba9e603d694d1430ff38bd914bae23ef9c2e44b25a65e318905807e654c"
checksum = "bf356697c40232aa09e1e3fb8a350ee894e849ccecc4eac56ff0570a4575c325"
dependencies = [
"anyhow",
"cranelift-codegen",
]

[[package]]
name = "cranelift-native"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12cdc799aee673be2317e631d4569a1ba0a7e77a07a7ce45557086d2e02e9514"
checksum = "b882b2251c9845d509d92aebfdb6c8bb3b3b48e207ac951f21fbd20cfe7f90b3"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -131,9 +131,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.81.0"
version = "0.82.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "502a7333836052fcdf4425d7f7a21264d99f862d32b9c3a0e47cd920487a9b60"
checksum = "2d3f1a88e654e567d2591169239ed157ab290811a729a6468f53999c01001263"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -145,9 +145,9 @@ dependencies = [

[[package]]
name = "crc32fast"
version = "1.3.1"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
Expand Down Expand Up @@ -179,9 +179,9 @@ dependencies = [

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

[[package]]
name = "libloading"
Expand Down Expand Up @@ -228,6 +228,12 @@ dependencies = [
"memchr",
]

[[package]]
name = "once_cell"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"

[[package]]
name = "regalloc"
version = "0.0.34"
Expand Down Expand Up @@ -272,6 +278,7 @@ dependencies = [
"indexmap",
"libloading",
"object",
"once_cell",
"smallvec",
"target-lexicon",
]
Expand All @@ -284,9 +291,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"

[[package]]
name = "target-lexicon"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff"
checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1"

[[package]]
name = "winapi"
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.81.0", features = ["unwind", "all-arch"] }
cranelift-frontend = "0.81.0"
cranelift-module = "0.81.0"
cranelift-native = "0.81.0"
cranelift-jit = { version = "0.81.0", optional = true }
cranelift-object = "0.81.0"
cranelift-codegen = { version = "0.82.1", features = ["unwind", "all-arch"] }
cranelift-frontend = "0.82.1"
cranelift-module = "0.82.1"
cranelift-native = "0.82.1"
cranelift-jit = { version = "0.82.1", optional = true }
cranelift-object = "0.82.1"
target-lexicon = "0.12.0"
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

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

[patch.crates-io]
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_cranelift/build_sysroot/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.70"
version = "0.1.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "163437f05ca8f29d7e9128ea728dedf5eb620e445fbca273641d3a3050305f23"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -132,9 +134,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.119"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_codegen_cranelift/build_sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ compiler_builtins = { version = "0.1.39", default-features = false, features = [
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
compiler_builtins = { path = "./compiler-builtins" }

[profile.dev]
lto = "off"
Expand All @@ -23,3 +22,14 @@ lto = "off"
debug = true
incremental = true
lto = "off"

# Mandatory for correctly compiling compiler-builtins
[profile.dev.package.compiler_builtins]
debug-assertions = false
overflow-checks = false
codegen-units = 10000

[profile.release.package.compiler_builtins]
debug-assertions = false
overflow-checks = false
codegen-units = 10000
92 changes: 65 additions & 27 deletions compiler/rustc_codegen_cranelift/build_system/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,33 @@ pub(crate) fn prepare() {
eprintln!("[INSTALL] hyperfine");
Command::new("cargo").arg("install").arg("hyperfine").spawn().unwrap().wait().unwrap();

clone_repo(
clone_repo_shallow_github(
"rand",
"rust-random",
"rand",
"https://github.com/rust-random/rand.git",
"0f933f9c7176e53b2a3c7952ded484e1783f0bf1",
);
apply_patches("rand", Path::new("rand"));

clone_repo(
clone_repo_shallow_github(
"regex",
"rust-lang",
"regex",
"https://github.com/rust-lang/regex.git",
"341f207c1071f7290e3f228c710817c280c8dca1",
);

clone_repo(
clone_repo_shallow_github(
"portable-simd",
"rust-lang",
"portable-simd",
"https://github.com/rust-lang/portable-simd",
"b8d6b6844602f80af79cd96401339ec594d472d8",
);
apply_patches("portable-simd", Path::new("portable-simd"));

clone_repo(
clone_repo_shallow_github(
"simple-raytracer",
"ebobby",
"simple-raytracer",
"https://github.com/ebobby/simple-raytracer",
"804a7a21b9e673a482797aa289a18ed480e4d813",
);

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

let mut git_add_cmd = Command::new("git");
git_add_cmd.arg("add").arg(".").current_dir(&sysroot_src);
spawn_and_wait(git_add_cmd);

let mut git_commit_cmd = Command::new("git");
git_commit_cmd
.arg("commit")
.arg("-m")
.arg("Initial commit")
.arg("-q")
.current_dir(&sysroot_src);
spawn_and_wait(git_commit_cmd);
init_git_repo(&sysroot_src);

apply_patches("sysroot", &sysroot_src);

clone_repo(
"build_sysroot/compiler-builtins",
"https://github.com/rust-lang/compiler-builtins.git",
"0.1.70",
);
apply_patches("compiler-builtins", Path::new("build_sysroot/compiler-builtins"));
}

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

fn clone_repo_shallow_github(target_dir: &str, username: &str, repo: &str, rev: &str) {
if cfg!(windows) {
// Older windows doesn't have tar or curl by default. Fall back to using git.
clone_repo(target_dir, &format!("https://github.com/{}/{}.git", username, repo), rev);
return;
}

let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", username, repo, rev);
let archive_file = format!("{}.tar.gz", rev);
let archive_dir = format!("{}-{}", repo, rev);

eprintln!("[DOWNLOAD] {}/{} from {}", username, repo, archive_url);

// Remove previous results if they exists
let _ = std::fs::remove_file(&archive_file);
let _ = std::fs::remove_dir_all(&archive_dir);
let _ = std::fs::remove_dir_all(target_dir);

// Download zip archive
let mut download_cmd = Command::new("curl");
download_cmd.arg("--location").arg("--output").arg(&archive_file).arg(archive_url);
spawn_and_wait(download_cmd);

// Unpack tar archive
let mut unpack_cmd = Command::new("tar");
unpack_cmd.arg("xf").arg(&archive_file);
spawn_and_wait(unpack_cmd);

// Rename unpacked dir to the expected name
std::fs::rename(archive_dir, target_dir).unwrap();

init_git_repo(Path::new(target_dir));

// Cleanup
std::fs::remove_file(archive_file).unwrap();
}

fn init_git_repo(repo_dir: &Path) {
let mut git_init_cmd = Command::new("git");
git_init_cmd.arg("init").arg("-q").current_dir(repo_dir);
spawn_and_wait(git_init_cmd);

let mut git_add_cmd = Command::new("git");
git_add_cmd.arg("add").arg(".").current_dir(repo_dir);
spawn_and_wait(git_add_cmd);

let mut git_commit_cmd = Command::new("git");
git_commit_cmd.arg("commit").arg("-m").arg("Initial commit").arg("-q").current_dir(repo_dir);
spawn_and_wait(git_commit_cmd);
}

fn get_patches(crate_name: &str) -> Vec<OsString> {
let mut patches: Vec<_> = fs::read_dir("patches")
.unwrap()
Expand Down
Loading