Skip to content

Sync rustc_codegen_cranelift #107269

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 96 commits into from
Jan 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
67b711a
Rename `assert_uninit_valid` intrinsic
Noratrieb Dec 12, 2022
98a276b
Merge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into sync_cg_…
bjorn3 Dec 14, 2022
b16dd91
Merge branch 'sync_from_rust'
bjorn3 Dec 14, 2022
808cba2
Extract Compiler creation from tests.rs
bjorn3 Dec 15, 2022
f626185
Update portable-simd to 582239ac3b32007613df04d7ffa78dc30f4c5645
bjorn3 Dec 15, 2022
0865e5a
Set RUSTDOCFLAGS again
bjorn3 Dec 15, 2022
06be70e
Implement simd_gather and simd_scatter (#1309)
bjorn3 Dec 15, 2022
e2a2739
Update not yet supported section of the readme
bjorn3 Dec 15, 2022
d74e5b6
Update actions/upload-artifact to v3
bjorn3 Dec 15, 2022
d841f93
Add .comment section with producer name
bjorn3 Dec 15, 2022
e082eeb
Run verifier checks during rustc tests too
bjorn3 Dec 15, 2022
cc3ac00
Move many env vars from CI configuration to the build system
bjorn3 Dec 15, 2022
6c88b08
Fix some build steps on Windows
bjorn3 Dec 15, 2022
1ca07b9
Fix running simple-raytracer benchmark on Windows
bjorn3 Dec 15, 2022
280fb29
Start running regex-shootout-regex-dna on Windows again
bjorn3 Dec 15, 2022
e735206
Unify Windows and non-Windows CI
bjorn3 Dec 15, 2022
a501d96
Merge branch 'staging'
bjorn3 Dec 15, 2022
9ca82a9
Fix ICE on unsized locals
bjorn3 Dec 16, 2022
b5ac64b
Don't PrintOnPanic on fatal errors
bjorn3 Dec 16, 2022
ec92c3e
Fix ICE on incompatible declarations of entry symbol
bjorn3 Dec 16, 2022
9165542
Ensure Cranelift errors are reported deterministically
bjorn3 Dec 16, 2022
14ca1df
Enable debug assertions on CI
bjorn3 Dec 16, 2022
ab0e2aa
Revert "Don't PrintOnPanic on fatal errors"
bjorn3 Dec 16, 2022
1c724ee
Re-enable some rustc tests
bjorn3 Dec 16, 2022
dffa6ac
Fix crash after simd type validation error
bjorn3 Dec 16, 2022
ee05e4d
Don't ICE on unimplemented call convs
bjorn3 Dec 16, 2022
8b47801
Don't ICE on C-cmse-nonsecure-call either
bjorn3 Dec 16, 2022
928d656
Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung
bors Dec 21, 2022
debd45c
Update to cranelift 0.91
bjorn3 Dec 13, 2022
97e2213
Enable inline stack probes on AArch64
bjorn3 Dec 22, 2022
571405d
Enable some fixed rustc tests
bjorn3 Jan 4, 2023
4c97569
Move patched sysroot from build_sysroot/ to download/
bjorn3 Jan 5, 2023
da37e16
Remove debuginfo files for compiled y.rs in clean_all.sh
bjorn3 Jan 5, 2023
e14e5c2
Don't use hyperfine during testing
bjorn3 Jan 5, 2023
20429c0
Merge pull request #1338 from bjorn3/build_system_rework5
bjorn3 Jan 5, 2023
4e47bd0
Change `src/test` to `tests` in source files, fix tidy and tests
albertlarsan68 Jan 5, 2023
fb788e3
Don't install hyperfine in y.rs prepare
bjorn3 Jan 11, 2023
caacef2
Retry downloads on network failure
bjorn3 Jan 11, 2023
8686383
Rustfmt
bjorn3 Jan 11, 2023
dbfbb29
Move LLVM simple-raytracer build to ./y.rs bench
bjorn3 Jan 13, 2023
cf22470
Disable CG_CLIF_DISPLAY_CG_TIME by default
bjorn3 Jan 13, 2023
70a1cb9
Pass around Compiler instead of target triples
bjorn3 Jan 13, 2023
f311ef5
Share cross-compilation code between building and testing
bjorn3 Jan 13, 2023
bb7ab82
Remove a lot of redundant rustc arguments for tests
bjorn3 Jan 13, 2023
af99a36
Use sparse cargo registry
bjorn3 Jan 13, 2023
397fafa
Don't require git user to be configured for testing rust
bjorn3 Jan 13, 2023
63fae6a
Introduce helpers for common test case commands
bjorn3 Jan 13, 2023
4074569
Add fixme
bjorn3 Jan 13, 2023
9a15db6
Add git_command helper
bjorn3 Jan 13, 2023
890c612
Set core.autocrlf=false in the build system instead of CI config
bjorn3 Jan 13, 2023
1a89507
Don't use the diff command in regex test
bjorn3 Jan 13, 2023
957d78c
Fetch all cargo dependencies in ./y.rs prepare
bjorn3 Jan 13, 2023
be8f656
Pass --frozen to cargo to ensure ./y.rs prepare fetches all deps
bjorn3 Jan 13, 2023
288c067
Set panic=abort for the build system
bjorn3 Jan 13, 2023
a346877
Rustfmt
bjorn3 Jan 13, 2023
3a27253
Enable VSCode formatOnSave
bjorn3 Jan 13, 2023
bdcbf47
Improve readme and build system help message
bjorn3 Jan 13, 2023
20a829a
Merge pull request #1339 from bjorn3/better_compiler_management
bjorn3 Jan 13, 2023
8af4eac
Update FreeBSD to 13.1
bjorn3 Jan 13, 2023
395eaa1
Remove Test nightly Cranelift workflow
bjorn3 Jan 14, 2023
9bc113f
Minor consistency improvement
bjorn3 Jan 14, 2023
a09712e
Use fs::remove_dir_all instead of cargo clean
bjorn3 Jan 14, 2023
5e452ba
Set RUSTC and RUSTDOC env vars to invalid values to catch forgetting …
bjorn3 Jan 14, 2023
fd1e824
Minor changes to the TestRunner::new signature
bjorn3 Jan 14, 2023
bbb7a3b
Rename Compiler variables for clarity
bjorn3 Jan 14, 2023
4dbafef
Return Compiler from build_sysroot
bjorn3 Jan 14, 2023
22c5249
Don't hard-code rustc path in get_rustc_version and get_default_sysroot
bjorn3 Jan 14, 2023
629eab7
Avoid hard-coded rustc when building wrappers
bjorn3 Jan 14, 2023
b31b74e
Merge pull request #1340 from bjorn3/non_rustup_build
bjorn3 Jan 14, 2023
c950f22
Build rtstartup for MinGW from scratch
bjorn3 Jan 14, 2023
6f1e177
Introduce SysrootTarget
bjorn3 Jan 14, 2023
0ac4456
Move rtstartup build to build_clif_sysroot_for_triple
bjorn3 Jan 14, 2023
fd83b27
Port llvm sysroot building to SysrootTarget too and dedup some code
bjorn3 Jan 14, 2023
280dffd
Build rtstartup for none sysroot too
bjorn3 Jan 14, 2023
1319732
Skip creating sysroot target dir if it will be empty
bjorn3 Jan 14, 2023
abcff71
Significantly speed up assembling of sysroots
bjorn3 Jan 15, 2023
0f4df8f
Eliminate a couple of extra calls
bjorn3 Jan 15, 2023
611c518
Merge pull request #1341 from bjorn3/build_sysroot_cleanup
bjorn3 Jan 15, 2023
7095783
Only run abi-cafe on cg_clif's CI
bjorn3 Jan 16, 2023
08c7230
Move compiler input and ouput paths into session
oli-obk Dec 7, 2022
49a9438
Remove double spaces after dots in comments
WaffleLapkin Nov 16, 2022
739938d
Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petroche…
bors Jan 19, 2023
4e87f13
Fix a couple of TOCTOU occurences
bjorn3 Jan 19, 2023
954dfd1
Sync from rust 56ee85274e5a3a4dda92f3bf73d1664c74ff9c15
bjorn3 Jan 20, 2023
7d14e60
Rustup to rustc 1.68.0-nightly (4c83bd03a 2023-01-19)
bjorn3 Jan 20, 2023
92b4c76
Update rustup.sh for the moved dir of the sysroot source
bjorn3 Jan 20, 2023
fb6d048
Update patch
bjorn3 Jan 20, 2023
6c58be8
Fix rustc test suite
bjorn3 Jan 20, 2023
c6ad186
Use panic_nounwind and panic_cannot_unwind where necessary
bjorn3 Jan 20, 2023
219cdba
Fix clif ir writing for simd_gather
bjorn3 Jan 20, 2023
6eef214
Separate out abi-cafe runs into separate CI jobs
bjorn3 Jan 20, 2023
598f090
Update to Cranelift 0.92
bjorn3 Jan 7, 2023
b829bb7
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_…
bjorn3 Jan 24, 2023
ae3aa71
Update tidy for cranelift-egraph removal and new windows-sys targets
bjorn3 Jan 24, 2023
1578b1c
Vendor newer version of cranelift-native
bjorn3 Jan 25, 2023
3808bc4
Fix CI
bjorn3 Jan 25, 2023
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
Prev Previous commit
Next Next commit
Introduce SysrootTarget
  • Loading branch information
bjorn3 committed Jan 14, 2023
commit 6f1e1775d3586d0f82bd202de461e4de27a0fe1c
69 changes: 46 additions & 23 deletions build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fs;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::{self, Command};

use super::path::{Dirs, RelPath};
Expand Down Expand Up @@ -56,35 +56,40 @@ pub(crate) fn build_sysroot(
spawn_and_wait(build_cargo_wrapper_cmd);
}

let default_sysroot = super::rustc_info::get_default_sysroot(&bootstrap_host_compiler.rustc);

let host_rustlib_lib =
RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
let target_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(&target_triple).join("lib");
fs::create_dir_all(&host_rustlib_lib).unwrap();
fs::create_dir_all(&target_rustlib_lib).unwrap();

if target_triple.ends_with("windows-gnu") {
eprintln!("[BUILD] rtstartup for {target_triple}");

let rtstartup_src = SYSROOT_SRC.to_path(dirs).join("library").join("rtstartup");
let mut target_libs = SysrootTarget { triple: target_triple.clone(), libs: vec![] };

for file in ["rsbegin", "rsend"] {
let obj = RelPath::BUILD.to_path(dirs).join(format!("{file}.o"));
let mut build_rtstartup_cmd = Command::new(&bootstrap_host_compiler.rustc);
build_rtstartup_cmd
.arg("--target")
.arg(&target_triple)
.arg("--emit=obj")
.arg("-o")
.arg(target_rustlib_lib.join(format!("{file}.o")))
.arg(&obj)
.arg(rtstartup_src.join(format!("{file}.rs")));
spawn_and_wait(build_rtstartup_cmd);
target_libs.libs.push(obj);
}
}

target_libs.install_into_sysroot(&DIST_DIR.to_path(dirs))
}
match sysroot_kind {
SysrootKind::None => {} // Nothing to do
SysrootKind::Llvm => {
let default_sysroot =
super::rustc_info::get_default_sysroot(&bootstrap_host_compiler.rustc);

let host_rustlib_lib =
RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
let target_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(&target_triple).join("lib");
fs::create_dir_all(&host_rustlib_lib).unwrap();
fs::create_dir_all(&target_rustlib_lib).unwrap();

for file in fs::read_dir(
default_sysroot
.join("lib")
Expand Down Expand Up @@ -122,12 +127,13 @@ pub(crate) fn build_sysroot(
}
}
SysrootKind::Clif => {
build_clif_sysroot_for_triple(
let host = build_clif_sysroot_for_triple(
dirs,
channel,
bootstrap_host_compiler.clone(),
&cg_clif_dylib_path,
);
host.install_into_sysroot(&DIST_DIR.to_path(dirs));

if !is_native {
build_clif_sysroot_for_triple(
Expand All @@ -140,16 +146,16 @@ pub(crate) fn build_sysroot(
bootstrap_target_compiler
},
&cg_clif_dylib_path,
);
)
.install_into_sysroot(&DIST_DIR.to_path(dirs));
}

// Copy std for the host to the lib dir. This is necessary for the jit mode to find
// libstd.
for file in fs::read_dir(host_rustlib_lib).unwrap() {
let file = file.unwrap().path();
let filename = file.file_name().unwrap().to_str().unwrap();
for lib in host.libs {
let filename = lib.file_name().unwrap().to_str().unwrap();
if filename.contains("std-") && !filename.contains(".rlib") {
try_hard_link(&file, LIB_DIR.to_path(dirs).join(file.file_name().unwrap()));
try_hard_link(&lib, LIB_DIR.to_path(dirs).join(lib.file_name().unwrap()));
}
}
}
Expand All @@ -162,19 +168,36 @@ pub(crate) fn build_sysroot(
target_compiler
}

struct SysrootTarget {
triple: String,
libs: Vec<PathBuf>,
}

impl SysrootTarget {
fn install_into_sysroot(&self, sysroot: &Path) {
let target_rustlib_lib = sysroot.join("lib").join("rustlib").join(&self.triple).join("lib");
fs::create_dir_all(&target_rustlib_lib).unwrap();

for lib in &self.libs {
try_hard_link(lib, target_rustlib_lib.join(lib.file_name().unwrap()));
}
}
}

pub(crate) static ORIG_BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot");
pub(crate) static BUILD_SYSROOT: RelPath = RelPath::DOWNLOAD.join("sysroot");
pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = BUILD_SYSROOT.join("rustc_version");
pub(crate) static SYSROOT_SRC: RelPath = BUILD_SYSROOT.join("sysroot_src");
pub(crate) static STANDARD_LIBRARY: CargoProject =
CargoProject::new(&BUILD_SYSROOT, "build_sysroot");

#[must_use]
fn build_clif_sysroot_for_triple(
dirs: &Dirs,
channel: &str,
mut compiler: Compiler,
cg_clif_dylib_path: &Path,
) {
) -> SysrootTarget {
match fs::read_to_string(SYSROOT_RUSTC_VERSION.to_path(dirs)) {
Err(e) => {
eprintln!("Failed to get rustc version for patched sysroot source: {}", e);
Expand Down Expand Up @@ -219,7 +242,8 @@ fn build_clif_sysroot_for_triple(
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
spawn_and_wait(build_cmd);

// Copy all relevant files to the sysroot
let mut target_libs = SysrootTarget { triple: compiler.triple, libs: vec![] };

for entry in fs::read_dir(build_dir.join("deps")).unwrap() {
let entry = entry.unwrap();
if let Some(ext) = entry.path().extension() {
Expand All @@ -229,9 +253,8 @@ fn build_clif_sysroot_for_triple(
} else {
continue;
};
try_hard_link(
entry.path(),
RUSTLIB_DIR.to_path(dirs).join(&compiler.triple).join("lib").join(entry.file_name()),
);
target_libs.libs.push(entry.path());
}

target_libs
}