Skip to content

Commit

Permalink
Auto merge of rust-lang#127177 - bjorn3:arm64_macos_cg_clif, r=<try>
Browse files Browse the repository at this point in the history
Distribute rustc_codegen_cranelift for arm64 macOS

Support for arm64 macOS has been added to rustc_codegen_cranelift recently.

Based on rust-lang#127162

try-job: dist-aarch64-apple
  • Loading branch information
bors committed Jun 30, 2024
2 parents 6c34855 + 342b280 commit 02b5134
Show file tree
Hide file tree
Showing 24 changed files with 441 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ jobs:
if: matrix.os == 'macos-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-apple-darwin'
run: rustup set default-host x86_64-apple-darwin

- name: Select XCode version
if: matrix.os == 'macos-latest'
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app

- name: Prepare dependencies
run: ./y.sh prepare

Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ jobs:
env:
TARGET_TRIPLE: aarch64-unknown-linux-gnu
apt_deps: gcc-aarch64-linux-gnu qemu-user
- os: macos-latest
env:
TARGET_TRIPLE: aarch64-apple-darwin
- os: ubuntu-latest
env:
TARGET_TRIPLE: s390x-unknown-linux-gnu
Expand Down Expand Up @@ -108,10 +111,6 @@ jobs:
sudo apt-get update
sudo apt-get install -y ${{ matrix.apt_deps }}
- name: Select XCode version
if: matrix.os == 'macos-latest'
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app

- name: Prepare dependencies
run: ./y.sh prepare

Expand Down Expand Up @@ -214,6 +213,9 @@ jobs:
- os: macos-latest
env:
TARGET_TRIPLE: x86_64-apple-darwin
- os: macos-latest
env:
TARGET_TRIPLE: aarch64-apple-darwin
# cross-compile from Linux to Windows using mingw
- os: ubuntu-latest
env:
Expand Down Expand Up @@ -248,10 +250,6 @@ jobs:
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-x86-64
- name: Select XCode version
if: matrix.os == 'macos-latest'
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app

- name: Prepare dependencies
run: ./y.sh prepare

Expand Down Expand Up @@ -282,7 +280,8 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.ref == 'refs/heads/master' }}
needs: [rustfmt, test, bench, dist]
# FIXME add the bench job back to the dependency list once rust-lang/rust#125493 gets merged
needs: [rustfmt, test, dist]

permissions:
contents: write # for creating the dev tag and release
Expand Down
58 changes: 30 additions & 28 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b27922a6879b5b5361d0a084cb0b1941bf109a98540addcb932da13b68bed4"
checksum = "0b6b33d7e757a887989eb18b35712b2a67d96171ec3149d1bfb657b29b7b367c"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "304c455b28bf56372729acb356afbb55d622f2b0f2f7837aa5e57c138acaac4d"
checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa"
dependencies = [
"bumpalo",
"cranelift-bforest",
Expand All @@ -70,45 +70,46 @@ dependencies = [
"hashbrown 0.14.3",
"log",
"regalloc2",
"rustc-hash",
"smallvec",
"target-lexicon",
]

[[package]]
name = "cranelift-codegen-meta"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1653c56b99591d07f67c5ca7f9f25888948af3f4b97186bff838d687d666f613"
checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97"
dependencies = [
"cranelift-codegen-shared",
]

[[package]]
name = "cranelift-codegen-shared"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5b6a9cf6b6eb820ee3f973a0db313c05dc12d370f37b4fe9630286e1672573f"
checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da"

[[package]]
name = "cranelift-control"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9d06e6bf30075fb6bed9e034ec046475093392eea1aff90eb5c44c4a033d19a"
checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa"
dependencies = [
"arbitrary",
]

[[package]]
name = "cranelift-entity"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29be04f931b73cdb9694874a295027471817f26f26d2f0ebe5454153176b6e3a"
checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b"

[[package]]
name = "cranelift-frontend"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a07fd7393041d7faa2f37426f5dc7fc04003b70988810e8c063beefeff1cd8f9"
checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -118,15 +119,15 @@ dependencies = [

[[package]]
name = "cranelift-isle"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f341d7938caa6dff8149dac05bb2b53fc680323826b83b4cf175ab9f5139a3c9"
checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e"

[[package]]
name = "cranelift-jit"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42733555e06433f1461570e09dbd756dafc228b4dac75c597cdbdc518de07522"
checksum = "f5c5cfb8bbd3339cd25cca30e7516ff8fe5cb1feeddde6980cc4d5ef34df97bb"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -144,9 +145,9 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84950af02bb85f3da764d53a953b43bb29a732e793d4fe24637a61591be9a024"
checksum = "7c9b0d4269b36fd858e6d8f20cd4938941186fb831488c361888cb2d6b33a9a6"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -155,9 +156,9 @@ dependencies = [

[[package]]
name = "cranelift-native"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82af6066e6448d26eeabb7aa26a43f7ff79f8217b06bade4ee6ef230aecc8880"
checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -166,9 +167,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.107.0"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00af56107039ed150391df6f753298c7b08f2b6a2e0727d216b5fa599d684d8b"
checksum = "19e33439ec20db058bc7cc3410f9748ab1ad90a35cef713d625c736f43e3820d"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down Expand Up @@ -278,9 +279,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"

[[package]]
name = "object"
version = "0.33.0"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8dd6c0cdf9429bce006e1362bfce61fa1bfd8c898a643ed8d2b471934701d3d"
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce"
dependencies = [
"crc32fast",
"hashbrown 0.14.3",
Expand Down Expand Up @@ -410,10 +411,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wasmtime-jit-icache-coherence"
version = "20.0.0"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a9f93a3289057b26dc75eb84d6e60d7694f7d169c7c09597495de6e016a13ff"
checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91"
dependencies = [
"anyhow",
"cfg-if",
"libc",
"windows-sys",
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ crate-type = ["dylib"]

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

indexmap = "2.0.0"
libloading = { version = "0.8.0", optional = true }
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
|FreeBSD|[^no-rustup]||||
|AIX|[^xcoff]|N/A|N/A|[^xcoff]|
|Other unixes|||||
|macOS||[^apple-silicon]|N/A|N/A|
|macOS||[^no-rustup]|N/A|N/A|
|Windows|[^no-rustup]||N/A|N/A|

✅: Fully supported and tested
Expand All @@ -80,7 +80,6 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
Not all targets are available as rustup component for nightly. See notes in the platform support matrix.

[^xcoff]: XCOFF object file format is not supported.
[^apple-silicon]: Tracked in [#1248](https://github.com/rust-lang/rustc_codegen_cranelift/issues/1248).
[^no-rustup]: Not available as rustup component for nightly. You can build it yourself.

## Usage
Expand Down
35 changes: 0 additions & 35 deletions compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ fn build_clif_sysroot_for_triple(
prefix.to_str().unwrap()
));
}
rustflags.push("-Zunstable-options".to_owned());
for (name, values) in EXTRA_CHECK_CFGS {
rustflags.push(check_cfg_arg(name, *values));
}
compiler.rustflags.extend(rustflags);
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
if channel == "release" {
Expand Down Expand Up @@ -330,34 +326,3 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {

Some(target_libs)
}

// Copied from https://github.com/rust-lang/rust/blob/4fd98a4b1b100f5329c6efae18031791f64372d2/src/bootstrap/src/utils/helpers.rs#L569-L585
/// Create a `--check-cfg` argument invocation for a given name
/// and it's values.
fn check_cfg_arg(name: &str, values: Option<&[&str]>) -> String {
// Creating a string of the values by concatenating each value:
// ',values("tvos","watchos")' or '' (nothing) when there are no values.
let next = match values {
Some(values) => {
let mut tmp = values.iter().flat_map(|val| [",", "\"", val, "\""]).collect::<String>();

tmp.insert_str(1, "values(");
tmp.push(')');
tmp
}
None => "".to_string(),
};
format!("--check-cfg=cfg({name}{next})")
}

const EXTRA_CHECK_CFGS: &[(&str, Option<&[&str]>)] = &[
("bootstrap", None),
("stdarch_intel_sde", None),
("no_fp_fmt_parse", None),
("no_global_oom_handling", None),
("no_rc", None),
("no_sync", None),
("netbsd10", None),
("backtrace_in_libstd", None),
("target_arch", Some(&["xtensa"])),
];
36 changes: 4 additions & 32 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ pub(crate) fn run_tests(
struct TestRunner<'a> {
is_native: bool,
jit_supported: bool,
use_unstable_features: bool,
skip_tests: &'a [&'a str],
dirs: Dirs,
target_compiler: Compiler,
Expand Down Expand Up @@ -361,15 +360,7 @@ impl<'a> TestRunner<'a> {
&& target_compiler.triple.contains("x86_64")
&& !target_compiler.triple.contains("windows");

Self {
is_native,
jit_supported,
use_unstable_features,
skip_tests,
dirs,
target_compiler,
stdlib_source,
}
Self { is_native, jit_supported, skip_tests, dirs, target_compiler, stdlib_source }
}

fn run_testsuite(&self, tests: &[TestCase]) {
Expand All @@ -393,31 +384,13 @@ impl<'a> TestRunner<'a> {
match *cmd {
TestCaseCmd::Custom { func } => func(self),
TestCaseCmd::BuildLib { source, crate_types } => {
if self.use_unstable_features {
self.run_rustc([source, "--crate-type", crate_types]);
} else {
self.run_rustc([
source,
"--crate-type",
crate_types,
"--cfg",
"no_unstable_features",
]);
}
self.run_rustc([source, "--crate-type", crate_types]);
}
TestCaseCmd::BuildBin { source } => {
if self.use_unstable_features {
self.run_rustc([source]);
} else {
self.run_rustc([source, "--cfg", "no_unstable_features"]);
}
self.run_rustc([source]);
}
TestCaseCmd::BuildBinAndRun { source, args } => {
if self.use_unstable_features {
self.run_rustc([source]);
} else {
self.run_rustc([source, "--cfg", "no_unstable_features"]);
}
self.run_rustc([source]);
self.run_out_command(
source.split('/').last().unwrap().split('.').next().unwrap(),
args,
Expand Down Expand Up @@ -472,7 +445,6 @@ impl<'a> TestRunner<'a> {
cmd.arg(&self.target_compiler.triple);
cmd.arg("-Cpanic=abort");
cmd.arg("-Zunstable-options");
cmd.arg("--check-cfg=cfg(no_unstable_features)");
cmd.arg("--check-cfg=cfg(jit)");
cmd.args(args);
cmd
Expand Down
Loading

0 comments on commit 02b5134

Please sign in to comment.