From c9b0075563bc43181469ec34a60f5f05b31a2d2c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 30 Jun 2024 17:09:46 +0000 Subject: [PATCH 01/42] Distribute rustc_codegen_cranelift for arm64 macOS --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index eb21e027dd0e0..3b3c86a1bd17b 100644 --- a/Readme.md +++ b/Readme.md @@ -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|✅|✅[^no-rustup]|N/A|N/A| +|macOS|✅|✅|N/A|N/A| |Windows|✅[^no-rustup]|❌|N/A|N/A| ✅: Fully supported and tested From 322c2f6b1373a71e99e291f2be6f2c9b82890a02 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:31:43 +0000 Subject: [PATCH 02/42] Sync ar_archive_writer to LLVM 18.1.3 From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files. --- src/archive.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 414d3db1c51a1..26db93a75795a 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; use rustc_codegen_ssa::back::archive::{ - get_native_object_symbols, ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, + ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER, }; use rustc_session::Session; @@ -9,7 +9,7 @@ pub(crate) struct ArArchiveBuilderBuilder; impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box { - Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols)) + Box::new(ArArchiveBuilder::new(sess, &DEFAULT_OBJECT_READER)) } fn create_dll_import_lib( From d0d2e608865f3c8d624f23d552532574b00780dd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:39:03 +0000 Subject: [PATCH 03/42] Merge commit '659243d85c7489412bd0faa1c068d904a6042941' into sync_cg_clif-2024-07-13 --- Cargo.lock | 94 +++++++++++++++++----------------- rust-toolchain | 2 +- scripts/test_rustc_tests.sh | 4 +- src/abi/mod.rs | 1 - src/archive.rs | 4 +- src/constant.rs | 36 +++++++++++-- src/debuginfo/object.rs | 8 ++- src/intrinsics/llvm.rs | 20 +------- src/intrinsics/llvm_aarch64.rs | 1 - src/intrinsics/llvm_x86.rs | 1 - 10 files changed, 94 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15c9e9d66fac2..efec5db836bb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -67,7 +67,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "log", "regalloc2", "rustc-hash", @@ -182,9 +182,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -203,9 +203,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" dependencies = [ "fallible-iterator", "indexmap", @@ -223,9 +223,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", ] @@ -237,20 +237,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", "windows-targets", @@ -258,9 +258,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "mach" @@ -273,9 +273,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "object" @@ -284,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "crc32fast", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "indexmap", "memchr", ] @@ -297,9 +297,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -382,9 +382,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "2.0.60" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", @@ -393,9 +393,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "unicode-ident" @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -470,66 +470,66 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", diff --git a/rust-toolchain b/rust-toolchain index cfa91744a0e8d..db9b551bd2a25 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-06-30" +channel = "nightly-2024-07-13" components = ["rust-src", "rustc-dev", "llvm-tools"] diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index c1b7e4b0e0768..f0550c23b177f 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -34,6 +34,7 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR # vendor intrinsics rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic +rm tests/ui/simd/dont-invalid-bitcast-x86_64.rs # unimplemented llvm.x86.sse41.round.ps # exotic linkages rm tests/incremental/hashes/function_interfaces.rs @@ -56,13 +57,13 @@ rm -r tests/run-make/target-specs # i686 not supported by Cranelift rm -r tests/run-make/mismatching-target-triples # same rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported +rm tests/ui/simd/simd-bitmask-notpow2.rs # non-pow-of-2 simd vector sizes # requires LTO rm -r tests/run-make/cdylib rm -r tests/run-make/codegen-options-parsing rm -r tests/run-make/lto-* rm -r tests/run-make/reproducible-build-2 -rm -r tests/run-make/issue-109934-lto-debuginfo rm -r tests/run-make/no-builtins-lto rm -r tests/run-make/reachable-extern-fn-available-lto @@ -109,6 +110,7 @@ rm -r tests/run-make/symbols-include-type-name rm -r tests/run-make/notify-all-emit-artifacts rm -r tests/run-make/reset-codegen-1 rm -r tests/run-make/inline-always-many-cgu +rm -r tests/run-make/intrinsic-unreachable # giving different but possibly correct results # ============================================= diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 9dc94ab33ea9e..fa0de6f9de5ea 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -395,7 +395,6 @@ pub(crate) fn codegen_terminator_call<'tcx>( crate::intrinsics::codegen_llvm_intrinsic_call( fx, &fx.tcx.symbol_name(instance).name, - fn_args, args, ret_place, target, diff --git a/src/archive.rs b/src/archive.rs index 414d3db1c51a1..3f23e0d9e046b 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -14,12 +14,12 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { fn create_dll_import_lib( &self, - _sess: &Session, + sess: &Session, _lib_name: &str, _dll_imports: &[rustc_session::cstore::DllImport], _tmpdir: &Path, _is_direct_dependency: bool, ) -> PathBuf { - unimplemented!("creating dll imports is not yet supported"); + sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift"); } } diff --git a/src/constant.rs b/src/constant.rs index fd34ed88c0b28..0ba163f50aec5 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -385,15 +385,43 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant if let Some(section_name) = section_name { let (segment_name, section_name) = if tcx.sess.target.is_like_osx { - let section_name = section_name.as_str(); - if let Some(names) = section_name.split_once(',') { - names - } else { + // See https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCSectionMachO.cpp + let mut parts = section_name.as_str().split(','); + let Some(segment_name) = parts.next() else { tcx.dcx().fatal(format!( "#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma", section_name )); + }; + let Some(section_name) = parts.next() else { + tcx.dcx().fatal(format!( + "#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma", + section_name + )); + }; + if section_name.len() > 16 { + tcx.dcx().fatal(format!( + "#[link_section = \"{}\"] is not valid for macos target: section name bigger than 16 bytes", + section_name + )); + } + let section_type = parts.next().unwrap_or("regular"); + if section_type != "regular" && section_type != "cstring_literals" { + tcx.dcx().fatal(format!( + "#[link_section = \"{}\"] is not supported: unsupported section type {}", + section_name, section_type, + )); + } + let _attrs = parts.next(); + if parts.next().is_some() { + tcx.dcx().fatal(format!( + "#[link_section = \"{}\"] is not valid for macos target: too many components", + section_name + )); } + // FIXME(bytecodealliance/wasmtime#8901) set S_CSTRING_LITERALS section type when + // cstring_literals is specified + (segment_name, section_name) } else { ("", section_name.as_str()) }; diff --git a/src/debuginfo/object.rs b/src/debuginfo/object.rs index 65f4c67b21f13..1c6e471cc870f 100644 --- a/src/debuginfo/object.rs +++ b/src/debuginfo/object.rs @@ -39,7 +39,13 @@ impl WriteDebugInfo for ObjectProduct { let section_id = self.object.add_section( segment, name, - if id == SectionId::EhFrame { SectionKind::ReadOnlyData } else { SectionKind::Debug }, + if id == SectionId::DebugStr || id == SectionId::DebugLineStr { + SectionKind::DebugString + } else if id == SectionId::EhFrame { + SectionKind::ReadOnlyData + } else { + SectionKind::Debug + }, ); self.object .section_mut(section_id) diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index e50c74b87f603..720a0d8fbf593 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -6,32 +6,16 @@ use crate::prelude::*; pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, '_, 'tcx>, intrinsic: &str, - generic_args: GenericArgsRef<'tcx>, args: &[Spanned>], ret: CPlace<'tcx>, target: Option, span: Span, ) { if intrinsic.starts_with("llvm.aarch64") { - return llvm_aarch64::codegen_aarch64_llvm_intrinsic_call( - fx, - intrinsic, - generic_args, - args, - ret, - target, - ); + return llvm_aarch64::codegen_aarch64_llvm_intrinsic_call(fx, intrinsic, args, ret, target); } if intrinsic.starts_with("llvm.x86") { - return llvm_x86::codegen_x86_llvm_intrinsic_call( - fx, - intrinsic, - generic_args, - args, - ret, - target, - span, - ); + return llvm_x86::codegen_x86_llvm_intrinsic_call(fx, intrinsic, args, ret, target, span); } match intrinsic { diff --git a/src/intrinsics/llvm_aarch64.rs b/src/intrinsics/llvm_aarch64.rs index e66bcbf4e40e5..f0fb18608e072 100644 --- a/src/intrinsics/llvm_aarch64.rs +++ b/src/intrinsics/llvm_aarch64.rs @@ -6,7 +6,6 @@ use crate::prelude::*; pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, '_, 'tcx>, intrinsic: &str, - _args: GenericArgsRef<'tcx>, args: &[Spanned>], ret: CPlace<'tcx>, target: Option, diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index 399518e58d8c5..e1896138e487b 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -10,7 +10,6 @@ use crate::prelude::*; pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, '_, 'tcx>, intrinsic: &str, - _args: GenericArgsRef<'tcx>, args: &[Spanned>], ret: CPlace<'tcx>, target: Option, From 5203b7e10d05e3e57ada5406d99950d44d847a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 14 Jul 2024 16:59:06 +0200 Subject: [PATCH 04/42] Set rustup profile to minimal (#1516) --- .github/workflows/audit.yml | 1 - .github/workflows/main.yml | 1 - rust-toolchain | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index b4f8ce0f5329d..27c95572ef879 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -13,7 +13,6 @@ jobs: - uses: actions/checkout@v4 - run: | sed -i 's/components.*/components = []/' rust-toolchain - echo 'profile = "minimal"' >> rust-toolchain - uses: rustsec/audit-check@v1.4.1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2ae3d63fb907..896a5c34c3eff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,6 @@ jobs: - name: Avoid installing rustc-dev run: | sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain - echo 'profile = "minimal"' >> rust-toolchain rustfmt -v - name: Rustfmt diff --git a/rust-toolchain b/rust-toolchain index db9b551bd2a25..2478a9bbccee9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] channel = "nightly-2024-07-13" components = ["rust-src", "rustc-dev", "llvm-tools"] +profile = "minimal" From c01fe3ceac9726b9c79f79efcd694ee5b32cbe29 Mon Sep 17 00:00:00 2001 From: Mohammad Omidvar Date: Mon, 15 Jul 2024 23:43:52 +0000 Subject: [PATCH 05/42] Move compiler_builtin check to the use case --- src/abi/mod.rs | 2 +- src/base.rs | 2 +- src/lib.rs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index fa0de6f9de5ea..698981ae1536d 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -10,12 +10,12 @@ use std::mem; use cranelift_codegen::ir::{ArgumentPurpose, SigRef}; use cranelift_codegen::isa::CallConv; use cranelift_module::ModuleError; +use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::TypeVisitableExt; -use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_session::Session; use rustc_span::source_map::Spanned; use rustc_target::abi::call::{Conv, FnAbi, PassMode}; diff --git a/src/base.rs b/src/base.rs index 5adbbb09ac85f..9bc7b57c53745 100644 --- a/src/base.rs +++ b/src/base.rs @@ -5,13 +5,13 @@ use cranelift_codegen::CodegenError; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use cranelift_module::ModuleError; use rustc_ast::InlineAsmOptions; +use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_index::IndexVec; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::TypeVisitableExt; -use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization; use crate::constant::ConstantCx; use crate::debuginfo::{FunctionDebugContext, TypeDebugContext}; diff --git a/src/lib.rs b/src/lib.rs index 192e6c91ea38b..8d3d5ac98e1e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,6 @@ extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; extern crate rustc_metadata; -extern crate rustc_monomorphize; extern crate rustc_session; extern crate rustc_span; extern crate rustc_target; From 580cdfa6a7a9513b9185b404e346cf7f0e1a6c85 Mon Sep 17 00:00:00 2001 From: "Chai T. Rex" Date: Tue, 16 Jul 2024 10:01:35 -0400 Subject: [PATCH 06/42] Added project-specific Zed IDE settings Created `.zed/settings.json` with all the settings from `.vscode/settings.json`. --- .zed/settings.json | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .zed/settings.json diff --git a/.zed/settings.json b/.zed/settings.json new file mode 100644 index 0000000000000..e93bed3694921 --- /dev/null +++ b/.zed/settings.json @@ -0,0 +1,68 @@ +{ + "format_on_save": "on", + "lsp": { + "rust-analyzer": { + "initialization_options": { + "diagnostics": { + // in case rustc.source is disabled for performance reasons; disable the errors about this + "disabled": ["unresolved-extern-crate", "unresolved-macro-call"] + }, + "rustc": { + "source": "discover" + }, + "imports": { + "granularity": { + "enforce": true, + "group": "module" + }, + "prefix": "crate" + }, + "cargo": { + "features": ["unstable-features"] + }, + "linkedProjects": [ + "./Cargo.toml", + "./build_system/Cargo.toml", + { + "crates": [ + { + "root_module": "./example/mini_core.rs", + "edition": "2018", + "deps": [], + "cfg": [] + }, + { + "root_module": "./example/mini_core_hello_world.rs", + "edition": "2018", + "deps": [ + { + "crate": 0, + "name": "mini_core" + } + ], + "cfg": [] + }, + { + "root_module": "./example/mod_bench.rs", + "edition": "2018", + "deps": [], + "cfg": [] + } + ] + }, + { + "sysroot_src": "./build/stdlib/library", + "crates": [ + { + "root_module": "./example/std_example.rs", + "edition": "2015", + "deps": [], + "cfg": [] + } + ] + } + ] + } + } + } +} From c1c13bd07ca476c0d9b53b0fa1384ea8a83962e3 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 19 Jul 2024 11:51:21 -0400 Subject: [PATCH 07/42] Avoid ref when using format! in compiler Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse. --- src/abi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index fa0de6f9de5ea..ac5aaea561cca 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -505,7 +505,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment( nop_inst, - format!("virtual call; self arg pass mode: {:?}", &fn_abi.args[0]), + format!("virtual call; self arg pass mode: {:?}", fn_abi.args[0]), ); } From b929b68a5ba4570e15637b12d9e687a2ba6673d8 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 20 Jul 2024 15:26:46 +0200 Subject: [PATCH 08/42] Remove the RUSTFLAGS enable method from Readme.md It is a worse option than using `CARGO_PROFILE_DEV_CODEGEN_BACKEND`. When using `--target` it doesn't apply to build scripts and proc macros. It also overrides any `RUSTFLAGS` you may have set in an env var or cargo config. --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index eb21e027dd0e0..29050e8b5b4f2 100644 --- a/Readme.md +++ b/Readme.md @@ -16,7 +16,6 @@ $ rustup component add rustc-codegen-cranelift-preview --toolchain nightly Once it is installed, you can enable it with one of the following approaches: - `CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly build -Zcodegen-backend` -- `RUSTFLAGS="-Zcodegen-backend=cranelift" cargo +nightly build` - Add the following to `.cargo/config.toml`: ```toml [unstable] From b70ad2defd4bb5fba6af7958893e22be0f33dfdd Mon Sep 17 00:00:00 2001 From: beetrees Date: Sat, 20 Jul 2024 17:03:35 +0100 Subject: [PATCH 09/42] Remove unneeded libcalls from `codegen_i128.rs` --- src/codegen_i128.rs | 27 ++++----------------------- src/compiler_builtins.rs | 6 ------ 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index e16b77648d12f..b6a4769e03114 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -23,19 +23,7 @@ pub(crate) fn maybe_codegen<'tcx>( match bin_op { BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => None, BinOp::Add | BinOp::AddUnchecked | BinOp::Sub | BinOp::SubUnchecked => None, - BinOp::Mul | BinOp::MulUnchecked => { - let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)]; - let ret_val = fx.lib_call( - "__multi3", - vec![AbiParam::new(types::I128), AbiParam::new(types::I128)], - vec![AbiParam::new(types::I128)], - &args, - )[0]; - Some(CValue::by_val( - ret_val, - fx.layout_of(if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }), - )) - } + BinOp::Mul | BinOp::MulUnchecked => None, BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Div | BinOp::Rem => { let name = match (bin_op, is_signed) { @@ -92,6 +80,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>( match bin_op { BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => unreachable!(), + BinOp::Add | BinOp::Sub => None, BinOp::Mul if is_signed => { let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]); let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32)); @@ -112,7 +101,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>( let oflow = fx.bcx.ins().ireduce(types::I8, oflow); Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty))) } - BinOp::Add | BinOp::Sub | BinOp::Mul => { + BinOp::Mul => { let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]); let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty)); let param_types = vec![ @@ -121,15 +110,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>( AbiParam::new(types::I128), ]; let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)]; - let name = match (bin_op, is_signed) { - (BinOp::Add, false) => "__rust_u128_addo", - (BinOp::Add, true) => "__rust_i128_addo", - (BinOp::Sub, false) => "__rust_u128_subo", - (BinOp::Sub, true) => "__rust_i128_subo", - (BinOp::Mul, false) => "__rust_u128_mulo", - _ => unreachable!(), - }; - fx.lib_call(name, param_types, vec![], &args); + fx.lib_call("__rust_u128_mulo", param_types, vec![], &args); Some(out_place.to_cvalue(fx)) } BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(), diff --git a/src/compiler_builtins.rs b/src/compiler_builtins.rs index f3b963200a0fb..4154a62234c12 100644 --- a/src/compiler_builtins.rs +++ b/src/compiler_builtins.rs @@ -38,18 +38,12 @@ builtin_functions! { register_functions_for_jit; // integers - fn __multi3(a: i128, b: i128) -> i128; fn __muloti4(n: i128, d: i128, oflow: &mut i32) -> i128; fn __udivti3(n: u128, d: u128) -> u128; fn __divti3(n: i128, d: i128) -> i128; fn __umodti3(n: u128, d: u128) -> u128; fn __modti3(n: i128, d: i128) -> i128; - fn __rust_u128_addo(a: u128, b: u128) -> (u128, bool); - fn __rust_i128_addo(a: i128, b: i128) -> (i128, bool); - fn __rust_u128_subo(a: u128, b: u128) -> (u128, bool); - fn __rust_i128_subo(a: i128, b: i128) -> (i128, bool); fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool); - fn __rust_i128_mulo(a: i128, b: i128) -> (i128, bool); // floats fn __floattisf(i: i128) -> f32; From 4fb3c4bf863f2ab32fee13405f71b6785763e909 Mon Sep 17 00:00:00 2001 From: beetrees Date: Sun, 21 Jul 2024 12:13:58 +0100 Subject: [PATCH 10/42] Fix handling of large alignments in `write_cvalue_maybe_transmute` (#1521) --- src/value_and_place.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 1aa28daeafc7e..8eb2095e52346 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -677,8 +677,10 @@ impl<'tcx> CPlace<'tcx> { let to_addr = to_ptr.get_addr(fx); let src_layout = from.1; let size = dst_layout.size.bytes(); - let src_align = src_layout.align.abi.bytes() as u8; - let dst_align = dst_layout.align.abi.bytes() as u8; + // `emit_small_memory_copy` uses `u8` for alignments, just use the maximum + // alignment that fits in a `u8` if the actual alignment is larger. + let src_align = src_layout.align.abi.bytes().try_into().unwrap_or(128); + let dst_align = dst_layout.align.abi.bytes().try_into().unwrap_or(128); fx.bcx.emit_small_memory_copy( fx.target_config, to_addr, From 486f5b50599b7e73f4488d7291e106e6c057c869 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Mon, 24 Jun 2024 16:17:59 +0100 Subject: [PATCH 11/42] Use Cow<'static, str> for InlineAsmTemplatePiece::String --- src/inline_asm.rs | 4 +--- src/intrinsics/llvm_x86.rs | 42 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index c88230c936056..16edec47e1029 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -46,9 +46,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( // Used by panic_abort on Windows, but uses a syntax which only happens to work with // asm!() by accident and breaks with the GNU assembler as well as global_asm!() for // the LLVM backend. - if template.len() == 1 - && template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) - { + if template.len() == 1 && template[0] == InlineAsmTemplatePiece::String("int $$0x29".into()) { fx.bcx.ins().trap(TrapCode::User(1)); return; } diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index e1896138e487b..a20faa2cad3a8 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -40,7 +40,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( shl rdx, 32 or rax, rdx " - .to_string(), + .into(), )], &[ CInlineAsmOperand::In { @@ -471,7 +471,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( // into 0x80000000 for which Cranelift doesn't have a native instruction. codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("cvtps2dq xmm0, xmm0"))], + &[InlineAsmTemplatePiece::String("cvtps2dq xmm0, xmm0".into())], &[CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), _late: true, @@ -875,7 +875,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(asm.to_string())], + &[InlineAsmTemplatePiece::String(asm.into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::ax)), @@ -914,7 +914,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("pcmpestri xmm0, xmm1, {imm8}"))], + &[InlineAsmTemplatePiece::String(format!("pcmpestri xmm0, xmm1, {imm8}").into())], &[ CInlineAsmOperand::In { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -967,7 +967,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("pcmpestrm xmm0, xmm1, {imm8}"))], + &[InlineAsmTemplatePiece::String(format!("pcmpestrm xmm0, xmm1, {imm8}").into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1015,7 +1015,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("pclmulqdq xmm0, xmm1, {imm8}"))], + &[InlineAsmTemplatePiece::String(format!("pclmulqdq xmm0, xmm1, {imm8}").into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1052,7 +1052,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("aeskeygenassist xmm0, xmm0, {imm8}"))], + &[InlineAsmTemplatePiece::String( + format!("aeskeygenassist xmm0, xmm0, {imm8}").into(), + )], &[CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), _late: true, @@ -1071,7 +1073,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("aesimc xmm0, xmm0".to_string())], + &[InlineAsmTemplatePiece::String("aesimc xmm0, xmm0".into())], &[CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), _late: true, @@ -1091,7 +1093,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("aesenc xmm0, xmm1".to_string())], + &[InlineAsmTemplatePiece::String("aesenc xmm0, xmm1".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1117,7 +1119,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("aesenclast xmm0, xmm1".to_string())], + &[InlineAsmTemplatePiece::String("aesenclast xmm0, xmm1".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1143,7 +1145,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("aesdec xmm0, xmm1".to_string())], + &[InlineAsmTemplatePiece::String("aesdec xmm0, xmm1".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1169,7 +1171,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("aesdeclast xmm0, xmm1".to_string())], + &[InlineAsmTemplatePiece::String("aesdeclast xmm0, xmm1".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), @@ -1207,7 +1209,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String(format!("sha1rnds4 xmm1, xmm2, {func}"))], + &[InlineAsmTemplatePiece::String(format!("sha1rnds4 xmm1, xmm2, {func}").into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1233,7 +1235,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha1msg1 xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha1msg1 xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1259,7 +1261,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha1msg2 xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha1msg2 xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1285,7 +1287,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha1nexte xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha1nexte xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1312,7 +1314,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha256rnds2 xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha256rnds2 xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1343,7 +1345,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha256msg1 xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha256msg1 xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1369,7 +1371,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("sha256msg2 xmm1, xmm2".to_string())], + &[InlineAsmTemplatePiece::String("sha256msg2 xmm1, xmm2".into())], &[ CInlineAsmOperand::InOut { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm1)), @@ -1435,7 +1437,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( let edx_place = res_place.place_field(fx, FieldIdx::new(1)); codegen_inline_asm_inner( fx, - &[InlineAsmTemplatePiece::String("rdtsc".to_string())], + &[InlineAsmTemplatePiece::String("rdtsc".into())], &[ CInlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::ax)), From b2e612f204e62f0d4dfb5bb4ec1b609b513bb420 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:35:53 +0000 Subject: [PATCH 12/42] Update Cranelift to 0.110.1 --- Cargo.lock | 62 +++++++++++++++++++++++++++++++----------------------- Cargo.toml | 12 +++++------ 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efec5db836bb1..b065720c9ce11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,21 +46,28 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6b33d7e757a887989eb18b35712b2a67d96171ec3149d1bfb657b29b7b367c" +checksum = "effa84ab2023f7138045ece6b326588c17447ca22e66db71ec15cb0a6c0c4ad2" dependencies = [ "cranelift-entity", ] +[[package]] +name = "cranelift-bitset" +version = "0.110.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a1dfc50dca188a15d938867c4400589530bcb0138f7022aae6d059d1d8c309" + [[package]] name = "cranelift-codegen" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa" +checksum = "821c20c639350158ecca928dc2a244d0d1c9cef2377a378fc62a445a286eb1ca" dependencies = [ "bumpalo", "cranelift-bforest", + "cranelift-bitset", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-control", @@ -77,39 +84,42 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97" +checksum = "064473f2fd59b44fa2c9aaa60de1f9c44db5e13521e28bc85d2b92ee535ef625" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da" +checksum = "d0f39b9ebfd2febdc2acfb9a0fca110665bcd5a6839502576307735ed07b2177" [[package]] name = "cranelift-control" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa" +checksum = "94e125c189c3a1ca8dfe209fc6f46edba058a6d24e0b92aff69459a15f4711e7" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b" +checksum = "ea62eb109baec2247e1a6fa7b74c0f584b1e76e289cfd7017385b4b031fc8450" +dependencies = [ + "cranelift-bitset", +] [[package]] name = "cranelift-frontend" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5" +checksum = "722b089357aacb6c7528b2e59a5fe00917d61ce63448b25a3e477a5b7819fac8" dependencies = [ "cranelift-codegen", "log", @@ -119,15 +129,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e" +checksum = "c4b5005a48288e7fc2a2991a377831c534e26929b063c379c018060727785a9b" [[package]] name = "cranelift-jit" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c5cfb8bbd3339cd25cca30e7516ff8fe5cb1feeddde6980cc4d5ef34df97bb" +checksum = "f843932baf8d1025c5f114b929eda172d74b7163d058e0de2597c308b567c7e9" dependencies = [ "anyhow", "cranelift-codegen", @@ -145,9 +155,9 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c9b0d4269b36fd858e6d8f20cd4938941186fb831488c361888cb2d6b33a9a6" +checksum = "449819ef1c4af139cf1b9717916fcaea0e23248853d3e95135139773a842d3eb" dependencies = [ "anyhow", "cranelift-codegen", @@ -156,9 +166,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581" +checksum = "3ae2d48f38081a9e679ad795bd36bb29bedeb5552fc1c195185bf9885fa1b16e" dependencies = [ "cranelift-codegen", "libc", @@ -167,9 +177,9 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.109.0" +version = "0.110.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e33439ec20db058bc7cc3410f9748ab1ad90a35cef713d625c736f43e3820d" +checksum = "3a39ee2cfd0ec485eca76f6b4dc17701a280fa406bc05137bb43f1635ed12c9f" dependencies = [ "anyhow", "cranelift-codegen", @@ -411,9 +421,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasmtime-jit-icache-coherence" -version = "22.0.0" +version = "23.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91" +checksum = "7fddf3e2980fb1d123d1fcac55189e417fdd3dba4f62139b5a0a1f9efe5669d5" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 2969a6cf6ecaa..a0df502dadc47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,12 +8,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -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" } +cranelift-codegen = { version = "0.110.1", default-features = false, features = ["std", "unwind", "all-arch"] } +cranelift-frontend = { version = "0.110.1" } +cranelift-module = { version = "0.110.1" } +cranelift-native = { version = "0.110.1" } +cranelift-jit = { version = "0.110.1", optional = true } +cranelift-object = { version = "0.110.1" } target-lexicon = "0.12.0" gimli = { version = "0.28", default-features = false, features = ["write"]} object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } From d7683597166371d9370d3f196434ea69733c80e5 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:16:41 +0000 Subject: [PATCH 13/42] Rustup to rustc 1.82.0-nightly (c1a6199e9 2024-07-24) --- patches/stdlib-lock.toml | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/stdlib-lock.toml b/patches/stdlib-lock.toml index 9ea53e8f848d9..1c1f81844c3de 100644 --- a/patches/stdlib-lock.toml +++ b/patches/stdlib-lock.toml @@ -252,9 +252,9 @@ dependencies = [ [[package]] name = "r-efi" -version = "4.3.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e244f96e03a3067f9e521d3167bd42657594cb8588c8d3a2db01545dc1af2e0" +checksum = "e9e935efc5854715dfc0a4c9ef18dc69dee0ec3bf9cc3ab740db831c0fdd86a3" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", diff --git a/rust-toolchain b/rust-toolchain index 2478a9bbccee9..800ac0a1ed064 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-07-13" +channel = "nightly-2024-07-25" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From 39bc103817ba5d7826a3d6183025bf0aa24a6fe9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:17:24 +0000 Subject: [PATCH 14/42] Fix rustc test suite --- scripts/test_rustc_tests.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index f0550c23b177f..735762b389cfb 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -134,6 +134,8 @@ rm tests/ui/deprecation/deprecated_inline_threshold.rs # missing deprecation war # bugs in the test suite # ====================== rm tests/ui/process/nofile-limit.rs # TODO some AArch64 linking issue +rm tests/ui/backtrace/synchronized-panic-handler.rs # missing needs-unwind annotation +rm -r tests/ui/codegen/equal-pointers-unequal # make incorrect assumptions about the location of stack variables rm tests/ui/stdio-is-blocking.rs # really slow with unoptimized libstd @@ -157,8 +159,8 @@ index ea06b620c4c..b969d0009c6 100644 RUSTDOC := \$(RUSTDOC) -Clinker='\$(RUSTC_LINKER)' diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index 9607ff02f96..b7d97caf9a2 100644 ---- a/src/tools/run-make-support/src/rustdoc.rs -+++ b/src/tools/run-make-support/src/rustdoc.rs +--- a/src/tools/run-make-support/src/external_deps/rustdoc.rs ++++ b/src/tools/run-make-support/src/external_deps/rustdoc.rs @@ -34,8 +34,6 @@ pub fn bare() -> Self { #[track_caller] pub fn new() -> Self { From 68b99fcb9148c48d30a385ba72e34cc0aa6e94a9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:22:59 +0000 Subject: [PATCH 15/42] Rustup to rustc 1.82.0-nightly (7c2012d0e 2024-07-26) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 800ac0a1ed064..f719dc441a5ea 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-07-25" +channel = "nightly-2024-07-27" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From 62a0c22ca9deaa1bcaaf688641b594d2b126e4af Mon Sep 17 00:00:00 2001 From: Slanterns Date: Sun, 28 Jul 2024 01:28:39 +0800 Subject: [PATCH 16/42] stabilize `is_sorted` --- example/std_example.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/example/std_example.rs b/example/std_example.rs index 6cedd84adfe52..e99763e272233 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,7 +3,6 @@ coroutines, stmt_expr_attributes, coroutine_trait, - is_sorted, repr_simd, tuple_trait, unboxed_closures From b00404e1a1c5696e432d43086700e22c4fb7bcfa Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 13 Jun 2024 09:16:09 +1000 Subject: [PATCH 17/42] Update `use` declarations formatting options. As decided in rust-lang/compiler-team#750. Use declarations are currently wildly inconsistent because rustfmt is quite unopinionated about how they should be formatted. The `rustfmt.toml` additions makes rustfmt more opinionated, which avoids the need for any decision when adding new use declarations to a file. This commit only updates `rustfmt.toml` and `compiler/rustc_codegen_cranelift/rustfmt.toml`. The next commit will do the reformatting. --- rustfmt.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rustfmt.toml b/rustfmt.toml index 6f4d4413c25d0..d9e6ac3d543c9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,3 +6,5 @@ ignore = [ version = "Two" use_small_heuristics = "Max" merge_derives = false +group_imports = "StdExternalCrate" +imports_granularity = "Module" From ea9f491696d9b39e9a6c4942ce7ef973ad36a271 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 29 Jul 2024 08:13:50 +1000 Subject: [PATCH 18/42] Reformat `use` declarations. The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options. --- build_system/abi_cafe.rs | 3 +-- build_system/build_sysroot.rs | 3 +-- build_system/config.rs | 3 +-- build_system/main.rs | 3 +-- build_system/tests.rs | 4 +--- build_system/utils.rs | 4 +--- example/alloc_system.rs | 5 +++-- example/arbitrary_self_types_pointers_and_wrappers.rs | 6 ++---- src/debuginfo/unwind.rs | 3 ++- src/driver/aot.rs | 8 +++++--- src/driver/jit.rs | 4 ++-- src/lib.rs | 5 ++--- src/main_shim.rs | 3 +-- src/optimize/peephole.rs | 3 ++- 14 files changed, 25 insertions(+), 32 deletions(-) diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index ecf303c30b6c3..75f9f233cb33d 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -1,8 +1,7 @@ -use crate::build_sysroot; use crate::path::Dirs; use crate::prepare::GitRepo; use crate::utils::{spawn_and_wait, CargoProject, Compiler}; -use crate::{CodegenBackend, SysrootKind}; +use crate::{build_sysroot, CodegenBackend, SysrootKind}; static ABI_CAFE_REPO: GitRepo = GitRepo::github( "Gankra", diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index dfbe0f51e7be2..5e9967aaeb1eb 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -1,7 +1,6 @@ -use std::env; -use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; +use std::{env, fs}; use crate::path::{Dirs, RelPath}; use crate::rustc_info::get_file_name; diff --git a/build_system/config.rs b/build_system/config.rs index c31784e1097dc..ef540cf1f822b 100644 --- a/build_system/config.rs +++ b/build_system/config.rs @@ -1,5 +1,4 @@ -use std::fs; -use std::process; +use std::{fs, process}; fn load_config_file() -> Vec<(String, Option)> { fs::read_to_string("config.txt") diff --git a/build_system/main.rs b/build_system/main.rs index 7dbf608f991e4..9ddeda583afd1 100644 --- a/build_system/main.rs +++ b/build_system/main.rs @@ -2,9 +2,8 @@ #![warn(unused_lifetimes)] #![warn(unreachable_pub)] -use std::env; use std::path::PathBuf; -use std::process; +use std::{env, process}; use self::utils::Compiler; diff --git a/build_system/tests.rs b/build_system/tests.rs index 790d9cbd9fc59..afc8a923863a2 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -3,14 +3,12 @@ use std::fs; use std::path::PathBuf; use std::process::Command; -use crate::build_sysroot; -use crate::config; use crate::path::{Dirs, RelPath}; use crate::prepare::{apply_patches, GitRepo}; use crate::rustc_info::get_default_sysroot; use crate::shared_utils::rustflags_from_env; use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup}; -use crate::{CodegenBackend, SysrootKind}; +use crate::{build_sysroot, config, CodegenBackend, SysrootKind}; static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example"); diff --git a/build_system/utils.rs b/build_system/utils.rs index 9f95122b341c5..3c4b45e02cc25 100644 --- a/build_system/utils.rs +++ b/build_system/utils.rs @@ -1,9 +1,7 @@ -use std::env; -use std::fs; -use std::io; use std::path::{Path, PathBuf}; use std::process::{self, Command}; use std::sync::atomic::{AtomicBool, Ordering}; +use std::{env, fs, io}; use crate::path::{Dirs, RelPath}; use crate::shared_utils::rustflags_to_cmd_env; diff --git a/example/alloc_system.rs b/example/alloc_system.rs index 441f3cd298743..2884c9c32ae4d 100644 --- a/example/alloc_system.rs +++ b/example/alloc_system.rs @@ -8,8 +8,7 @@ pub struct System; #[cfg(any(windows, unix, target_os = "redox"))] mod realloc_fallback { use core::alloc::{GlobalAlloc, Layout}; - use core::cmp; - use core::ptr; + use core::{cmp, ptr}; impl super::System { pub(crate) unsafe fn realloc_fallback( &self, @@ -34,6 +33,7 @@ mod platform { use core::alloc::{GlobalAlloc, Layout}; use core::ffi::c_void; use core::ptr; + use System; extern "C" { fn posix_memalign(memptr: *mut *mut c_void, align: usize, size: usize) -> i32; @@ -71,6 +71,7 @@ mod platform { #[allow(nonstandard_style)] mod platform { use core::alloc::{GlobalAlloc, Layout}; + use System; type LPVOID = *mut u8; type HANDLE = LPVOID; diff --git a/example/arbitrary_self_types_pointers_and_wrappers.rs b/example/arbitrary_self_types_pointers_and_wrappers.rs index f7edfa960a229..5479b0c617bfb 100644 --- a/example/arbitrary_self_types_pointers_and_wrappers.rs +++ b/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -2,10 +2,8 @@ #![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)] -use std::{ - marker::Unsize, - ops::{CoerceUnsized, Deref, DispatchFromDyn}, -}; +use std::marker::Unsize; +use std::ops::{CoerceUnsized, Deref, DispatchFromDyn}; struct Ptr(Box); diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index eebd181341d08..ac7dd0bd46329 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -1,7 +1,8 @@ //! Unwind info generation (`.eh_frame`) use cranelift_codegen::ir::Endianness; -use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa}; +use cranelift_codegen::isa::unwind::UnwindInfo; +use cranelift_codegen::isa::TargetIsa; use cranelift_object::ObjectProduct; use gimli::write::{CieId, EhFrame, FrameTable, Section}; use gimli::RunTimeEndian; diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 763d9a484077e..b6fee1bf24a78 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -11,8 +11,9 @@ use rustc_codegen_ssa::assert_module_sources::CguReuse; use rustc_codegen_ssa::back::link::ensure_removed; use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file; use rustc_codegen_ssa::base::determine_cgu_reuse; -use rustc_codegen_ssa::errors as ssa_errors; -use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind}; +use rustc_codegen_ssa::{ + errors as ssa_errors, CodegenResults, CompiledModule, CrateInfo, ModuleKind, +}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::{par_map, IntoDynSyncSend}; @@ -26,8 +27,9 @@ use rustc_session::Session; use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken}; use crate::debuginfo::TypeDebugContext; use crate::global_asm::GlobalAsmConfig; +use crate::prelude::*; use crate::unwind_module::UnwindModule; -use crate::{prelude::*, BackendConfig}; +use crate::BackendConfig; struct ModuleCodegenResult { module_regular: CompiledModule, diff --git a/src/driver/jit.rs b/src/driver/jit.rs index dfee8e714e64a..12e860f676d05 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -14,9 +14,9 @@ use rustc_session::Session; use rustc_span::Symbol; use crate::debuginfo::TypeDebugContext; +use crate::prelude::*; use crate::unwind_module::UnwindModule; -use crate::{prelude::*, BackendConfig}; -use crate::{CodegenCx, CodegenMode}; +use crate::{BackendConfig, CodegenCx, CodegenMode}; struct JitState { jit_module: UnwindModule, diff --git a/src/lib.rs b/src/lib.rs index 8d3d5ac98e1e5..9d46d8d6dac35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,10 +85,9 @@ mod vtable; mod prelude { pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; pub(crate) use cranelift_codegen::ir::function::Function; - pub(crate) use cranelift_codegen::ir::types; pub(crate) use cranelift_codegen::ir::{ - AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, - StackSlotData, StackSlotKind, TrapCode, Type, Value, + types, AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, + StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value, }; pub(crate) use cranelift_codegen::Context; pub(crate) use cranelift_module::{self, DataDescription, FuncId, Linkage, Module}; diff --git a/src/main_shim.rs b/src/main_shim.rs index fe0a15514190c..ba20a750d2b35 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -1,7 +1,6 @@ use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use rustc_hir::LangItem; -use rustc_middle::ty::AssocKind; -use rustc_middle::ty::GenericArg; +use rustc_middle::ty::{AssocKind, GenericArg}; use rustc_session::config::{sigpipe, EntryFnType}; use rustc_span::symbol::Ident; use rustc_span::DUMMY_SP; diff --git a/src/optimize/peephole.rs b/src/optimize/peephole.rs index 26327dca299b9..c93fe93521033 100644 --- a/src/optimize/peephole.rs +++ b/src/optimize/peephole.rs @@ -1,6 +1,7 @@ //! Peephole optimizations that can be performed while creating clif ir. -use cranelift_codegen::ir::{condcodes::IntCC, InstructionData, Opcode, Value, ValueDef}; +use cranelift_codegen::ir::condcodes::IntCC; +use cranelift_codegen::ir::{InstructionData, Opcode, Value, ValueDef}; use cranelift_frontend::FunctionBuilder; /// If the given value was produced by the lowering of `Rvalue::Not` return the input and true, From 5cd1e8d9ab8594c0281906a1cc69a2546eae7118 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 11 May 2024 09:56:59 -0400 Subject: [PATCH 19/42] Update compiler_builtins to 0.1.114 The `weak-intrinsics` feature was removed from compiler_builtins in https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot. In https://github.com/rust-lang/compiler-builtins/pull/593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc. Also disable it for LLVM targets that don't support it. --- build_system/build_sysroot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 196ff8fda7544..557e90abdb3d7 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -276,7 +276,7 @@ fn build_clif_sysroot_for_triple( if channel == "release" { build_cmd.arg("--release"); } - build_cmd.arg("--features").arg("backtrace panic-unwind"); + build_cmd.arg("--features").arg("backtrace panic-unwind compiler-builtins-no-f16-f128"); build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true"); build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif"); if compiler.triple.contains("apple") { From 161d2476d5bed2daf55770ea68b5964cd6d5d543 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:53:17 +0000 Subject: [PATCH 20/42] Move temp file name generation out of the create_dll_import_lib method --- src/archive.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 1935005a08c54..73ccf500a51fb 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use rustc_codegen_ssa::back::archive::{ ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER, @@ -17,9 +17,8 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { sess: &Session, _lib_name: &str, _dll_imports: &[rustc_session::cstore::DllImport], - _tmpdir: &Path, - _is_direct_dependency: bool, - ) -> PathBuf { + _output_path: &Path, + ) { sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift"); } } From 37da2641076203c22d615f132572172359576fe2 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 25 Jul 2024 20:08:40 +0000 Subject: [PATCH 21/42] Move computation of decorated names out of the create_dll_import_lib method --- src/archive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/archive.rs b/src/archive.rs index 73ccf500a51fb..084654af09dd7 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -16,7 +16,7 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { &self, sess: &Session, _lib_name: &str, - _dll_imports: &[rustc_session::cstore::DllImport], + _import_name_and_ordinal_vector: Vec<(String, Option)>, _output_path: &Path, ) { sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift"); From f340c81caac9bca69fba16a9e6f7622fa099d20a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:33:58 +0200 Subject: [PATCH 22/42] Statically enable a couple of target features always enabled on arm64 macOS Ring fails to compile when they are not statically enabled when compiling for macOS. Fixes rust-lang/rustc_codegen_cranelift#1522 --- src/lib.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8d3d5ac98e1e5..fab36104845f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,9 +191,20 @@ impl CodegenBackend for CraneliftCodegenBackend { if sess.target.arch == "x86_64" && sess.target.os != "none" { // x86_64 mandates SSE2 support vec![Symbol::intern("fxsr"), sym::sse, Symbol::intern("sse2")] - } else if sess.target.arch == "aarch64" && sess.target.os != "none" { - // AArch64 mandates Neon support - vec![sym::neon] + } else if sess.target.arch == "aarch64" { + match &*sess.target.os { + "none" => vec![], + // On macOS the aes, sha2 and sha3 features are enabled by default and ring + // fails to compile on macOS when they are not present. + "macos" => vec![ + sym::neon, + Symbol::intern("aes"), + Symbol::intern("sha2"), + Symbol::intern("sha3"), + ], + // AArch64 mandates Neon support + _ => vec![sym::neon], + } } else { vec![] } From 7bdafb5f6ac0dc6aeeba41f0a760cedb6a6614d6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:40:01 +0000 Subject: [PATCH 23/42] Rustup to rustc 1.82.0-nightly (8e86c9567 2024-08-01) --- ...022-coretests-Disable-not-compiling-tests.patch | 6 +++--- .../0027-coretests-128bit-atomic-operations.patch | 14 +++++++------- patches/stdlib-lock.toml | 4 ++-- rust-toolchain | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/patches/0022-coretests-Disable-not-compiling-tests.patch b/patches/0022-coretests-Disable-not-compiling-tests.patch index 7cf7f86700eaf..8c404956bcc20 100644 --- a/patches/0022-coretests-Disable-not-compiling-tests.patch +++ b/patches/0022-coretests-Disable-not-compiling-tests.patch @@ -37,8 +37,8 @@ index 42a26ae..5ac1042 100644 +++ b/lib.rs @@ -1,3 +1,4 @@ +#![cfg(test)] - #![feature(alloc_layout_extra)] - #![feature(array_chunks)] - #![feature(array_ptr_get)] + // tidy-alphabetical-start + #![cfg_attr(bootstrap, feature(offset_of_nested))] + #![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] -- 2.21.0 (Apple Git-122) diff --git a/patches/0027-coretests-128bit-atomic-operations.patch b/patches/0027-coretests-128bit-atomic-operations.patch index 271ca12eabbcd..d579c9588f08a 100644 --- a/patches/0027-coretests-128bit-atomic-operations.patch +++ b/patches/0027-coretests-128bit-atomic-operations.patch @@ -11,17 +11,17 @@ Cranelift doesn't support them yet 4 files changed, 4 insertions(+), 50 deletions(-) diff --git a/lib.rs b/lib.rs -index 897a5e9..331f66f 100644 +index 1e336bf..35e6f54 100644 --- a/lib.rs +++ b/lib.rs -@@ -93,7 +93,6 @@ - #![feature(const_option)] - #![feature(const_option_ext)] - #![feature(const_result)] +@@ -1,7 +1,6 @@ + #![cfg(test)] + // tidy-alphabetical-start + #![cfg_attr(bootstrap, feature(offset_of_nested))] -#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] #![cfg_attr(test, feature(cfg_match))] - #![feature(int_roundings)] - #![feature(split_array)] + #![feature(alloc_layout_extra)] + #![feature(array_chunks)] diff --git a/atomic.rs b/atomic.rs index b735957..ea728b6 100644 --- a/atomic.rs diff --git a/patches/stdlib-lock.toml b/patches/stdlib-lock.toml index 1c1f81844c3de..b68e9c2f0d075 100644 --- a/patches/stdlib-lock.toml +++ b/patches/stdlib-lock.toml @@ -58,9 +58,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.106" +version = "0.1.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ab134a739bafec76aa91ccb15d519a54e569350644a1fea6528d5a0d407e22" +checksum = "eb58b199190fcfe0846f55a3b545cd6b07a34bdd5930a476ff856f3ebcc5558a" dependencies = [ "cc", "rustc-std-workspace-core", diff --git a/rust-toolchain b/rust-toolchain index f719dc441a5ea..10bdf09ba8b32 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-07-27" +channel = "nightly-2024-08-02" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From 9bad4b620f8e55c3d67442020180a414e5b88fb7 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:06:02 +0200 Subject: [PATCH 24/42] Fix rustc test suite --- scripts/test_rustc_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 735762b389cfb..b85d474516807 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -118,6 +118,7 @@ rm tests/ui/mir/mir_misc_casts.rs # depends on deduplication of constants rm tests/ui/mir/mir_raw_fat_ptr.rs # same rm tests/ui/consts/issue-33537.rs # same rm tests/ui/consts/const-mut-refs-crate.rs # same +rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift # doesn't work due to the way the rustc test suite is invoked. # should work when using ./x.py test the way it is intended From c48b010845213ba3be38ca4a481160ed582fac8a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:24:08 +0200 Subject: [PATCH 25/42] Implement x86 _mm_sqrt_ss vendor intrinsic --- src/intrinsics/llvm_x86.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index a20faa2cad3a8..246d126d4f9c3 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -192,6 +192,23 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( ret.place_lane(fx, 0).write_cvalue(fx, res_lane); } + "llvm.x86.sse.sqrt.ss" => { + // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ss&ig_expand=6278 + intrinsic_args!(fx, args => (a); intrinsic); + + assert_eq!(a.layout(), ret.layout()); + let (_, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx); + assert!(lane_ty.is_floating_point()); + let ret_lane_layout = fx.layout_of(lane_ty); + + ret.write_cvalue(fx, a); + + let lane = a.value_lane(fx, 0).load_scalar(fx); + let res = fx.bcx.ins().sqrt(lane); + let res_lane = CValue::by_val(res, ret_lane_layout); + ret.place_lane(fx, 0).write_cvalue(fx, res_lane); + } + "llvm.x86.sse.sqrt.ps" => { // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ps&ig_expand=6245 intrinsic_args!(fx, args => (a); intrinsic); From e52af665f54dcb16df7a546bd6569d250c9ea6c6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:14:46 +0000 Subject: [PATCH 26/42] Update abi-cafe This has found a couple of new abi issues. I also had to disable the abi-cafe tests for the MinGW target as one of these abi issues causes a hang and abi-cafe doesn't yet support timeouts. --- .github/workflows/abi-cafe.yml | 9 ++-- build_system/abi_cafe.rs | 25 +++++++---- ...e-some-test-on-x86_64-pc-windows-gnu.patch | 32 -------------- .../0002-abi-cafe-Disable-broken-tests.patch | 44 +++++++++++++++++++ 4 files changed, 65 insertions(+), 45 deletions(-) delete mode 100644 patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch create mode 100644 patches/0002-abi-cafe-Disable-broken-tests.patch diff --git a/.github/workflows/abi-cafe.yml b/.github/workflows/abi-cafe.yml index 1ed6f8fc359db..bcba00d0bfc64 100644 --- a/.github/workflows/abi-cafe.yml +++ b/.github/workflows/abi-cafe.yml @@ -8,7 +8,7 @@ permissions: {} jobs: abi_cafe: runs-on: ${{ matrix.os }} - timeout-minutes: 60 + timeout-minutes: 30 concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.env.TARGET_TRIPLE }} cancel-in-progress: true @@ -30,9 +30,10 @@ jobs: - os: windows-latest env: TARGET_TRIPLE: x86_64-pc-windows-msvc - - os: windows-latest - env: - TARGET_TRIPLE: x86_64-pc-windows-gnu + # FIXME Currently hangs. Re-enable once this is fixed or abi-cafe adds a timeout. + #- os: windows-latest + # env: + # TARGET_TRIPLE: x86_64-pc-windows-gnu steps: - uses: actions/checkout@v4 diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index 75f9f233cb33d..c4a3cbf125900 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -6,8 +6,8 @@ use crate::{build_sysroot, CodegenBackend, SysrootKind}; static ABI_CAFE_REPO: GitRepo = GitRepo::github( "Gankra", "abi-cafe", - "4c6dc8c9c687e2b3a760ff2176ce236872b37212", - "588df6d66abbe105", + "f1220cfd13b57f5c0082c26529163865ee25e115", + "fe93a9acd461425d", "abi-cafe", ); @@ -38,17 +38,23 @@ pub(crate) fn run( eprintln!("Running abi-cafe"); let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"]; - - let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs); - cmd.arg("--"); - cmd.arg("--pairs"); - cmd.args( + let pairs = if cfg!(not(any(target_os = "macos", all(target_os = "windows", target_env = "msvc")))) { &pairs[..] } else { &pairs[..2] - }, - ); + }; + + let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs); + cmd.arg("--"); + + // stdcall, vectorcall and such don't work yet + cmd.arg("--conventions").arg("c").arg("--conventions").arg("rust"); + + for pair in pairs { + cmd.arg("--pairs").arg(pair); + } + cmd.arg("--add-rustc-codegen-backend"); match cg_clif_dylib { CodegenBackend::Local(path) => { @@ -58,6 +64,7 @@ pub(crate) fn run( cmd.arg(format!("cgclif:{name}")); } } + cmd.current_dir(ABI_CAFE.source_dir(dirs)); spawn_and_wait(cmd); diff --git a/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch b/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch deleted file mode 100644 index 77716c5139978..0000000000000 --- a/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2b15fee2bb5fd14e34c7e17e44d99cb34f4c555d Mon Sep 17 00:00:00 2001 -From: Afonso Bordado -Date: Tue, 27 Sep 2022 07:55:17 +0100 -Subject: [PATCH] Disable some test on x86_64-pc-windows-gnu - ---- - src/report.rs | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/report.rs b/src/report.rs -index eeec614..f582867 100644 ---- a/src/report.rs -+++ b/src/report.rs -@@ -48,6 +48,15 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl - // - // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES - -+ // x86_64-pc-windows-gnu has some broken i128 tests that aren't disabled by default -+ if cfg!(all(target_os = "windows", target_env = "gnu")) && test.test_name == "ui128" { -+ result.run = Link; -+ result.check = Pass(Link); -+ } else if test.test_name == "ui128" { -+ result.run == Check; -+ result.check = Pass(Check); -+ } -+ - // END OF VENDOR RESERVED AREA - // - // --- -2.30.1.windows.1 - diff --git a/patches/0002-abi-cafe-Disable-broken-tests.patch b/patches/0002-abi-cafe-Disable-broken-tests.patch new file mode 100644 index 0000000000000..c30962728463f --- /dev/null +++ b/patches/0002-abi-cafe-Disable-broken-tests.patch @@ -0,0 +1,44 @@ +From 378d9e451a8af1045b8cb32841198cd5ad5464a3 Mon Sep 17 00:00:00 2001 +From: bjorn3 <17426603+bjorn3@users.noreply.github.com> +Date: Tue, 9 Jul 2024 11:25:14 +0000 +Subject: [PATCH] Disable broken tests + +--- + src/abis/mod.rs | 6 +++--- + src/report.rs | 4 ++++ + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/report.rs b/src/report.rs +index acfce38..b3ab842 100644 +--- a/src/report.rs ++++ b/src/report.rs +@@ -45,6 +45,26 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl + // + // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES + ++ if cfg!(target_arch = "aarch64") && test.test == "F32Array" && test.options.convention == CallingConvention::C { ++ result.check = Busted(Check); ++ } ++ ++ if cfg!(target_arch = "aarch64") && test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::C { ++ result.check = Busted(Check); ++ } ++ ++ if cfg!(target_arch = "x86_64") && test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::Rust { ++ result.check = Busted(Run); ++ } ++ ++ if cfg!(windows) && (test.test == "OptionU128" || test.test == "I64Array" || test.test == "simple") { ++ result.run = Skip; // Gives SIGILL on x86_64 windows. ++ } ++ ++ if test.test == "f16" || test.test == "f128" { ++ result.run = Skip; ++ } ++ + // END OF VENDOR RESERVED AREA + // + // +-- +2.34.1 + From 9ad44ba73714afa2d803fab883d0f8969c8da5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 14 Jul 2024 07:07:47 +0000 Subject: [PATCH 27/42] enable abi-cafe tests on aarch64-apple-darwin --- .github/workflows/abi-cafe.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/abi-cafe.yml b/.github/workflows/abi-cafe.yml index bcba00d0bfc64..9c487f2f90af2 100644 --- a/.github/workflows/abi-cafe.yml +++ b/.github/workflows/abi-cafe.yml @@ -27,6 +27,9 @@ jobs: - os: macos-latest env: TARGET_TRIPLE: x86_64-apple-darwin + - os: macos-latest + env: + TARGET_TRIPLE: aarch64-apple-darwin - os: windows-latest env: TARGET_TRIPLE: x86_64-pc-windows-msvc From b3df6dcb6069bdd8a7c1f5507df112830d7981b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 4 Aug 2024 14:54:20 +0000 Subject: [PATCH 28/42] ensure the download folder exists when running `abi-cafe` --- build_system/abi_cafe.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index c4a3cbf125900..e3f1162445b33 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -1,4 +1,4 @@ -use crate::path::Dirs; +use crate::path::{Dirs, RelPath}; use crate::prepare::GitRepo; use crate::utils::{spawn_and_wait, CargoProject, Compiler}; use crate::{build_sysroot, CodegenBackend, SysrootKind}; @@ -21,6 +21,7 @@ pub(crate) fn run( rustup_toolchain_name: Option<&str>, bootstrap_host_compiler: &Compiler, ) { + RelPath::DOWNLOAD.ensure_exists(dirs); ABI_CAFE_REPO.fetch(dirs); ABI_CAFE_REPO.patch(dirs); From 1f19cdf659f1fd603c371ebb305b5afb8abd45f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Mon, 5 Aug 2024 16:30:51 +0000 Subject: [PATCH 29/42] mark busted tests for `aarch64-apple-darwin` and `aarch64-unknown-linux-gnu` --- .../0002-abi-cafe-Disable-broken-tests.patch | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/patches/0002-abi-cafe-Disable-broken-tests.patch b/patches/0002-abi-cafe-Disable-broken-tests.patch index c30962728463f..5aab566e6f281 100644 --- a/patches/0002-abi-cafe-Disable-broken-tests.patch +++ b/patches/0002-abi-cafe-Disable-broken-tests.patch @@ -1,27 +1,42 @@ -From 378d9e451a8af1045b8cb32841198cd5ad5464a3 Mon Sep 17 00:00:00 2001 +From 236df390f3bc4ed69c26f4d51d584bea246da886 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:25:14 +0000 Subject: [PATCH] Disable broken tests --- - src/abis/mod.rs | 6 +++--- - src/report.rs | 4 ++++ - 2 files changed, 7 insertions(+), 3 deletions(-) + src/report.rs | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) diff --git a/src/report.rs b/src/report.rs -index acfce38..b3ab842 100644 +index 958ab43..dcf1044 100644 --- a/src/report.rs +++ b/src/report.rs -@@ -45,6 +45,26 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl +@@ -48,6 +48,42 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn Toolchain, callee: &dyn Toolc // // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES -+ if cfg!(target_arch = "aarch64") && test.test == "F32Array" && test.options.convention == CallingConvention::C { -+ result.check = Busted(Check); ++ if cfg!(all(target_arch = "aarch64", target_os = "linux")) { ++ if test.test == "F32Array" && test.options.convention == CallingConvention::C { ++ result.check = Busted(Check); ++ } ++ ++ if test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::C { ++ result.check = Busted(Check); ++ } + } + -+ if cfg!(target_arch = "aarch64") && test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::C { -+ result.check = Busted(Check); ++ if cfg!(all(target_arch = "aarch64", target_os = "macos")) { ++ if test.test == "SingleVariantUnion" && test.options.convention == CallingConvention::C && test.options.repr == LangRepr::C { ++ result.check = Busted(Check); ++ } ++ ++ if test.test == "OptionU128" && test.caller == "rustc" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::C { ++ result.check = Busted(Run); ++ } ++ ++ if test.test == "OptionU128" && test.caller == "cgclif" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::C { ++ result.check = Busted(Check); ++ } + } + + if cfg!(target_arch = "x86_64") && test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::Rust { From 52f1ea49156b9e9b46d76b12035c540b506ad2e3 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:21:28 +0000 Subject: [PATCH 30/42] Don't skip running abi-cafe tests that give SIGILL on Windows --- .../0002-abi-cafe-Disable-broken-tests.patch | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/patches/0002-abi-cafe-Disable-broken-tests.patch b/patches/0002-abi-cafe-Disable-broken-tests.patch index 5aab566e6f281..8a2565f1668ad 100644 --- a/patches/0002-abi-cafe-Disable-broken-tests.patch +++ b/patches/0002-abi-cafe-Disable-broken-tests.patch @@ -11,7 +11,7 @@ diff --git a/src/report.rs b/src/report.rs index 958ab43..dcf1044 100644 --- a/src/report.rs +++ b/src/report.rs -@@ -48,6 +48,42 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn Toolchain, callee: &dyn Toolc +@@ -48,6 +48,58 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn Toolchain, callee: &dyn Toolc // // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES @@ -39,12 +39,28 @@ index 958ab43..dcf1044 100644 + } + } + -+ if cfg!(target_arch = "x86_64") && test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::Rust { -+ result.check = Busted(Run); ++ if cfg!(all(target_arch = "x86_64", unix)) { ++ if test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && test.options.repr == LangRepr::Rust { ++ result.check = Busted(Run); ++ } + } + -+ if cfg!(windows) && (test.test == "OptionU128" || test.test == "I64Array" || test.test == "simple") { -+ result.run = Skip; // Gives SIGILL on x86_64 windows. ++ if cfg!(all(target_arch = "x86_64", windows)) { ++ if test.test == "OptionU128" && test.options.convention == CallingConvention::Rust { ++ result.check = Busted(Check); ++ } ++ ++ if test.test == "OptionU128" && test.options.convention == CallingConvention::Rust && (test.caller == "rustc" || test.options.repr == LangRepr::Rust) { ++ result.check = Busted(Run); ++ } ++ ++ if test.test == "simple" && test.options.convention == CallingConvention::Rust { ++ result.check = Busted(Check); ++ } ++ ++ if test.test == "simple" && test.options.convention == CallingConvention::Rust && test.caller == "rustc" { ++ result.check = Busted(Run); ++ } + } + + if test.test == "f16" || test.test == "f128" { From 6ef49b2ea3e84990da14aa19b4416510d34c30f9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:35:31 +0000 Subject: [PATCH 31/42] Run abi-cafe tests for pull requests too --- .github/workflows/abi-cafe.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/abi-cafe.yml b/.github/workflows/abi-cafe.yml index 9c487f2f90af2..30dc5cb16154b 100644 --- a/.github/workflows/abi-cafe.yml +++ b/.github/workflows/abi-cafe.yml @@ -2,6 +2,7 @@ name: Abi-cafe on: - push + - pull_request permissions: {} From 76f615ef1fbe8fa795731659950c2287f2b836d6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:54:55 +0000 Subject: [PATCH 32/42] Rustup to rustc 1.82.0-nightly (60d146580 2024-08-06) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 10bdf09ba8b32..f5cf169c7f7c9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-08-02" +channel = "nightly-2024-08-07" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From 14d020f88d8840987d161d2425c30778499a6ac3 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:45:15 +0000 Subject: [PATCH 33/42] Remove no longer used vendor intrinsic implementations --- src/intrinsics/llvm_x86.rs | 161 ------------------------------------- 1 file changed, 161 deletions(-) diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index 246d126d4f9c3..cb003037c265f 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -169,56 +169,6 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( } } - "llvm.x86.sse.add.ss" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_add_ss&ig_expand=171 - intrinsic_args!(fx, args => (a, b); intrinsic); - - assert_eq!(a.layout(), b.layout()); - assert_eq!(a.layout(), ret.layout()); - let layout = a.layout(); - - let (_, lane_ty) = layout.ty.simd_size_and_type(fx.tcx); - assert!(lane_ty.is_floating_point()); - let ret_lane_layout = fx.layout_of(lane_ty); - - ret.write_cvalue(fx, a); - - let a_lane = a.value_lane(fx, 0).load_scalar(fx); - let b_lane = b.value_lane(fx, 0).load_scalar(fx); - - let res = fx.bcx.ins().fadd(a_lane, b_lane); - - let res_lane = CValue::by_val(res, ret_lane_layout); - ret.place_lane(fx, 0).write_cvalue(fx, res_lane); - } - - "llvm.x86.sse.sqrt.ss" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ss&ig_expand=6278 - intrinsic_args!(fx, args => (a); intrinsic); - - assert_eq!(a.layout(), ret.layout()); - let (_, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx); - assert!(lane_ty.is_floating_point()); - let ret_lane_layout = fx.layout_of(lane_ty); - - ret.write_cvalue(fx, a); - - let lane = a.value_lane(fx, 0).load_scalar(fx); - let res = fx.bcx.ins().sqrt(lane); - let res_lane = CValue::by_val(res, ret_lane_layout); - ret.place_lane(fx, 0).write_cvalue(fx, res_lane); - } - - "llvm.x86.sse.sqrt.ps" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ps&ig_expand=6245 - intrinsic_args!(fx, args => (a); intrinsic); - - // FIXME use vector instructions when possible - simd_for_each_lane(fx, a, ret, &|fx, _lane_ty, _res_lane_ty, lane| { - fx.bcx.ins().sqrt(lane) - }); - } - "llvm.x86.sse.max.ps" => { // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_max_ps&ig_expand=4357 intrinsic_args!(fx, args => (a, b); intrinsic); @@ -761,117 +711,6 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( pack_instruction(fx, a, b, ret, PackSize::S16, PackWidth::Avx); } - "llvm.x86.fma.vfmaddsub.ps" - | "llvm.x86.fma.vfmaddsub.pd" - | "llvm.x86.fma.vfmaddsub.ps.256" - | "llvm.x86.fma.vfmaddsub.pd.256" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fmaddsub_ps&ig_expand=3205 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fmaddsub_pd&ig_expand=3181 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fmaddsub_ps&ig_expand=3209 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fmaddsub_pd&ig_expand=3185 - intrinsic_args!(fx, args => (a, b, c); intrinsic); - - assert_eq!(a.layout(), b.layout()); - assert_eq!(a.layout(), c.layout()); - let layout = a.layout(); - - let (lane_count, lane_ty) = layout.ty.simd_size_and_type(fx.tcx); - let (ret_lane_count, ret_lane_ty) = ret.layout().ty.simd_size_and_type(fx.tcx); - assert!(lane_ty.is_floating_point()); - assert!(ret_lane_ty.is_floating_point()); - assert_eq!(lane_count, ret_lane_count); - let ret_lane_layout = fx.layout_of(ret_lane_ty); - - for idx in 0..lane_count { - let a_lane = a.value_lane(fx, idx).load_scalar(fx); - let b_lane = b.value_lane(fx, idx).load_scalar(fx); - let c_lane = c.value_lane(fx, idx).load_scalar(fx); - - let mul = fx.bcx.ins().fmul(a_lane, b_lane); - let res = if idx & 1 == 0 { - fx.bcx.ins().fsub(mul, c_lane) - } else { - fx.bcx.ins().fadd(mul, c_lane) - }; - - let res_lane = CValue::by_val(res, ret_lane_layout); - ret.place_lane(fx, idx).write_cvalue(fx, res_lane); - } - } - - "llvm.x86.fma.vfmsubadd.ps" - | "llvm.x86.fma.vfmsubadd.pd" - | "llvm.x86.fma.vfmsubadd.ps.256" - | "llvm.x86.fma.vfmsubadd.pd.256" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fmsubadd_ps&ig_expand=3325 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fmsubadd_pd&ig_expand=3301 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fmsubadd_ps&ig_expand=3329 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fmsubadd_pd&ig_expand=3305 - intrinsic_args!(fx, args => (a, b, c); intrinsic); - - assert_eq!(a.layout(), b.layout()); - assert_eq!(a.layout(), c.layout()); - let layout = a.layout(); - - let (lane_count, lane_ty) = layout.ty.simd_size_and_type(fx.tcx); - let (ret_lane_count, ret_lane_ty) = ret.layout().ty.simd_size_and_type(fx.tcx); - assert!(lane_ty.is_floating_point()); - assert!(ret_lane_ty.is_floating_point()); - assert_eq!(lane_count, ret_lane_count); - let ret_lane_layout = fx.layout_of(ret_lane_ty); - - for idx in 0..lane_count { - let a_lane = a.value_lane(fx, idx).load_scalar(fx); - let b_lane = b.value_lane(fx, idx).load_scalar(fx); - let c_lane = c.value_lane(fx, idx).load_scalar(fx); - - let mul = fx.bcx.ins().fmul(a_lane, b_lane); - let res = if idx & 1 == 0 { - fx.bcx.ins().fadd(mul, c_lane) - } else { - fx.bcx.ins().fsub(mul, c_lane) - }; - - let res_lane = CValue::by_val(res, ret_lane_layout); - ret.place_lane(fx, idx).write_cvalue(fx, res_lane); - } - } - - "llvm.x86.fma.vfnmadd.ps" - | "llvm.x86.fma.vfnmadd.pd" - | "llvm.x86.fma.vfnmadd.ps.256" - | "llvm.x86.fma.vfnmadd.pd.256" => { - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fnmadd_ps&ig_expand=3391 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_fnmadd_pd&ig_expand=3367 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fnmadd_ps&ig_expand=3395 - // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_fnmadd_pd&ig_expand=3371 - intrinsic_args!(fx, args => (a, b, c); intrinsic); - - assert_eq!(a.layout(), b.layout()); - assert_eq!(a.layout(), c.layout()); - let layout = a.layout(); - - let (lane_count, lane_ty) = layout.ty.simd_size_and_type(fx.tcx); - let (ret_lane_count, ret_lane_ty) = ret.layout().ty.simd_size_and_type(fx.tcx); - assert!(lane_ty.is_floating_point()); - assert!(ret_lane_ty.is_floating_point()); - assert_eq!(lane_count, ret_lane_count); - let ret_lane_layout = fx.layout_of(ret_lane_ty); - - for idx in 0..lane_count { - let a_lane = a.value_lane(fx, idx).load_scalar(fx); - let b_lane = b.value_lane(fx, idx).load_scalar(fx); - let c_lane = c.value_lane(fx, idx).load_scalar(fx); - - let mul = fx.bcx.ins().fmul(a_lane, b_lane); - let neg_mul = fx.bcx.ins().fneg(mul); - let res = fx.bcx.ins().fadd(neg_mul, c_lane); - - let res_lane = CValue::by_val(res, ret_lane_layout); - ret.place_lane(fx, idx).write_cvalue(fx, res_lane); - } - } - "llvm.x86.sse42.crc32.32.8" | "llvm.x86.sse42.crc32.32.16" | "llvm.x86.sse42.crc32.32.32" From 60ffec8b4a1bdeeef3cd3793b829659979b90bbf Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:25:20 +0000 Subject: [PATCH 34/42] Rustup to rustc 1.82.0-nightly (8b3870784 2024-08-07) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index f5cf169c7f7c9..827956c98cf29 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-08-07" +channel = "nightly-2024-08-08" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From fdc6a5562b07192992592577a49333766b104bf1 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:54:20 +0200 Subject: [PATCH 35/42] Fix rustc test suite --- scripts/test_rustc_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index b85d474516807..bb5af9127b96e 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -39,6 +39,7 @@ rm tests/ui/simd/dont-invalid-bitcast-x86_64.rs # unimplemented llvm.x86.sse41.r # exotic linkages rm tests/incremental/hashes/function_interfaces.rs rm tests/incremental/hashes/statics.rs +rm -r tests/run-make/naked-symbol-visibility # variadic arguments rm tests/ui/abi/mir/mir_codegen_calls_variadic.rs # requires float varargs From 2756bd6ff77232a198adeb6e4083866484a469f3 Mon Sep 17 00:00:00 2001 From: Daniel Paoliello Date: Fri, 2 Aug 2024 13:53:09 -0700 Subject: [PATCH 36/42] Add support for raw-dylib --- Cargo.lock | 14 +++- Cargo.toml | 1 + build_system/tests.rs | 1 + config.txt | 1 + example/raw-dylib.rs | 31 ++++++++ .../0029-stdlib-rawdylib-processprng.patch | 47 ----------- ...use-raw-dylib-for-Windows-futex-APIs.patch | 37 --------- src/archive.rs | 79 +++++++++++++++++-- 8 files changed, 120 insertions(+), 91 deletions(-) create mode 100644 example/raw-dylib.rs delete mode 100644 patches/0029-stdlib-rawdylib-processprng.patch delete mode 100644 patches/0030-stdlib-Revert-use-raw-dylib-for-Windows-futex-APIs.patch diff --git a/Cargo.lock b/Cargo.lock index b065720c9ce11..741a1748fec98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,15 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "ar_archive_writer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2bcb7cf51decfbbfc7ef476e28b0775b13e5eb1190f8b7df145cd53d4f4374" +dependencies = [ + "object", +] + [[package]] name = "arbitrary" version = "1.3.2" @@ -289,9 +298,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "object" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "crc32fast", "hashbrown 0.14.5", @@ -358,6 +367,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ + "ar_archive_writer", "cranelift-codegen", "cranelift-frontend", "cranelift-jit", diff --git a/Cargo.toml b/Cargo.toml index a0df502dadc47..c86919dcdfb7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ cranelift-object = { version = "0.110.1" } target-lexicon = "0.12.0" gimli = { version = "0.28", default-features = false, features = ["write"]} object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } +ar_archive_writer = "0.3" indexmap = "2.0.0" libloading = { version = "0.8.0", optional = true } diff --git a/build_system/tests.rs b/build_system/tests.rs index afc8a923863a2..3a88824bf3635 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -106,6 +106,7 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[ ]); runner.run_out_command("gen_block_iterate", &[]); }), + TestCase::build_bin_and_run("aot.raw-dylib", "example/raw-dylib.rs", &[]), ]; pub(crate) static RAND_REPO: GitRepo = GitRepo::github( diff --git a/config.txt b/config.txt index 0b7cac1883761..527ec5303b602 100644 --- a/config.txt +++ b/config.txt @@ -45,6 +45,7 @@ aot.issue-59326 aot.polymorphize_coroutine aot.neon aot.gen_block_iterate +aot.raw-dylib testsuite.extended_sysroot test.rust-random/rand diff --git a/example/raw-dylib.rs b/example/raw-dylib.rs new file mode 100644 index 0000000000000..4711884f76af6 --- /dev/null +++ b/example/raw-dylib.rs @@ -0,0 +1,31 @@ +// Tests the raw-dylib feature for Windows. +// https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute + +fn main() { + #[cfg(windows)] + { + #[link(name = "kernel32", kind = "raw-dylib")] + extern "C" { + fn GetModuleFileNameA( + module: *mut std::ffi::c_void, + filename: *mut u8, + size: u32, + ) -> u32; + } + + // Get the filename of the current executable.... + let mut buffer = [0u8; 1024]; + let size = unsafe { + GetModuleFileNameA(core::ptr::null_mut(), buffer.as_mut_ptr(), buffer.len() as u32) + }; + if size == 0 { + eprintln!("failed to get module file name: {}", std::io::Error::last_os_error()); + return; + } else { + // ...and make sure that it matches the test name. + let filename = + std::ffi::CStr::from_bytes_with_nul(&buffer[..size as usize + 1]).unwrap(); + assert!(filename.to_str().unwrap().ends_with("raw-dylib.exe")); + } + } +} diff --git a/patches/0029-stdlib-rawdylib-processprng.patch b/patches/0029-stdlib-rawdylib-processprng.patch deleted file mode 100644 index 584dbdb647f60..0000000000000 --- a/patches/0029-stdlib-rawdylib-processprng.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 9f65e742ba3e41474e6126c6c4469c48eaa6ca7e Mon Sep 17 00:00:00 2001 -From: Chris Denton -Date: Tue, 20 Feb 2024 16:01:40 -0300 -Subject: [PATCH] Don't use raw-dylib in std - ---- - library/std/src/sys/pal/windows/c.rs | 2 +- - library/std/src/sys/pal/windows/rand.rs | 3 +-- - 2 files changed, 2 insertions(+), 3 deletions(-) - -diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs -index ad8e01bfa9b..9ca8e4c16ce 100644 ---- a/library/std/src/sys/pal/windows/c.rs -+++ b/library/std/src/sys/pal/windows/c.rs -@@ -312,7 +312,7 @@ pub unsafe fn NtWriteFile( - - // Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. - cfg_if::cfg_if! { --if #[cfg(not(target_vendor = "win7"))] { -+if #[cfg(any())] { - #[cfg(target_arch = "x86")] - #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] - extern "system" { -diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs -index e427546222a..f2fe42a4d51 100644 ---- a/library/std/src/sys/pal/windows/rand.rs -+++ b/library/std/src/sys/pal/windows/rand.rs -@@ -2,7 +2,7 @@ - - use crate::sys::c; - --#[cfg(not(target_vendor = "win7"))] -+#[cfg(any())] - #[inline] - pub fn hashmap_random_keys() -> (u64, u64) { - let mut v = (0, 0); -@@ -13,7 +13,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { - v - } - --#[cfg(target_vendor = "win7")] - pub fn hashmap_random_keys() -> (u64, u64) { - use crate::ffi::c_void; - use crate::io; --- -2.42.0.windows.2 - diff --git a/patches/0030-stdlib-Revert-use-raw-dylib-for-Windows-futex-APIs.patch b/patches/0030-stdlib-Revert-use-raw-dylib-for-Windows-futex-APIs.patch deleted file mode 100644 index 21f5ee9cc6ea0..0000000000000 --- a/patches/0030-stdlib-Revert-use-raw-dylib-for-Windows-futex-APIs.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0d741cf82c3c908616abd39dc84ebf7d8702e0c3 Mon Sep 17 00:00:00 2001 -From: Chris Denton -Date: Tue, 16 Apr 2024 15:51:34 +0000 -Subject: [PATCH] Revert use raw-dylib for Windows futex APIs - ---- - library/std/src/sys/pal/windows/c.rs | 14 +------------- - 1 file changed, 1 insertion(+), 13 deletions(-) - -diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs -index 9d58ce05f01..1c828bac4b6 100644 ---- a/library/std/src/sys/pal/windows/c.rs -+++ b/library/std/src/sys/pal/windows/c.rs -@@ -357,19 +357,7 @@ pub fn GetTempPath2W(bufferlength: u32, buffer: PWSTR) -> u32 { - } - - #[cfg(not(target_vendor = "win7"))] --// Use raw-dylib to import synchronization functions to workaround issues with the older mingw import library. --#[cfg_attr( -- target_arch = "x86", -- link( -- name = "api-ms-win-core-synch-l1-2-0", -- kind = "raw-dylib", -- import_name_type = "undecorated" -- ) --)] --#[cfg_attr( -- not(target_arch = "x86"), -- link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib") --)] -+#[link(name = "synchronization")] - extern "system" { - pub fn WaitOnAddress( - address: *const c_void, --- -2.42.0.windows.2 - diff --git a/src/archive.rs b/src/archive.rs index 084654af09dd7..5eedab4f2cbaa 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,8 +1,13 @@ +use std::borrow::Borrow; +use std::fs; use std::path::Path; +use ar_archive_writer::{COFFShortExport, MachineTypes}; use rustc_codegen_ssa::back::archive::{ - ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER, + create_mingw_dll_import_lib, ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, + DEFAULT_OBJECT_READER, }; +use rustc_codegen_ssa::common::is_mingw_gnu_toolchain; use rustc_session::Session; pub(crate) struct ArArchiveBuilderBuilder; @@ -15,10 +20,74 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { fn create_dll_import_lib( &self, sess: &Session, - _lib_name: &str, - _import_name_and_ordinal_vector: Vec<(String, Option)>, - _output_path: &Path, + lib_name: &str, + import_name_and_ordinal_vector: Vec<(String, Option)>, + output_path: &Path, ) { - sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift"); + if is_mingw_gnu_toolchain(&sess.target) { + // The binutils linker used on -windows-gnu targets cannot read the import + // libraries generated by LLVM: in our attempts, the linker produced an .EXE + // that loaded but crashed with an AV upon calling one of the imported + // functions. Therefore, use binutils to create the import library instead, + // by writing a .DEF file to the temp dir and calling binutils's dlltool. + create_mingw_dll_import_lib( + sess, + lib_name, + import_name_and_ordinal_vector, + output_path, + ); + } else { + let mut file = + match fs::OpenOptions::new().write(true).create_new(true).open(&output_path) { + Ok(file) => file, + Err(error) => { + sess.dcx().fatal(format!( + "failed to create import library file `{path}`: {error}", + path = output_path.display(), + )); + } + }; + + let machine = match sess.target.arch.borrow() { + "x86" => MachineTypes::I386, + "x86_64" => MachineTypes::AMD64, + "arm" => MachineTypes::ARMNT, + "aarch64" => MachineTypes::ARM64, + _ => { + sess.dcx().fatal(format!( + "unsupported target architecture `{arch}`", + arch = sess.target.arch, + )); + } + }; + + let exports = import_name_and_ordinal_vector + .iter() + .map(|(name, ordinal)| COFFShortExport { + name: name.to_string(), + ext_name: None, + symbol_name: None, + alias_target: None, + ordinal: ordinal.unwrap_or(0), + noname: ordinal.is_some(), + data: false, + private: false, + constant: false, + }) + .collect::>(); + + if let Err(error) = ar_archive_writer::write_import_library( + &mut file, + lib_name, + &exports, + machine, + !sess.target.is_like_msvc, + ) { + sess.dcx().fatal(format!( + "failed to create import library `{path}`: `{error}`", + path = output_path.display(), + )); + } + } } } From d61b0e782f1a37594f06467ba8a88605d01ac774 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:38:46 +0000 Subject: [PATCH 37/42] Rustup to rustc 1.82.0-nightly (3e9bd8b56 2024-08-08) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 827956c98cf29..96c467e091cff 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-08-08" +channel = "nightly-2024-08-09" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" From d515e881a7b7ad5ba0e55c82391b881dc4058925 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:51:43 +0000 Subject: [PATCH 38/42] Disable f16 and f128 in compiler-builtins when running rustc tests --- ...le-f16-and-f128-in-compiler-builtins.patch | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch diff --git a/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch b/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch new file mode 100644 index 0000000000000..ada35145e2937 --- /dev/null +++ b/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch @@ -0,0 +1,25 @@ +From 175d52c5e1779764b66777db1e6f172c2dc365ff Mon Sep 17 00:00:00 2001 +From: bjorn3 <17426603+bjorn3@users.noreply.github.com> +Date: Fri, 9 Aug 2024 15:44:51 +0000 +Subject: [PATCH] Disable f16 and f128 in compiler-builtins + +--- + library/sysroot/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml +index 7165c3e48af..968552ad435 100644 +--- a/library/sysroot/Cargo.toml ++++ b/library/sysroot/Cargo.toml +@@ -11,7 +11,7 @@ test = { path = "../test" } + + # Forward features to the `std` crate as necessary + [features] +-default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"] ++default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind", "compiler-builtins-no-f16-f128"] + backtrace = ["std/backtrace"] + compiler-builtins-c = ["std/compiler-builtins-c"] + compiler-builtins-mem = ["std/compiler-builtins-mem"] +-- +2.34.1 + From 0e20a762f12f1f0262d9d7e5b438b89e95d29d30 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:59:30 +0000 Subject: [PATCH 39/42] Stop using a custom Cargo.toml and Cargo.lock for the standard library The rust-src component now ships a working copy of both. --- build_system/prepare.rs | 30 --- patches/stdlib-lock.toml | 455 --------------------------------------- 2 files changed, 485 deletions(-) delete mode 100644 patches/stdlib-lock.toml diff --git a/build_system/prepare.rs b/build_system/prepare.rs index 5525a5f63e93b..be0bed0f4e636 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -22,36 +22,6 @@ pub(crate) fn prepare_stdlib(dirs: &Dirs, rustc: &Path) { assert!(sysroot_src_orig.exists()); apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs)); - - std::fs::write( - STDLIB_SRC.to_path(dirs).join("Cargo.toml"), - r#" -[workspace] -resolver = "1" -members = ["./library/sysroot"] - -[patch.crates-io] -rustc-std-workspace-core = { path = "./library/rustc-std-workspace-core" } -rustc-std-workspace-alloc = { path = "./library/rustc-std-workspace-alloc" } -rustc-std-workspace-std = { path = "./library/rustc-std-workspace-std" } - -# 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 -"#, - ) - .unwrap(); - - let source_lockfile = RelPath::PATCHES.to_path(dirs).join("stdlib-lock.toml"); - let target_lockfile = STDLIB_SRC.to_path(dirs).join("Cargo.lock"); - fs::copy(source_lockfile, target_lockfile).unwrap(); } pub(crate) struct GitRepo { diff --git a/patches/stdlib-lock.toml b/patches/stdlib-lock.toml deleted file mode 100644 index b68e9c2f0d075..0000000000000 --- a/patches/stdlib-lock.toml +++ /dev/null @@ -1,455 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "compiler_builtins", - "gimli 0.29.0", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "alloc" -version = "0.0.0" -dependencies = [ - "compiler_builtins", - "core", - "rand", - "rand_xorshift", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - -[[package]] -name = "cc" -version = "1.0.97" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "compiler_builtins" -version = "0.1.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb58b199190fcfe0846f55a3b545cd6b07a34bdd5930a476ff856f3ebcc5558a" -dependencies = [ - "cc", - "rustc-std-workspace-core", -] - -[[package]] -name = "core" -version = "0.0.0" -dependencies = [ - "rand", - "rand_xorshift", -] - -[[package]] -name = "cupid" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bad352a84b567cc38a5854e3aa8ee903cb8519a25d0b799b739bafffd1f91a1" -dependencies = [ - "gcc", - "rustc_version", -] - -[[package]] -name = "dlmalloc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a" -dependencies = [ - "compiler_builtins", - "libc", - "rustc-std-workspace-core", -] - -[[package]] -name = "fortanix-sgx-abi" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cafc2274c10fab234f176b25903ce17e690fca7597090d50880e047a0389c5" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - -[[package]] -name = "getopts" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" -dependencies = [ - "rustc-std-workspace-core", - "rustc-std-workspace-std", - "unicode-width", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "allocator-api2", - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -dependencies = [ - "rustc-std-workspace-core", -] - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "object" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" -dependencies = [ - "compiler_builtins", - "memchr", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "panic_abort" -version = "0.0.0" -dependencies = [ - "alloc", - "cfg-if", - "compiler_builtins", - "core", - "libc", -] - -[[package]] -name = "panic_unwind" -version = "0.0.0" -dependencies = [ - "alloc", - "cfg-if", - "compiler_builtins", - "core", - "libc", - "unwind", -] - -[[package]] -name = "proc_macro" -version = "0.0.0" -dependencies = [ - "core", - "std", -] - -[[package]] -name = "profiler_builtins" -version = "0.0.0" -dependencies = [ - "cc", - "compiler_builtins", - "core", -] - -[[package]] -name = "r-efi" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e935efc5854715dfc0a4c9ef18dc69dee0ec3bf9cc3ab740db831c0fdd86a3" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "r-efi-alloc" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d6f09fe2b6ad044bc3d2c34ce4979796581afd2f1ebc185837e02421e02fd7" -dependencies = [ - "compiler_builtins", - "r-efi", - "rustc-std-workspace-core", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - -[[package]] -name = "rand_xorshift" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - -[[package]] -name = "rustc-std-workspace-alloc" -version = "1.99.0" -dependencies = [ - "alloc", -] - -[[package]] -name = "rustc-std-workspace-core" -version = "1.99.0" -dependencies = [ - "core", -] - -[[package]] -name = "rustc-std-workspace-std" -version = "1.99.0" -dependencies = [ - "std", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "std" -version = "0.0.0" -dependencies = [ - "addr2line", - "alloc", - "cfg-if", - "compiler_builtins", - "core", - "dlmalloc", - "fortanix-sgx-abi", - "hashbrown", - "hermit-abi", - "libc", - "miniz_oxide", - "object", - "panic_abort", - "panic_unwind", - "profiler_builtins", - "r-efi", - "r-efi-alloc", - "rand", - "rand_xorshift", - "rustc-demangle", - "std_detect", - "unwind", - "wasi", -] - -[[package]] -name = "std_detect" -version = "0.1.5" -dependencies = [ - "cfg-if", - "compiler_builtins", - "cupid", - "libc", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "sysroot" -version = "0.0.0" -dependencies = [ - "proc_macro", - "std", - "test", -] - -[[package]] -name = "test" -version = "0.0.0" -dependencies = [ - "core", - "getopts", - "libc", - "std", -] - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", - "rustc-std-workspace-std", -] - -[[package]] -name = "unwind" -version = "0.0.0" -dependencies = [ - "cfg-if", - "compiler_builtins", - "core", - "libc", - "unwinding", -] - -[[package]] -name = "unwinding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b" -dependencies = [ - "compiler_builtins", - "gimli 0.28.1", - "rustc-std-workspace-core", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] From 69b3f5a426a5c1c05236a45b36f6679d95fbe01b Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:13:39 +0000 Subject: [PATCH 40/42] Couple of minor cleanups --- build_system/build_sysroot.rs | 1 - build_system/tests.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index ed8b5b906d28f..e41f6c5e709e2 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -312,7 +312,6 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option { let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o")); let mut build_rtstartup_cmd = Command::new(&compiler.rustc); build_rtstartup_cmd - .arg("-Ainternal_features") // Missing #[allow(internal_features)] .arg("--target") .arg(&compiler.triple) .arg("--emit=obj") diff --git a/build_system/tests.rs b/build_system/tests.rs index 3a88824bf3635..38c3786a94a42 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -438,7 +438,7 @@ impl<'a> TestRunner<'a> { cmd.arg("-L"); cmd.arg(format!("crate={}", BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).display())); cmd.arg("--out-dir"); - cmd.arg(format!("{}", BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).display())); + cmd.arg(BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs)); cmd.arg("-Cdebuginfo=2"); cmd.arg("--target"); cmd.arg(&self.target_compiler.triple); From 6e5873c08c13b7aebae6e277caa39177e6c2b5e3 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:23:50 +0000 Subject: [PATCH 41/42] Use ar_archive_writer from sysroot for cg_clif --- compiler/rustc_codegen_cranelift/Cargo.lock | 10 ---------- compiler/rustc_codegen_cranelift/Cargo.toml | 1 - compiler/rustc_codegen_cranelift/src/lib.rs | 1 + 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/Cargo.lock b/compiler/rustc_codegen_cranelift/Cargo.lock index 741a1748fec98..02d4d98dc4212 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.lock +++ b/compiler/rustc_codegen_cranelift/Cargo.lock @@ -20,15 +20,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "ar_archive_writer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2bcb7cf51decfbbfc7ef476e28b0775b13e5eb1190f8b7df145cd53d4f4374" -dependencies = [ - "object", -] - [[package]] name = "arbitrary" version = "1.3.2" @@ -367,7 +358,6 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar_archive_writer", "cranelift-codegen", "cranelift-frontend", "cranelift-jit", diff --git a/compiler/rustc_codegen_cranelift/Cargo.toml b/compiler/rustc_codegen_cranelift/Cargo.toml index c86919dcdfb7e..a0df502dadc47 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.toml +++ b/compiler/rustc_codegen_cranelift/Cargo.toml @@ -17,7 +17,6 @@ cranelift-object = { version = "0.110.1" } target-lexicon = "0.12.0" gimli = { version = "0.28", default-features = false, features = ["write"]} object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } -ar_archive_writer = "0.3" indexmap = "2.0.0" libloading = { version = "0.8.0", optional = true } diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index f737af25b62ee..21930fa2ddb49 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -12,6 +12,7 @@ #![warn(unused_lifetimes)] // tidy-alphabetical-end +extern crate ar_archive_writer; extern crate jobserver; #[macro_use] extern crate rustc_middle; From 57dd967e7122b55f14027122828cdd8b60a86ad4 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:25:32 +0000 Subject: [PATCH 42/42] Update tidy for new cranelift-bitset crate --- src/tools/tidy/src/deps.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index e23e931b0eb04..89011bbb48f5c 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -192,6 +192,7 @@ const EXCEPTIONS_RUSTBOOK: ExceptionList = &[ const EXCEPTIONS_CRANELIFT: ExceptionList = &[ // tidy-alphabetical-start ("cranelift-bforest", "Apache-2.0 WITH LLVM-exception"), + ("cranelift-bitset", "Apache-2.0 WITH LLVM-exception"), ("cranelift-codegen", "Apache-2.0 WITH LLVM-exception"), ("cranelift-codegen-meta", "Apache-2.0 WITH LLVM-exception"), ("cranelift-codegen-shared", "Apache-2.0 WITH LLVM-exception"), @@ -511,6 +512,7 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[ "bumpalo", "cfg-if", "cranelift-bforest", + "cranelift-bitset", "cranelift-codegen", "cranelift-codegen-meta", "cranelift-codegen-shared",