From 0415c11726b80534deb06fba1b210c40f1968115 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:47:04 +0000 Subject: [PATCH 01/67] Directly raise fatal errors inside the codegen backends As opposed to passing it around through Result. --- src/back/lto.rs | 33 ++++++++++++++++----------------- src/back/write.rs | 7 +++---- src/lib.rs | 12 +++++------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d558dfbc1c455..fcee6b6df6234 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -29,7 +29,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::memmap::Mmap; -use rustc_errors::{DiagCtxtHandle, FatalError}; +use rustc_errors::DiagCtxtHandle; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; use rustc_session::config::Lto; @@ -51,12 +51,11 @@ fn prepare_lto( cgcx: &CodegenContext, each_linked_rlib_for_lto: &[PathBuf], dcx: DiagCtxtHandle<'_>, -) -> Result { +) -> LtoData { let tmp_path = match tempdir() { Ok(tmp_path) => tmp_path, Err(error) => { - eprintln!("Cannot create temporary directory: {}", error); - return Err(FatalError); + dcx.fatal(format!("Cannot create temporary directory: {}", error)); } }; @@ -91,15 +90,14 @@ fn prepare_lto( upstream_modules.push((module, CString::new(name).unwrap())); } Err(e) => { - dcx.emit_err(e); - return Err(FatalError); + dcx.emit_fatal(e); } } } } } - Ok(LtoData { upstream_modules, tmp_path }) + LtoData { upstream_modules, tmp_path } } fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> { @@ -114,10 +112,10 @@ pub(crate) fn run_fat( cgcx: &CodegenContext, each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, -) -> Result, FatalError> { +) -> ModuleCodegen { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); - let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx); /*let symbols_below_threshold = lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::>();*/ fat_lto( @@ -137,7 +135,7 @@ fn fat_lto( mut serialized_modules: Vec<(SerializedModule, CString)>, tmp_path: TempDir, //symbols_below_threshold: &[String], -) -> Result, FatalError> { +) -> ModuleCodegen { let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module"); info!("going for a fat lto"); @@ -261,7 +259,7 @@ fn fat_lto( // of now. module.module_llvm.temp_dir = Some(tmp_path); - Ok(module) + module } pub struct ModuleBuffer(PathBuf); @@ -286,10 +284,10 @@ pub(crate) fn run_thin( each_linked_rlib_for_lto: &[PathBuf], modules: Vec<(String, ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, -) -> Result<(Vec>, Vec), FatalError> { +) -> (Vec>, Vec) { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); - let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx); if cgcx.opts.cg.linker_plugin_lto.enabled() { unreachable!( "We should never reach this case if the LTO step \ @@ -355,7 +353,7 @@ fn thin_lto( tmp_path: TempDir, cached_modules: Vec<(SerializedModule, WorkProduct)>, //_symbols_below_threshold: &[String], -) -> Result<(Vec>, Vec), FatalError> { +) -> (Vec>, Vec) { let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis"); info!("going for that thin, thin LTO"); @@ -518,13 +516,13 @@ fn thin_lto( // TODO: save the directory so that it gets deleted later. std::mem::forget(tmp_path); - Ok((opt_jobs, copy_jobs)) + (opt_jobs, copy_jobs) } pub fn optimize_thin_module( thin_module: ThinModule, _cgcx: &CodegenContext, -) -> Result, FatalError> { +) -> ModuleCodegen { //let dcx = cgcx.create_dcx(); //let module_name = &thin_module.shared.module_names[thin_module.idx]; @@ -634,7 +632,8 @@ pub fn optimize_thin_module( save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); } }*/ - Ok(module) + #[allow(clippy::let_and_return)] + module } pub struct ThinBuffer { diff --git a/src/back/write.rs b/src/back/write.rs index c1231142c6585..84bc70162719f 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -6,7 +6,6 @@ use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, Mo use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_fs_util::link_or_copy; use rustc_session::config::OutputType; -use rustc_span::fatal_error::FatalError; use rustc_target::spec::SplitDebuginfo; use crate::base::add_pic_option; @@ -17,7 +16,7 @@ pub(crate) fn codegen( cgcx: &CodegenContext, module: ModuleCodegen, config: &ModuleConfig, -) -> Result { +) -> CompiledModule { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); @@ -246,7 +245,7 @@ pub(crate) fn codegen( } } - Ok(module.into_compiled_module( + module.into_compiled_module( config.emit_obj != EmitObj::None, cgcx.target_can_use_split_dwarf && cgcx.split_debuginfo == SplitDebuginfo::Unpacked, config.emit_bc, @@ -254,7 +253,7 @@ pub(crate) fn codegen( config.emit_ir, &cgcx.output_filenames, cgcx.invocation_temp.as_deref(), - )) + ) } pub(crate) fn save_temp_bitcode( diff --git a/src/lib.rs b/src/lib.rs index 4025aba82da32..2d7df79ba95fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,6 @@ use rustc_middle::util::Providers; use rustc_session::Session; use rustc_session::config::{OptLevel, OutputFilenames}; use rustc_span::Symbol; -use rustc_span::fatal_error::FatalError; use rustc_target::spec::RelocModel; use tempfile::TempDir; @@ -362,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } @@ -373,7 +372,7 @@ impl WriteBackendMethods for GccCodegenBackend { each_linked_rlib_for_lto: &[PathBuf], modules: Vec<(String, Self::ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, - ) -> Result<(Vec>, Vec), FatalError> { + ) -> (Vec>, Vec) { back::lto::run_thin(cgcx, each_linked_rlib_for_lto, modules, cached_modules) } @@ -390,15 +389,14 @@ impl WriteBackendMethods for GccCodegenBackend { _dcx: DiagCtxtHandle<'_>, module: &mut ModuleCodegen, config: &ModuleConfig, - ) -> Result<(), FatalError> { + ) { module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level)); - Ok(()) } fn optimize_thin( cgcx: &CodegenContext, thin: ThinModule, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::optimize_thin_module(thin, cgcx) } @@ -406,7 +404,7 @@ impl WriteBackendMethods for GccCodegenBackend { cgcx: &CodegenContext, module: ModuleCodegen, config: &ModuleConfig, - ) -> Result { + ) -> CompiledModule { back::write::codegen(cgcx, module, config) } From a224101061040360986a1d553039ae0627fb1026 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Aug 2025 17:18:15 +0200 Subject: [PATCH 02/67] Merge commit 'feb42827f11a7ae241ceecc81e9ae556fb6ba214' into subtree-update_cg_gcc_2025-08-26 --- .github/workflows/m68k.yml | 42 ++++++++++++++------------------ Cargo.lock | 8 +++--- Cargo.toml | 2 +- build_system/src/fmt.rs | 30 +++++++++++++++++++++-- build_system/src/test.rs | 2 +- libgccjit.version | 2 +- rust-toolchain | 2 +- src/intrinsic/simd.rs | 1 - src/lib.rs | 2 +- tests/failing-run-make-tests.txt | 3 --- tests/failing-ui-tests.txt | 4 ++- tests/run/int.rs | 10 +++----- tests/run/int_overflow.rs | 2 +- tests/run/structs.rs | 8 ++---- tests/run/volatile.rs | 8 ++---- tests/run/volatile2.rs | 12 +++++++-- 16 files changed, 77 insertions(+), 61 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 759d0d59e2685..e49c62d6c9315 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -82,20 +82,16 @@ jobs: - name: Build sample project with target defined as JSON spec run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json + ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json ./y.sh clean all - name: Build run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu + ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu - # FIXME: since https://github.com/rust-lang/rust/pull/140809, we cannot run programs for architectures not - # supported by the object crate, since this adds a dependency on symbols.o for the panic runtime. - # And as such, a wrong order of the object files in the linker command now fails with an undefined reference - # to some symbols like __rustc::rust_panic. - #CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu + CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu ./y.sh clean all - name: Prepare dependencies @@ -104,23 +100,21 @@ jobs: git config --global user.name "User" ./y.sh prepare --cross - # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. - #- name: Run tests - #run: | - #./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler-builtins-no-f16-f128 ${{ matrix.commands }} - - # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. - #- name: Run Hello World! - #run: | - #./y.sh build --target-triple m68k-unknown-linux-gnu - - #vm_dir=$(pwd)/vm - #cd tests/hello-world - #CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu - #sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ - #sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout - #expected_output="40" - #test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) + - name: Run tests + run: | + ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot ${{ matrix.commands }} + + - name: Run Hello World! + run: | + ./y.sh build --target-triple m68k-unknown-linux-gnu + + vm_dir=$(pwd)/vm + cd tests/hello-world + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu + sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ + sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout + expected_output="40" + test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! diff --git a/Cargo.lock b/Cargo.lock index 7f35c1a80bda7..a5b972baf98e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,18 +56,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae99a89184220d967dd300139f2d2ae7d52c1a69d632b24aacc57c54625254ce" +checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24edb7bfe2b7b27c6d09ed23eebfcab0b359c8fe978433f902943e6f127a0f1b" +checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 193348d1ef608..6031933bd2d2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default = ["master"] [dependencies] object = { version = "0.37.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" -gccjit = "2.7" +gccjit = "2.8" #gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } # Local copy. diff --git a/build_system/src/fmt.rs b/build_system/src/fmt.rs index 7e6594f50f93d..91535f217e351 100644 --- a/build_system/src/fmt.rs +++ b/build_system/src/fmt.rs @@ -1,7 +1,7 @@ use std::ffi::OsStr; use std::path::Path; -use crate::utils::run_command_with_output; +use crate::utils::{run_command_with_output, walk_dir}; fn show_usage() { println!( @@ -32,5 +32,31 @@ pub fn run() -> Result<(), String> { if check { &[&"cargo", &"fmt", &"--check"] } else { &[&"cargo", &"fmt"] }; run_command_with_output(cmd, Some(Path::new(".")))?; - run_command_with_output(cmd, Some(Path::new("build_system"))) + run_command_with_output(cmd, Some(Path::new("build_system")))?; + + run_rustfmt_recursively("tests/run", check) +} + +fn run_rustfmt_recursively

(dir: P, check: bool) -> Result<(), String> +where + P: AsRef, +{ + walk_dir( + dir, + &mut |dir| run_rustfmt_recursively(dir, check), + &mut |file_path| { + if file_path.extension().filter(|ext| ext == &OsStr::new("rs")).is_some() { + let rustfmt_cmd: &[&dyn AsRef] = if check { + &[&"rustfmt", &"--check", &file_path] + } else { + &[&"rustfmt", &file_path] + }; + + run_command_with_output(rustfmt_cmd, Some(Path::new("."))) + } else { + Ok(()) + } + }, + true, + ) } diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 2c8271c36a94a..3dd3fce2eec5d 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -531,7 +531,7 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result { r#"change-id = 115898 [rust] -codegen-backends = [] +codegen-backends = ["gcc"] deny-warnings = false verbose-tests = true diff --git a/libgccjit.version b/libgccjit.version index f62154968d3de..dc9a00128646e 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -04ce66d8c918de9273bd7101638ad8724edf5e21 +4e995bd73c4490edfe5080ec6014d63aa9abed5f diff --git a/rust-toolchain b/rust-toolchain index 058e734be5cf5..04d33dfb116ce 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-08-03" +channel = "nightly-2025-08-25" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs index fdc15d580effc..41363d6313d69 100644 --- a/src/intrinsic/simd.rs +++ b/src/intrinsic/simd.rs @@ -1497,7 +1497,6 @@ fn simd_funnel_shift<'a, 'gcc, 'tcx>( let index = bx.context.new_rvalue_from_int(bx.int_type, i as i32); let a_val = bx.context.new_vector_access(None, a, index).to_rvalue(); let a_val = bx.context.new_bitcast(None, a_val, unsigned_type); - // TODO: we probably need to use gcc_int_cast instead. let a_val = bx.gcc_int_cast(a_val, new_int_type); let b_val = bx.context.new_vector_access(None, b, index).to_rvalue(); let b_val = bx.context.new_bitcast(None, b_val, unsigned_type); diff --git a/src/lib.rs b/src/lib.rs index 2d7df79ba95fa..ff1708d6e957f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> ModuleCodegen { + ) -> Result, FatalError> { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } diff --git a/tests/failing-run-make-tests.txt b/tests/failing-run-make-tests.txt index 29032b321fa72..c5e22970c6605 100644 --- a/tests/failing-run-make-tests.txt +++ b/tests/failing-run-make-tests.txt @@ -6,7 +6,6 @@ tests/run-make/doctests-keep-binaries/ tests/run-make/doctests-runtool/ tests/run-make/emit-shared-files/ tests/run-make/exit-code/ -tests/run-make/issue-64153/ tests/run-make/llvm-ident/ tests/run-make/native-link-modifier-bundle/ tests/run-make/remap-path-prefix-dwarf/ @@ -34,8 +33,6 @@ tests/run-make/c-link-to-rust-staticlib/ tests/run-make/foreign-double-unwind/ tests/run-make/foreign-exceptions/ tests/run-make/glibc-staticlib-args/ -tests/run-make/issue-36710/ -tests/run-make/issue-68794-textrel-on-minimal-lib/ tests/run-make/lto-smoke-c/ tests/run-make/return-non-c-like-enum/ diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 41fb4729c07d4..e2615bce190e0 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -20,7 +20,7 @@ tests/ui/drop/dynamic-drop.rs tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs tests/ui/simd/issue-17170.rs tests/ui/simd/issue-39720.rs -tests/ui/issues/issue-14875.rs +tests/ui/drop/panic-during-drop-14875.rs tests/ui/issues/issue-29948.rs tests/ui/process/println-with-broken-pipe.rs tests/ui/lto/thin-lto-inlines2.rs @@ -86,3 +86,5 @@ tests/ui/panics/unwind-force-no-unwind-tables.rs tests/ui/attributes/fn-align-dyn.rs tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs tests/ui/explicit-tail-calls/recursion-etc.rs +tests/ui/explicit-tail-calls/indexer.rs +tests/ui/explicit-tail-calls/drop-order.rs diff --git a/tests/run/int.rs b/tests/run/int.rs index e20ecc23679d6..78675acb5447b 100644 --- a/tests/run/int.rs +++ b/tests/run/int.rs @@ -7,12 +7,10 @@ fn main() { use std::hint::black_box; macro_rules! check { - ($ty:ty, $expr:expr) => { - { - const EXPECTED: $ty = $expr; - assert_eq!($expr, EXPECTED); - } - }; + ($ty:ty, $expr:expr) => {{ + const EXPECTED: $ty = $expr; + assert_eq!($expr, EXPECTED); + }}; } check!(u32, (2220326408_u32 + black_box(1)) >> (32 - 6)); diff --git a/tests/run/int_overflow.rs b/tests/run/int_overflow.rs index 78872159f62da..78e1cac57e03f 100644 --- a/tests/run/int_overflow.rs +++ b/tests/run/int_overflow.rs @@ -12,7 +12,7 @@ fn main() { let arg_count = std::env::args().count(); let int = isize::MAX; - let _int = int + arg_count as isize; // overflow + let _int = int + arg_count as isize; // overflow // If overflow checking is disabled, we should reach here. #[cfg(not(debug_assertions))] diff --git a/tests/run/structs.rs b/tests/run/structs.rs index da73cbed9ae97..e08e67837bec6 100644 --- a/tests/run/structs.rs +++ b/tests/run/structs.rs @@ -27,12 +27,8 @@ fn one() -> isize { #[no_mangle] extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { - let test = Test { - field: one(), - }; - let two = Two { - two: 2, - }; + let test = Test { field: one() }; + let two = Two { two: 2 }; unsafe { libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two); diff --git a/tests/run/volatile.rs b/tests/run/volatile.rs index 94a7bdc5c0668..dc11fbfa600d5 100644 --- a/tests/run/volatile.rs +++ b/tests/run/volatile.rs @@ -12,15 +12,11 @@ struct Struct { func: unsafe fn(*const ()), } -fn func(_ptr: *const ()) { -} +fn func(_ptr: *const ()) {} fn main() { let mut x = MaybeUninit::<&Struct>::uninit(); - x.write(&Struct { - pointer: std::ptr::null(), - func, - }); + x.write(&Struct { pointer: std::ptr::null(), func }); let x = unsafe { x.assume_init() }; let value = unsafe { (x as *const Struct).read_volatile() }; println!("{:?}", value); diff --git a/tests/run/volatile2.rs b/tests/run/volatile2.rs index bdcb82598789c..ada112687d3b4 100644 --- a/tests/run/volatile2.rs +++ b/tests/run/volatile2.rs @@ -7,7 +7,14 @@ mod libc { #[link(name = "c")] extern "C" { pub fn sigaction(signum: i32, act: *const sigaction, oldact: *mut sigaction) -> i32; - pub fn mmap(addr: *mut (), len: usize, prot: i32, flags: i32, fd: i32, offset: i64) -> *mut (); + pub fn mmap( + addr: *mut (), + len: usize, + prot: i32, + flags: i32, + fd: i32, + offset: i64, + ) -> *mut (); pub fn mprotect(addr: *mut (), len: usize, prot: i32) -> i32; } @@ -54,7 +61,8 @@ fn main() { libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, -1, 0, - ).cast(); + ) + .cast(); if STORAGE == libc::MAP_FAILED { panic!("error: mmap failed"); } From 059f00d46368e12f5c08268d36fce629b44145b7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Aug 2025 17:25:45 +0200 Subject: [PATCH 03/67] Fix sync conflict --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ff1708d6e957f..2d7df79ba95fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } From 26736f9ad253510299b6a7b4e20799d47f47010c Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Thu, 31 Jul 2025 19:03:22 +0200 Subject: [PATCH 04/67] fix target-pointer-width in tests --- target_specs/m68k-unknown-linux-gnu.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_specs/m68k-unknown-linux-gnu.json b/target_specs/m68k-unknown-linux-gnu.json index 95ea06106fb1b..b13b640a7c7e6 100644 --- a/target_specs/m68k-unknown-linux-gnu.json +++ b/target_specs/m68k-unknown-linux-gnu.json @@ -22,5 +22,5 @@ "unix" ], "target-mcount": "_mcount", - "target-pointer-width": "32" + "target-pointer-width": 32 } From 01ef5520fb5f827d64ac3df239585530b469cc8c Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 28 Aug 2025 12:31:44 -0400 Subject: [PATCH 05/67] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index dc9a00128646e..8ed7e0f5fb088 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -4e995bd73c4490edfe5080ec6014d63aa9abed5f +4a8c8ec7c375a2f6bb5ca832efa45375a590bb5d From c1477c33f4b25acaf565d564bbf37fc92749e098 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 Aug 2025 10:26:29 +0000 Subject: [PATCH 06/67] Special case allocator module submission to avoid special casing it elsewhere A lot of places had special handling just in case they would get an allocator module even though most of these places could never get one or would have a trivial implementation for the allocator module. Moving all handling of the allocator module to a single place simplifies things a fair bit. --- src/back/lto.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index fcee6b6df6234..9d8ce2383f2b1 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -204,7 +204,7 @@ fn fat_lto( let path = tmp_path.path().to_path_buf().join(&module.name); let path = path.to_str().expect("path"); let context = &module.module_llvm.context; - let config = cgcx.config(module.kind); + let config = &cgcx.module_config; // NOTE: we need to set the optimization level here in order for LTO to do its job. context.set_optimization_level(to_gcc_opt_level(config.opt_level)); context.add_command_line_option("-flto=auto"); From fada75d9cdada10354725415b509987723521fec Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Fri, 5 Sep 2025 21:39:29 +0800 Subject: [PATCH 07/67] cg_gcc: run `run-make-cargo` tests --- build_system/src/test.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 3dd3fce2eec5d..1823aa71f408e 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -1083,11 +1083,12 @@ where fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; + test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?; test_rustc_inner(env, args, |_| Ok(false), false, "ui") } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - let result1 = test_rustc_inner( + let run_make_result = test_rustc_inner( env, args, retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), @@ -1095,7 +1096,15 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { "run-make", ); - let result2 = test_rustc_inner( + let run_make_cargo_result = test_rustc_inner( + env, + args, + retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), + false, + "run-make", + ); + + let ui_result = test_rustc_inner( env, args, retain_files_callback("tests/failing-ui-tests.txt", "ui"), @@ -1103,7 +1112,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { "ui", ); - result1.and(result2) + run_make_result.and(run_make_cargo_result).and(ui_result) } fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1120,6 +1129,13 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + )?; + test_rustc_inner( + env, + args, + remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), + false, + "run-make-cargo", ) } From 03aa02fbc0e86b9184d0023e0f3a749b2ddf8c3f Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Fri, 5 Sep 2025 23:56:16 +0200 Subject: [PATCH 08/67] Rework some build_system/utils return value Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com> --- build_system/src/utils.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/build_system/src/utils.rs b/build_system/src/utils.rs index fc948c54b24aa..112322f8688c1 100644 --- a/build_system/src/utils.rs +++ b/build_system/src/utils.rs @@ -112,8 +112,7 @@ pub fn run_command_with_output( cwd: Option<&Path>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, None)?; - check_exit_status(input, cwd, exit_status, None, true)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, true) } pub fn run_command_with_output_and_env( @@ -122,8 +121,7 @@ pub fn run_command_with_output_and_env( env: Option<&HashMap>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, env)?; - check_exit_status(input, cwd, exit_status, None, true)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, true) } #[cfg(not(unix))] @@ -133,8 +131,7 @@ pub fn run_command_with_output_and_env_no_err( env: Option<&HashMap>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, env)?; - check_exit_status(input, cwd, exit_status, None, false)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, false) } pub fn cargo_install(to_install: &str) -> Result<(), String> { From bd33abfa9080be914463591a8db25ade82342187 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:12:19 +0000 Subject: [PATCH 09/67] Remove thin_link_data method from ThinBufferMethods It is only used within cg_llvm. --- src/back/lto.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index 9d8ce2383f2b1..d475d2c7da996 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -650,10 +650,6 @@ impl ThinBufferMethods for ThinBuffer { fn data(&self) -> &[u8] { &[] } - - fn thin_link_data(&self) -> &[u8] { - unimplemented!(); - } } pub struct ThinData; //(Arc); From 79955e1cb513285ff174f435445e2c503511150b Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 4 Sep 2025 15:16:55 +0000 Subject: [PATCH 10/67] Remove want_summary argument from prepare_thin It is always false nowadays. ThinLTO summary writing is instead done by llvm_optimize. --- src/back/lto.rs | 7 ++----- src/lib.rs | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d475d2c7da996..d29bba2570f67 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -305,12 +305,9 @@ pub(crate) fn run_thin( ) } -pub(crate) fn prepare_thin( - module: ModuleCodegen, - _emit_summary: bool, -) -> (String, ThinBuffer) { +pub(crate) fn prepare_thin(module: ModuleCodegen) -> (String, ThinBuffer) { let name = module.name; - //let buffer = ThinBuffer::new(module.module_llvm.context, true, emit_summary); + //let buffer = ThinBuffer::new(module.module_llvm.context, true); let buffer = ThinBuffer::new(&module.module_llvm.context); (name, buffer) } diff --git a/src/lib.rs b/src/lib.rs index 2d7df79ba95fa..f76f933cad4a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -408,11 +408,8 @@ impl WriteBackendMethods for GccCodegenBackend { back::write::codegen(cgcx, module, config) } - fn prepare_thin( - module: ModuleCodegen, - emit_summary: bool, - ) -> (String, Self::ThinBuffer) { - back::lto::prepare_thin(module, emit_summary) + fn prepare_thin(module: ModuleCodegen) -> (String, Self::ThinBuffer) { + back::lto::prepare_thin(module) } fn serialize_module(_module: ModuleCodegen) -> (String, Self::ModuleBuffer) { From bd303ca85af8799bf01727b6ea6bf0886d1397ca Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Sat, 6 Sep 2025 00:05:09 +0200 Subject: [PATCH 11/67] Always pass git options to run_command Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com> --- build_system/src/prepare.rs | 72 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/build_system/src/prepare.rs b/build_system/src/prepare.rs index 35a6e20fb86bb..1e97e8d932746 100644 --- a/build_system/src/prepare.rs +++ b/build_system/src/prepare.rs @@ -1,5 +1,7 @@ +use std::ffi::OsStr; use std::fs; use std::path::{Path, PathBuf}; +use std::process::Output; use crate::rustc_info::get_rustc_path; use crate::utils::{ @@ -7,6 +9,41 @@ use crate::utils::{ run_command_with_output, walk_dir, }; +// This is needed on systems where nothing is configured. +// git really needs something here, or it will fail. +// Even using --author is not enough. +const GIT_CMD: [&dyn AsRef; 9] = [ + &"git", + &"-c", + &"user.name=None", + &"-c", + &"user.email=none@example.com", + &"-c", + &"core.autocrlf=false", + &"-c", + &"commit.gpgSign=false", +]; + +fn run_git_command( + command: &dyn AsRef, + input: &[&dyn AsRef], + cwd: Option<&Path>, +) -> Result { + let git_cmd = + &GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::>()[..]; + run_command(git_cmd, cwd) +} + +fn run_git_command_with_output( + command: &dyn AsRef, + input: &[&dyn AsRef], + cwd: Option<&Path>, +) -> Result<(), String> { + let git_cmd = + &GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::>()[..]; + run_command_with_output(git_cmd, cwd) +} + fn prepare_libcore( sysroot_path: &Path, libgccjit12_patches: bool, @@ -55,19 +92,12 @@ fn prepare_libcore( run_command(&[&"cp", &"-r", &rustlib_dir.join("library"), &sysroot_dir], None)?; println!("[GIT] init (cwd): `{}`", sysroot_dir.display()); - run_command(&[&"git", &"init"], Some(&sysroot_dir))?; + run_git_command(&"init", &[], Some(&sysroot_dir))?; println!("[GIT] add (cwd): `{}`", sysroot_dir.display()); - run_command(&[&"git", &"add", &"."], Some(&sysroot_dir))?; + run_git_command(&"add", &[&"."], Some(&sysroot_dir))?; println!("[GIT] commit (cwd): `{}`", sysroot_dir.display()); - // This is needed on systems where nothing is configured. - // git really needs something here, or it will fail. - // Even using --author is not enough. - run_command(&[&"git", &"config", &"user.email", &"none@example.com"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"user.name", &"None"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"core.autocrlf", &"false"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"commit.gpgSign", &"false"], Some(&sysroot_dir))?; - run_command(&[&"git", &"commit", &"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?; + run_git_command(&"commit", &[&"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?; let mut patches = Vec::new(); walk_dir( @@ -105,10 +135,11 @@ fn prepare_libcore( for file_path in patches { println!("[GIT] apply `{}`", file_path.display()); let path = Path::new("../../..").join(file_path); - run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?; - run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?; - run_command_with_output( - &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + run_git_command_with_output(&"apply", &[&path], Some(&sysroot_dir))?; + run_git_command_with_output(&"add", &[&"-A"], Some(&sysroot_dir))?; + run_git_command_with_output( + &"commit", + &[&"-m", &format!("Patch {}", path.display())], Some(&sysroot_dir), )?; } @@ -124,10 +155,11 @@ fn prepare_rand() -> Result<(), String> { let rand_dir = Path::new("build/rand"); println!("[GIT] apply `{file_path}`"); let path = Path::new("../..").join(file_path); - run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?; - run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?; - run_command_with_output( - &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + run_git_command_with_output(&"apply", &[&path], Some(rand_dir))?; + run_git_command_with_output(&"add", &[&"-A"], Some(rand_dir))?; + run_git_command_with_output( + &"commit", + &[&"-m", &format!("Patch {}", path.display())], Some(rand_dir), )?; @@ -154,8 +186,8 @@ where println!("`{}` has already been cloned", clone_result.repo_name); } let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name); - run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?; - run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?; + run_git_command(&"checkout", &[&"--", &"."], Some(&repo_path))?; + run_git_command(&"checkout", &[&checkout_commit], Some(&repo_path))?; if let Some(extra) = extra { extra(&repo_path)?; } From a211d63b8381638ee2ac00834103168c184192c6 Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 21 Aug 2025 16:50:54 +0100 Subject: [PATCH 12/67] erase_regions to erase_and_anonymize_regions --- src/type_of.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type_of.rs b/src/type_of.rs index 093f902bc3d86..93202483eed81 100644 --- a/src/type_of.rs +++ b/src/type_of.rs @@ -240,7 +240,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { // Make sure lifetimes are erased, to avoid generating distinct LLVM // types for Rust types that only differ in the choice of lifetimes. - let normal_ty = cx.tcx.erase_regions(self.ty); + let normal_ty = cx.tcx.erase_and_anonymize_regions(self.ty); let mut defer = None; let ty = if self.ty != normal_ty { From 2d2aad3ce623c5047b4263621b4738deab168a54 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 7 Jun 2025 22:56:22 +0200 Subject: [PATCH 13/67] allow `#[rustc_align_static(N)]` on `static`s We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. --- src/consts.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/consts.rs b/src/consts.rs index 619277eba8b83..7fe8fc122b3cc 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -81,6 +81,8 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> { if global.to_rvalue().get_type() != val_llty { global.to_rvalue().set_type(val_llty); } + + // NOTE: Alignment from attributes has already been applied to the allocation. set_global_alignment(self, global, alloc.align); global.global_set_initializer_rvalue(value); From b5b58d1e343c33f36bfa4dd10b69db4e2dc111ac Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 12 Sep 2025 09:49:41 -0500 Subject: [PATCH 14/67] Remove unreachable unsized arg handling in `store_fn_arg/store_arg` in codegen --- src/intrinsic/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index eb0a5336a1f13..84fa56cf90308 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -730,7 +730,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { if self.is_sized_indirect() { OperandValue::Ref(PlaceValue::new_sized(val, self.layout.align.abi)).store(bx, dst) } else if self.is_unsized_indirect() { - bug!("unsized `ArgAbi` must be handled through `store_fn_arg`"); + bug!("unsized `ArgAbi` cannot be stored"); } else if let PassMode::Cast { ref cast, .. } = self.mode { // FIXME(eddyb): Figure out when the simpler Store is safe, clang // uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}. @@ -797,12 +797,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { OperandValue::Pair(next(), next()).store(bx, dst); } PassMode::Indirect { meta_attrs: Some(_), .. } => { - let place_val = PlaceValue { - llval: next(), - llextra: Some(next()), - align: self.layout.align.abi, - }; - OperandValue::Ref(place_val).store(bx, dst); + bug!("unsized `ArgAbi` cannot be stored"); } PassMode::Direct(_) | PassMode::Indirect { meta_attrs: None, .. } From dbc3ace11c9fd2fe8d22e9d1042cc0ffcd86bf05 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Sep 2025 08:51:29 -0400 Subject: [PATCH 15/67] Update to nightly-2025-09-16 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 04d33dfb116ce..f6c8404296077 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-08-25" +channel = "nightly-2025-09-16" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From b072f38bea38a4fded7c2aa6bec9ea8583fea8c8 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Sep 2025 09:49:55 -0400 Subject: [PATCH 16/67] Ignore failing test --- tests/failing-ui-tests.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index e2615bce190e0..9a44034c127c5 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -88,3 +88,4 @@ tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs tests/ui/explicit-tail-calls/recursion-etc.rs tests/ui/explicit-tail-calls/indexer.rs tests/ui/explicit-tail-calls/drop-order.rs +tests/ui/c-variadic/valid.rs From 8ecf880743ac8ef8fdcb044c6b30c7dd778befe2 Mon Sep 17 00:00:00 2001 From: Karan Janthe Date: Sat, 23 Aug 2025 23:10:48 +0000 Subject: [PATCH 17/67] added typetree support for memcpy --- src/builder.rs | 1 + src/intrinsic/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index f7a7a3f8c7e35..5657620879ca1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1383,6 +1383,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { _src_align: Align, size: RValue<'gcc>, flags: MemFlags, + _tt: Option, // Autodiff TypeTrees are LLVM-only, ignored in GCC backend ) { assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memcpy not supported"); let size = self.intcast(size, self.type_size_t(), false); diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 84fa56cf90308..3b897a1983503 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -771,6 +771,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { scratch_align, bx.const_usize(self.layout.size.bytes()), MemFlags::empty(), + None, ); bx.lifetime_end(scratch, scratch_size); From ee849b0db25b33b95971eb8a3bc78f1f78cfb6c3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Sep 2025 17:57:17 -0400 Subject: [PATCH 18/67] Switch to Ubuntu Plucky repository because Oracular is not supported anymore --- .github/workflows/stdarch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stdarch.yml b/.github/workflows/stdarch.yml index 20d009f08a798..184f122cc1c17 100644 --- a/.github/workflows/stdarch.yml +++ b/.github/workflows/stdarch.yml @@ -41,7 +41,7 @@ jobs: # TODO: remove when we have binutils version 2.43 in the repo. - name: Install more recent binutils run: | - echo "deb http://archive.ubuntu.com/ubuntu oracular main universe" | sudo tee /etc/apt/sources.list.d/oracular-copies.list + echo "deb http://archive.ubuntu.com/ubuntu plucky main universe" | sudo tee /etc/apt/sources.list.d/plucky-copies.list sudo apt-get update sudo apt-get install binutils From 7c12d9d4f1fdc4eafea1d42f33b463817d714029 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Sep 2025 19:35:26 -0400 Subject: [PATCH 19/67] Disable funnel shift tests since they fail --- build_system/src/test.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1823aa71f408e..a892d97356ca7 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -714,7 +714,8 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> { let path = get_sysroot_dir().join("sysroot_src/library/coretests"); let _ = remove_dir_all(path.join("target")); // TODO(antoyo): run in release mode when we fix the failures. - run_cargo_command(&[&"test"], Some(&path), env, args)?; + // TODO(antoyo): Stop skipping funnel shift tests when those operations are fixed. + run_cargo_command(&[&"test", &"--", &"--skip", &"test_funnel_shift"], Some(&path), env, args)?; Ok(()) } From b9a2e046f0d936051802039855085514e4ec77ca Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 21 Sep 2025 13:48:22 +0900 Subject: [PATCH 20/67] Support ctr and lr as clobber-only registers in PowerPC inline assembly --- src/asm.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index 17e2e028b16fa..a14881c502cf3 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -698,8 +698,12 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => "v", - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) - | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::cr + | PowerPCInlineAsmRegClass::ctr + | PowerPCInlineAsmRegClass::lr + | PowerPCInlineAsmRegClass::xer, + ) => { unreachable!("clobber-only") } InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r", @@ -777,8 +781,12 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => { cx.type_vector(cx.type_i32(), 4) } - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) - | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::cr + | PowerPCInlineAsmRegClass::ctr + | PowerPCInlineAsmRegClass::lr + | PowerPCInlineAsmRegClass::xer, + ) => { unreachable!("clobber-only") } InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(), From 8f244364983a740eca94e5b4cc28a14070c3b3e4 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 7 Sep 2025 12:31:35 -0400 Subject: [PATCH 21/67] Add panic=immediate-abort --- src/base.rs | 4 ++-- src/intrinsic/mod.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index e9d72e457a086..e8672f49580b6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -15,9 +15,9 @@ use rustc_middle::mir::mono::Visibility; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::Symbol; +use rustc_target::spec::RelocModel; #[cfg(feature = "master")] use rustc_target::spec::SymbolVisibility; -use rustc_target::spec::{PanicStrategy, RelocModel}; use crate::builder::Builder; use crate::context::CodegenCx; @@ -101,7 +101,7 @@ pub fn compile_codegen_unit( // Instantiate monomorphizations without filling out definitions yet... let context = new_context(tcx); - if tcx.sess.panic_strategy() == PanicStrategy::Unwind { + if tcx.sess.panic_strategy().unwinds() { context.add_command_line_option("-fexceptions"); context.add_driver_option("-fexceptions"); } diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 84fa56cf90308..a915f5d64188f 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -29,7 +29,6 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, Instance, Ty}; use rustc_span::{Span, Symbol, sym}; use rustc_target::callconv::{ArgAbi, PassMode}; -use rustc_target::spec::PanicStrategy; #[cfg(feature = "master")] use crate::abi::FnAbiGccExt; @@ -1334,7 +1333,7 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>( _catch_func: RValue<'gcc>, dest: PlaceRef<'tcx, RValue<'gcc>>, ) { - if bx.sess().panic_strategy() == PanicStrategy::Abort { + if !bx.sess().panic_strategy().unwinds() { bx.call(bx.type_void(), None, None, try_func, &[data], None, None); // Return 0 unconditionally from the intrinsic call; // we can never unwind. From 994d3e1fd9c795f24e7546c5e375884d5cebb36e Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Tue, 16 Sep 2025 02:23:24 -0400 Subject: [PATCH 22/67] Add an attribute to check the number of lanes in a SIMD vector after monomorphization Unify zero-length and oversized SIMD errors --- src/context.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 665cf22ddbaee..9815fb07eaae9 100644 --- a/src/context.rs +++ b/src/context.rs @@ -529,7 +529,10 @@ impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> { impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { - if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { + if let LayoutError::SizeOverflow(_) + | LayoutError::InvalidSimd { .. } + | LayoutError::ReferencesError(_) = err + { self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic())) } else { self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) @@ -545,7 +548,9 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { span: Span, fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { - if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { + if let FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::InvalidSimd { .. }) = + err + { self.tcx.dcx().emit_fatal(respan(span, err)) } else { match fn_abi_request { From 7587323505cba4a5c39599f69921d0bec65c1dce Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 28 Sep 2025 12:08:44 -0400 Subject: [PATCH 23/67] Add a leading dash to linker plugin arguments in the gcc codegen --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f76f933cad4a5..ec7eab8489ab8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,6 +184,10 @@ impl CodegenBackend for GccCodegenBackend { crate::DEFAULT_LOCALE_RESOURCE } + fn name(&self) -> &'static str { + "gcc" + } + fn init(&self, _sess: &Session) { #[cfg(feature = "master")] { From 9159b616298016af15361ba91aedd8fd343e6d0e Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 28 Sep 2025 14:40:39 -0700 Subject: [PATCH 24/67] remove explicit deref of AbiAlign for most methods Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference. --- src/context.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/context.rs b/src/context.rs index 9815fb07eaae9..c9ae96777de44 100644 --- a/src/context.rs +++ b/src/context.rs @@ -147,7 +147,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { let layout = tcx .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(rust_type)) .unwrap(); - let align = layout.align.abi.bytes(); + let align = layout.align.bytes(); // For types with size 1, the alignment can be 1 and only 1 // So, we can skip the call to ``get_aligned`. // In the future, we can add a GCC API to query the type align, @@ -186,9 +186,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { (i128_type, u128_type) } else { /*let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.i128)).unwrap(); - let i128_align = layout.align.abi.bytes(); + let i128_align = layout.align.bytes(); let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.u128)).unwrap(); - let u128_align = layout.align.abi.bytes();*/ + let u128_align = layout.align.bytes();*/ // TODO(antoyo): re-enable the alignment when libgccjit fixed the issue in // gcc_jit_context_new_array_constructor (it should not use reinterpret_cast). From a2b536a2b4cf362392d892fc53a8ca131add3319 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 29 Sep 2025 09:31:00 -0400 Subject: [PATCH 25/67] Update to nightly-2025-09-30 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index f6c8404296077..ec625481add1b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-09-16" +channel = "nightly-2025-09-30" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From 0127601faae6b2ff9c43f5c2ba694b47fff52413 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 14:44:40 -0400 Subject: [PATCH 26/67] Stop ignoring the clippy lint suspicious_else_formatting --- src/intrinsic/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index eb0bd9cf71f4f..db9f32bad5a77 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -272,10 +272,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc .or_else(|| get_simple_function_f128(self, name)) .or_else(|| get_simple_function_f128_2args(self, name)); - // FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved: - // https://github.com/rust-lang/rust-clippy/issues/12497 - // and leave `else if use_integer_compare` to be placed "as is". - #[allow(clippy::suspicious_else_formatting)] let value = match name { _ if simple.is_some() => { let func = simple.expect("simple intrinsic function"); From 3fdf349ba18b56addcb059bdd146ab07455e3264 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 17:29:43 -0400 Subject: [PATCH 27/67] Fix and re-enable mini-core test --- example/mini_core.rs | 2 +- example/mini_core_hello_world.rs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 9dfb12be24363..5afedf9d40172 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -671,7 +671,7 @@ pub mod intrinsics { #[rustc_intrinsic] pub unsafe fn ctlz_nonzero(x: T) -> u32; #[rustc_intrinsic] - pub fn needs_drop() -> bool; + pub const fn needs_drop() -> bool; #[rustc_intrinsic] pub fn bitreverse(x: T) -> T; #[rustc_intrinsic] diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 092fd6a764099..1e601d42413cb 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -198,8 +198,6 @@ fn main() { assert_eq!(intrinsics::align_of::() as u8, 2); assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8); - /* - * TODO: re-enable in the next sync. let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); let slice_needs_drop = const { intrinsics::needs_drop::<[u8]>() }; @@ -208,7 +206,6 @@ fn main() { assert!(noisy_drop); let noisy_unsized_drop = const { intrinsics::needs_drop::() }; assert!(noisy_unsized_drop); - */ Unique { pointer: 0 as *const &str, From 5e6e797e79d411e0bc787689896947fb2b139ef7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 24 Sep 2025 13:06:00 -0400 Subject: [PATCH 28/67] Remove passing run-make tests --- tests/failing-run-make-tests.txt | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tests/failing-run-make-tests.txt b/tests/failing-run-make-tests.txt index c5e22970c6605..822aaec0edeb5 100644 --- a/tests/failing-run-make-tests.txt +++ b/tests/failing-run-make-tests.txt @@ -1,35 +1,11 @@ -tests/run-make/a-b-a-linker-guard/ -tests/run-make/CURRENT_RUSTC_VERSION/ tests/run-make/cross-lang-lto/ tests/run-make/cross-lang-lto-upstream-rlibs/ -tests/run-make/doctests-keep-binaries/ -tests/run-make/doctests-runtool/ -tests/run-make/emit-shared-files/ -tests/run-make/exit-code/ tests/run-make/llvm-ident/ tests/run-make/native-link-modifier-bundle/ tests/run-make/remap-path-prefix-dwarf/ -tests/run-make/repr128-dwarf/ tests/run-make/rlib-format-packed-bundled-libs/ tests/run-make/rlib-format-packed-bundled-libs-2/ -tests/run-make/rustdoc-determinism/ -tests/run-make/rustdoc-error-lines/ -tests/run-make/rustdoc-map-file/ -tests/run-make/rustdoc-output-path/ -tests/run-make/rustdoc-scrape-examples-invalid-expr/ -tests/run-make/rustdoc-scrape-examples-multiple/ -tests/run-make/rustdoc-scrape-examples-ordering/ -tests/run-make/rustdoc-scrape-examples-remap/ -tests/run-make/rustdoc-scrape-examples-test/ -tests/run-make/rustdoc-scrape-examples-whitespace/ -tests/run-make/rustdoc-scrape-examples-macros/ -tests/run-make/rustdoc-with-out-dir-option/ -tests/run-make/rustdoc-verify-output-files/ -tests/run-make/rustdoc-themes/ -tests/run-make/rustdoc-with-short-out-dir-option/ -tests/run-make/rustdoc-with-output-option/ tests/run-make/arguments-non-c-like-enum/ -tests/run-make/c-link-to-rust-staticlib/ tests/run-make/foreign-double-unwind/ tests/run-make/foreign-exceptions/ tests/run-make/glibc-staticlib-args/ From f951feee5476aaf0eab7f3c7c15b0a7dad0ced36 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 24 Sep 2025 13:05:36 -0400 Subject: [PATCH 29/67] Clean all test directories --- build_system/src/clean.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build_system/src/clean.rs b/build_system/src/clean.rs index a441ed613f949..43f01fdf35ecb 100644 --- a/build_system/src/clean.rs +++ b/build_system/src/clean.rs @@ -69,8 +69,13 @@ fn clean_all() -> Result<(), String> { } fn clean_ui_tests() -> Result<(), String> { - let path = Path::new(crate::BUILD_DIR).join("rust/build/x86_64-unknown-linux-gnu/test/ui/"); - run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?; + let directories = ["run-make", "run-make-cargo", "ui"]; + for directory in directories { + let path = Path::new(crate::BUILD_DIR) + .join("rust/build/x86_64-unknown-linux-gnu/test/") + .join(directory); + run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?; + } Ok(()) } From 8deca81cf289efdb1a10cec19d46633b5ab5a46f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 15:52:03 -0400 Subject: [PATCH 30/67] Fix shifting a value of a smaller type to a bigger type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Bernier --- build_system/src/test.rs | 3 +-- src/int.rs | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index a892d97356ca7..1823aa71f408e 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -714,8 +714,7 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> { let path = get_sysroot_dir().join("sysroot_src/library/coretests"); let _ = remove_dir_all(path.join("target")); // TODO(antoyo): run in release mode when we fix the failures. - // TODO(antoyo): Stop skipping funnel shift tests when those operations are fixed. - run_cargo_command(&[&"test", &"--", &"--skip", &"test_funnel_shift"], Some(&path), env, args)?; + run_cargo_command(&[&"test"], Some(&path), env, args)?; Ok(()) } diff --git a/src/int.rs b/src/int.rs index 9fb7f6bad6844..aa1d3b6b091c6 100644 --- a/src/int.rs +++ b/src/int.rs @@ -83,12 +83,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let a_size = a_type.get_size(); let b_size = b_type.get_size(); match a_size.cmp(&b_size) { - std::cmp::Ordering::Less => { - let a = self.context.new_cast(self.location, a, b_type); - a >> b - } std::cmp::Ordering::Equal => a >> b, - std::cmp::Ordering::Greater => { + _ => { + // NOTE: it is OK to cast even if b has a type bigger than a because b has + // been masked by codegen_ssa before calling Builder::lshr or + // Builder::ashr. let b = self.context.new_cast(self.location, b, a_type); a >> b } @@ -692,12 +691,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let a_size = a_type.get_size(); let b_size = b_type.get_size(); match a_size.cmp(&b_size) { - std::cmp::Ordering::Less => { - let a = self.context.new_cast(self.location, a, b_type); - a << b - } std::cmp::Ordering::Equal => a << b, - std::cmp::Ordering::Greater => { + _ => { + // NOTE: it is OK to cast even if b has a type bigger than a because b has + // been masked by codegen_ssa before calling Builder::shl. let b = self.context.new_cast(self.location, b, a_type); a << b } From 243ef31f1e5684a7ce3f2617beb7267faddf90c1 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 17:26:12 -0400 Subject: [PATCH 31/67] Add test for cross-language LTO --- .github/workflows/release.yml | 17 ++++++++++++++++- tests/cross_lang_lto/Cargo.lock | 7 +++++++ tests/cross_lang_lto/Cargo.toml | 6 ++++++ tests/cross_lang_lto/add.c | 5 +++++ tests/cross_lang_lto/src/main.rs | 18 ++++++++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/cross_lang_lto/Cargo.lock create mode 100644 tests/cross_lang_lto/Cargo.toml create mode 100644 tests/cross_lang_lto/add.c create mode 100644 tests/cross_lang_lto/src/main.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7e2583aad39f..65ceb69190661 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - - name: Run y.sh cargo build + - name: LTO test run: | EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||: @@ -92,6 +92,21 @@ jobs: exit 1 fi + - name: Cross-language LTO test + run: | + pushd tests/cross_lang_lto + gcc -c -flto add.c -masm=intel -fPIC -O3 + ar rcs libadd.a add.o + popd + + EMBED_LTO_BITCODE=1 CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml + call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||: + if [ $call_found -gt 0 ]; then + echo "ERROR: call my_add found in asm" + echo "Test is done with cross-language LTO enabled, hence inlining should occur across object files" + exit 1 + fi + # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! success_release: diff --git a/tests/cross_lang_lto/Cargo.lock b/tests/cross_lang_lto/Cargo.lock new file mode 100644 index 0000000000000..a0c9d2df383d8 --- /dev/null +++ b/tests/cross_lang_lto/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cross_lang_lto" +version = "0.1.0" diff --git a/tests/cross_lang_lto/Cargo.toml b/tests/cross_lang_lto/Cargo.toml new file mode 100644 index 0000000000000..777e6548df2b7 --- /dev/null +++ b/tests/cross_lang_lto/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "cross_lang_lto" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/tests/cross_lang_lto/add.c b/tests/cross_lang_lto/add.c new file mode 100644 index 0000000000000..cc59f113bc192 --- /dev/null +++ b/tests/cross_lang_lto/add.c @@ -0,0 +1,5 @@ +#include + +uint32_t my_add(uint32_t a, uint32_t b) { + return a + b; +} diff --git a/tests/cross_lang_lto/src/main.rs b/tests/cross_lang_lto/src/main.rs new file mode 100644 index 0000000000000..a7180b3339630 --- /dev/null +++ b/tests/cross_lang_lto/src/main.rs @@ -0,0 +1,18 @@ +/* + * Compile the C code with: + * gcc -c -flto add.c -ffat-lto-objects + * ar rcs libadd.a add.o + * + * Compile the Rust code with: + * EMBED_LTO_BITCODE=1 CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release + */ + +#[link(name="add")] +unsafe extern "C" { + fn my_add(a: u32, b: u32) -> u32; +} + +fn main() { + let res = unsafe { my_add(30, 12) }; + println!("{}", res); +} From c9145e1e58f9fddb8be884978f33d8859c3c5604 Mon Sep 17 00:00:00 2001 From: dianqk Date: Wed, 18 Jun 2025 22:04:48 +0800 Subject: [PATCH 32/67] codegen: Generate `dbg_value` for the ref statement --- src/debuginfo.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 4c8585192a1b1..0f015cc23f52f 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -29,13 +29,24 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> { _variable_alloca: Self::Value, _direct_offset: Size, _indirect_offsets: &[Size], - _fragment: Option>, + _fragment: &Option>, ) { // FIXME(tempdragon): Not sure if this is correct, probably wrong but still keep it here. #[cfg(feature = "master")] _variable_alloca.set_location(_dbg_loc); } + fn dbg_var_value( + &mut self, + _dbg_var: Self::DIVariable, + _dbg_loc: Self::DILocation, + _value: Self::Value, + _direct_offset: Size, + _indirect_offsets: &[Size], + _fragment: &Option>, + ) { + } + fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) { // TODO(antoyo): insert reference to gdb debug scripts section global. } From 130a8e9ccf51a55f1cd84cd9750850800f0a8821 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:49:01 +0200 Subject: [PATCH 33/67] Add `dejagnu` to the quickstart installation command line --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 859bb1568f4eb..3c6e595d21238 100644 --- a/Readme.md +++ b/Readme.md @@ -57,7 +57,7 @@ To build it (most of these instructions come from [here](https://gcc.gnu.org/onl ```bash $ git clone https://github.com/rust-lang/gcc -$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev +$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev dejagnu $ mkdir gcc-build gcc-install $ cd gcc-build $ ../gcc/configure \ From a90977912c9881b571e08e24914a1dbb560abbf7 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:39:01 +0200 Subject: [PATCH 34/67] Move dejagnu install step to libgccjit tests documentation --- Readme.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 3c6e595d21238..32aa2935aaa09 100644 --- a/Readme.md +++ b/Readme.md @@ -57,7 +57,7 @@ To build it (most of these instructions come from [here](https://gcc.gnu.org/onl ```bash $ git clone https://github.com/rust-lang/gcc -$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev dejagnu +$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev $ mkdir gcc-build gcc-install $ cd gcc-build $ ../gcc/configure \ @@ -70,15 +70,22 @@ $ ../gcc/configure \ $ make -j4 # You can replace `4` with another number depending on how many cores you have. ``` -If you want to run libgccjit tests, you will need to also enable the C++ language in the `configure`: +If you want to run libgccjit tests, you will need to +* Enable the C++ language in the `configure` step: ```bash --enable-languages=jit,c++ ``` +* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests + +```bash +$ sudo apt install dejagnu +``` Then to run libgccjit tests: ```bash +$ sudo apt install dejagnu $ cd gcc # from the `gcc-build` folder $ make check-jit # To run one specific test: From 87c59b812194140dfc16c554c6805c3a280038d5 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:39:52 +0200 Subject: [PATCH 35/67] Remove dejagnu install from libgccjit tests run instructions --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index 32aa2935aaa09..5ebdef15a5cee 100644 --- a/Readme.md +++ b/Readme.md @@ -85,7 +85,6 @@ $ sudo apt install dejagnu Then to run libgccjit tests: ```bash -$ sudo apt install dejagnu $ cd gcc # from the `gcc-build` folder $ make check-jit # To run one specific test: From d7e37d98cc595fcddea93194332de512967d000c Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:40:47 +0200 Subject: [PATCH 36/67] Add colon to Install dejagnu step for consistency --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 5ebdef15a5cee..9cdd59f94f814 100644 --- a/Readme.md +++ b/Readme.md @@ -76,7 +76,7 @@ If you want to run libgccjit tests, you will need to ```bash --enable-languages=jit,c++ ``` -* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests +* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests: ```bash $ sudo apt install dejagnu From 5384032d284cccdc12181ba74e9367768901c52f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 3 Oct 2025 11:27:03 -0400 Subject: [PATCH 37/67] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index 8ed7e0f5fb088..93cff753b14d6 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -4a8c8ec7c375a2f6bb5ca832efa45375a590bb5d +0256a7539a83aa26aade8cca138d9c69634a51b1 From b70b3041712b9821395d5244900f4a52a70d3020 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 07:12:55 -0400 Subject: [PATCH 38/67] Remove EMBED_LTO_BITCODE --- .github/workflows/release.yml | 6 +- Readme.md | 10 --- src/back/write.rs | 114 ++++++++++++---------------------- 3 files changed, 41 insertions(+), 89 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65ceb69190661..a577c2eed712c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ jobs: - name: Build run: | ./y.sh prepare --only-libcore - EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot + ./y.sh build --sysroot --release --release-sysroot ./y.sh test --cargo-tests ./y.sh clean all @@ -80,11 +80,11 @@ jobs: # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml - EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - name: LTO test run: | - EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml + CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||: if [ $call_found -gt 0 ]; then echo "ERROR: call my_func found in asm" diff --git a/Readme.md b/Readme.md index 9cdd59f94f814..cd6aeae4b42ea 100644 --- a/Readme.md +++ b/Readme.md @@ -141,16 +141,6 @@ $ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. -### LTO - -To use LTO, you need to set the variable `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`. - -Failing to set `EMBED_LTO_BITCODE` will give you the following error: - -``` -error: failed to copy bitcode to object file: No such file or directory (os error 2) -``` - ### Rustc If you want to run `rustc` directly, you can do so with: diff --git a/src/back/write.rs b/src/back/write.rs index 84bc70162719f..02537e89abada 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -26,11 +26,6 @@ pub(crate) fn codegen( let should_combine_object_files = module.module_llvm.should_combine_object_files; - // NOTE: Only generate object files with GIMPLE when this environment variable is set for - // now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit). - // TODO(antoyo): remove this environment variable. - let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1"); - let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, &module.name, @@ -43,80 +38,44 @@ pub(crate) fn codegen( ); if config.bitcode_needed() { - if fat_lto { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name); + + // TODO(antoyo) + /*if let Some(bitcode_filename) = bc_out.file_name() { + cgcx.prof.artifact_size( + "llvm_bitcode", + bitcode_filename.to_string_lossy(), + data.len() as u64, + ); + }*/ + + if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof - .generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name); - - // TODO(antoyo) - /*if let Some(bitcode_filename) = bc_out.file_name() { - cgcx.prof.artifact_size( - "llvm_bitcode", - bitcode_filename.to_string_lossy(), - data.len() as u64, - ); - }*/ - - if config.emit_bc || config.emit_obj == EmitObj::Bitcode { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_emit_bitcode", - &*module.name, - ); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - - if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_embed_bitcode", - &*module.name, - ); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - context.add_command_line_option("-ffat-lto-objects"); - // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - } else { - if config.emit_bc || config.emit_obj == EmitObj::Bitcode { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_emit_bitcode", - &*module.name, - ); - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - - if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { - // TODO(antoyo): we might want to emit to emit an error here, saying to set the - // environment variable EMBED_LTO_BITCODE. - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_embed_bitcode", - &*module.name, - ); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + .generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. + context.add_command_line_option("-ffat-lto-objects"); + context + .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); + } - // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } + if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name); + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.add_command_line_option("-ffat-lto-objects"); + // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). + context + .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); } } @@ -166,6 +125,9 @@ pub(crate) fn codegen( context.dump_to_file(path, true); } if should_combine_object_files { + let fat_lto = config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full); + // We need to check if we're doing LTO since this code is also used for the + // dummy ThinLTO implementation to combine the object files. if fat_lto { context.add_command_line_option("-flto=auto"); context.add_command_line_option("-flto-partition=one"); From af86f4e351f828a0b475016765996e347ee2e70b Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 09:26:22 -0400 Subject: [PATCH 39/67] Fix to do LTO when requested --- src/back/lto.rs | 10 +++++----- src/back/write.rs | 8 ++++---- src/base.rs | 4 ++-- src/lib.rs | 11 +++++++++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d29bba2570f67..fdd4bdb0e3979 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -38,7 +38,7 @@ use tempfile::{TempDir, tempdir}; use crate::back::write::save_temp_bitcode; use crate::errors::LtoBitcodeFromRlib; -use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level}; +use crate::{GccCodegenBackend, GccContext, LtoMode, SyncContext, to_gcc_opt_level}; struct LtoData { // TODO(antoyo): use symbols_below_threshold. @@ -228,7 +228,7 @@ fn fat_lto( info!("linking {:?}", name); match bc_decoded { SerializedModule::Local(ref module_buffer) => { - module.module_llvm.should_combine_object_files = true; + module.module_llvm.lto_mode = LtoMode::Fat; module .module_llvm .context @@ -533,7 +533,7 @@ pub fn optimize_thin_module( // that LLVM Context and Module. //let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); //let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &dcx)? as *const _; - let mut should_combine_object_files = false; + let mut lto_mode = LtoMode::None; let context = match thin_module.shared.thin_buffers.get(thin_module.idx) { Some(thin_buffer) => Arc::clone(&thin_buffer.context), None => { @@ -544,7 +544,7 @@ pub fn optimize_thin_module( SerializedModule::Local(ref module_buffer) => { let path = module_buffer.0.to_str().expect("path"); context.add_driver_option(path); - should_combine_object_files = true; + lto_mode = LtoMode::Thin; /*module.module_llvm.should_combine_object_files = true; module .module_llvm @@ -563,7 +563,7 @@ pub fn optimize_thin_module( thin_module.name().to_string(), GccContext { context, - should_combine_object_files, + lto_mode, // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/back/write.rs b/src/back/write.rs index 02537e89abada..1bc0402298b47 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -10,7 +10,7 @@ use rustc_target::spec::SplitDebuginfo; use crate::base::add_pic_option; use crate::errors::CopyBitcode; -use crate::{GccCodegenBackend, GccContext}; +use crate::{GccCodegenBackend, GccContext, LtoMode}; pub(crate) fn codegen( cgcx: &CodegenContext, @@ -24,7 +24,7 @@ pub(crate) fn codegen( { let context = &module.module_llvm.context; - let should_combine_object_files = module.module_llvm.should_combine_object_files; + let lto_mode = module.module_llvm.lto_mode; let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, @@ -124,8 +124,8 @@ pub(crate) fn codegen( context.set_debug_info(true); context.dump_to_file(path, true); } - if should_combine_object_files { - let fat_lto = config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full); + if lto_mode != LtoMode::None { + let fat_lto = lto_mode == LtoMode::Fat; // We need to check if we're doing LTO since this code is also used for the // dummy ThinLTO implementation to combine the object files. if fat_lto { diff --git a/src/base.rs b/src/base.rs index e8672f49580b6..4616e46b8c9b3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -21,7 +21,7 @@ use rustc_target::spec::SymbolVisibility; use crate::builder::Builder; use crate::context::CodegenCx; -use crate::{GccContext, LockedTargetInfo, SyncContext, gcc_util, new_context}; +use crate::{GccContext, LockedTargetInfo, LtoMode, SyncContext, gcc_util, new_context}; #[cfg(feature = "master")] pub fn visibility_to_gcc(visibility: Visibility) -> gccjit::Visibility { @@ -247,7 +247,7 @@ pub fn compile_codegen_unit( GccContext { context: Arc::new(SyncContext::new(context)), relocation_model: tcx.sess.relocation_model(), - should_combine_object_files: false, + lto_mode: LtoMode::None, temp_dir: None, }, ) diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab8..79f7d21711efb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -290,7 +290,7 @@ impl ExtraBackendMethods for GccCodegenBackend { let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), - should_combine_object_files: false, + lto_mode: LtoMode::None, temp_dir: None, }; @@ -319,12 +319,19 @@ impl ExtraBackendMethods for GccCodegenBackend { } } +#[derive(Clone, Copy, PartialEq)] +pub enum LtoMode { + None, + Thin, + Fat, +} + pub struct GccContext { context: Arc, /// This field is needed in order to be able to set the flag -fPIC when necessary when doing /// LTO. relocation_model: RelocModel, - should_combine_object_files: bool, + lto_mode: LtoMode, // Temporary directory used by LTO. We keep it here so that it's not removed before linking. temp_dir: Option, } From b0777f2c07364554dce2110d03460c5f190297c3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 21:15:48 -0400 Subject: [PATCH 40/67] Fix to not do LTO when LTO is not enabled in gcc --- src/back/lto.rs | 1 + src/back/write.rs | 24 +++++++++++++++--------- src/base.rs | 6 ++++-- src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index fdd4bdb0e3979..e9088a4e6e890 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -564,6 +564,7 @@ pub fn optimize_thin_module( GccContext { context, lto_mode, + lto_supported: false, // TODO(antoyo): check if this is correct to use this value. // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/back/write.rs b/src/back/write.rs index 1bc0402298b47..a598392511929 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -25,6 +25,7 @@ pub(crate) fn codegen( let context = &module.module_llvm.context; let lto_mode = module.module_llvm.lto_mode; + let lto_supported = module.module_llvm.lto_supported; let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, @@ -51,14 +52,17 @@ pub(crate) fn codegen( ); }*/ + // TODO: only emit if libgccjit is compiled with LTO enabled? if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof .generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); + if lto_supported { + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. + context.add_command_line_option("-ffat-lto-objects"); + } context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); } @@ -67,12 +71,14 @@ pub(crate) fn codegen( let _timer = cgcx .prof .generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + if lto_supported { + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - context.add_command_line_option("-ffat-lto-objects"); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.add_command_line_option("-ffat-lto-objects"); + } // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); diff --git a/src/base.rs b/src/base.rs index 4616e46b8c9b3..7cf3a2375879c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -74,6 +74,7 @@ pub fn compile_codegen_unit( tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: LockedTargetInfo, + lto_supported: bool, ) -> (ModuleCodegen, u64) { let prof_timer = tcx.prof.generic_activity("codegen_module"); let start_time = Instant::now(); @@ -82,7 +83,7 @@ pub fn compile_codegen_unit( let (module, _) = tcx.dep_graph.with_task( dep_node, tcx, - (cgu_name, target_info), + (cgu_name, target_info, lto_supported), module_codegen, Some(dep_graph::hash_result), ); @@ -95,7 +96,7 @@ pub fn compile_codegen_unit( fn module_codegen( tcx: TyCtxt<'_>, - (cgu_name, target_info): (Symbol, LockedTargetInfo), + (cgu_name, target_info, lto_supported): (Symbol, LockedTargetInfo, bool), ) -> ModuleCodegen { let cgu = tcx.codegen_unit(cgu_name); // Instantiate monomorphizations without filling out definitions yet... @@ -247,6 +248,7 @@ pub fn compile_codegen_unit( GccContext { context: Arc::new(SyncContext::new(context)), relocation_model: tcx.sess.relocation_model(), + lto_supported, lto_mode: LtoMode::None, temp_dir: None, }, diff --git a/src/lib.rs b/src/lib.rs index 79f7d21711efb..f48d945266210 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,10 +82,7 @@ use std::any::Any; use std::fmt::Debug; use std::ops::Deref; use std::path::PathBuf; -#[cfg(not(feature = "master"))] -use std::sync::atomic::AtomicBool; -#[cfg(not(feature = "master"))] -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use back::lto::{ThinBuffer, ThinData}; @@ -177,6 +174,7 @@ impl LockedTargetInfo { #[derive(Clone)] pub struct GccCodegenBackend { target_info: LockedTargetInfo, + lto_supported: Arc, } impl CodegenBackend for GccCodegenBackend { @@ -202,6 +200,29 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } + // TODO: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + { + let temp_dir = TempDir::new().expect("cannot create temporary directory"); + let temp_file = temp_dir.into_path().join("result.asm"); + let context = Context::default(); + let object_file_path = temp_file.to_str().expect("path to str"); + context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); + + //let temp_dir = TempDir::new().expect("cannot create temporary directory"); + //let temp_file = temp_dir.into_path().join("result.asm"); + let check_context = Context::default(); + check_context.add_driver_option("-x"); + check_context.add_driver_option("lto"); + check_context.add_driver_option(object_file_path); + check_context.set_print_errors_to_stderr(false); + //context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str")); + // FIXME: compile gives the error as expected, but compile_to_file doesn't. + check_context.compile(); + let error = check_context.get_last_error(); + let lto_supported = error == Ok(None); + self.lto_supported.store(lto_supported, Ordering::SeqCst); + } + #[cfg(feature = "master")] gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); @@ -291,6 +312,7 @@ impl ExtraBackendMethods for GccCodegenBackend { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), lto_mode: LtoMode::None, + lto_supported: false, temp_dir: None, }; @@ -305,7 +327,12 @@ impl ExtraBackendMethods for GccCodegenBackend { tcx: TyCtxt<'_>, cgu_name: Symbol, ) -> (ModuleCodegen, u64) { - base::compile_codegen_unit(tcx, cgu_name, self.target_info.clone()) + base::compile_codegen_unit( + tcx, + cgu_name, + self.target_info.clone(), + self.lto_supported.load(Ordering::SeqCst), + ) } fn target_machine_factory( @@ -332,6 +359,7 @@ pub struct GccContext { /// LTO. relocation_model: RelocModel, lto_mode: LtoMode, + lto_supported: bool, // Temporary directory used by LTO. We keep it here so that it's not removed before linking. temp_dir: Option, } @@ -443,7 +471,10 @@ pub fn __rustc_codegen_backend() -> Box { supports_128bit_integers: AtomicBool::new(false), }))); - Box::new(GccCodegenBackend { target_info: LockedTargetInfo { info } }) + Box::new(GccCodegenBackend { + lto_supported: Arc::new(AtomicBool::new(false)), + target_info: LockedTargetInfo { info }, + }) } fn to_gcc_opt_level(optlevel: Option) -> OptimizationLevel { From 2f2a83450755d1e8e4ae43ace2e7817549e5cbcf Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 09:43:44 -0400 Subject: [PATCH 41/67] Fix to forward lto_supported and lto_mode where needed --- src/back/lto.rs | 6 ++++-- src/lib.rs | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index e9088a4e6e890..9071c49001319 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -21,6 +21,7 @@ use std::ffi::{CStr, CString}; use std::fs::{self, File}; use std::path::{Path, PathBuf}; use std::sync::Arc; +use std::sync::atomic::Ordering; use gccjit::{Context, OutputKind}; use object::read::archive::ArchiveFile; @@ -38,7 +39,7 @@ use tempfile::{TempDir, tempdir}; use crate::back::write::save_temp_bitcode; use crate::errors::LtoBitcodeFromRlib; -use crate::{GccCodegenBackend, GccContext, LtoMode, SyncContext, to_gcc_opt_level}; +use crate::{GccCodegenBackend, GccContext, LTO_SUPPORTED, LtoMode, SyncContext, to_gcc_opt_level}; struct LtoData { // TODO(antoyo): use symbols_below_threshold. @@ -559,12 +560,13 @@ pub fn optimize_thin_module( Arc::new(SyncContext::new(context)) } }; + let lto_supported = LTO_SUPPORTED.load(Ordering::SeqCst); let module = ModuleCodegen::new_regular( thin_module.name().to_string(), GccContext { context, lto_mode, - lto_supported: false, // TODO(antoyo): check if this is correct to use this value. + lto_supported, // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/lib.rs b/src/lib.rs index f48d945266210..ec3f5a919ab75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,6 +177,8 @@ pub struct GccCodegenBackend { lto_supported: Arc, } +static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); + impl CodegenBackend for GccCodegenBackend { fn locale_resource(&self) -> &'static str { crate::DEFAULT_LOCALE_RESOURCE @@ -200,7 +202,7 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // TODO: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. { let temp_dir = TempDir::new().expect("cannot create temporary directory"); let temp_file = temp_dir.into_path().join("result.asm"); @@ -220,6 +222,7 @@ impl CodegenBackend for GccCodegenBackend { check_context.compile(); let error = check_context.get_last_error(); let lto_supported = error == Ok(None); + LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst); self.lto_supported.store(lto_supported, Ordering::SeqCst); } @@ -308,11 +311,12 @@ impl ExtraBackendMethods for GccCodegenBackend { kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind, ) -> Self::Module { + let lto_supported = self.lto_supported.load(Ordering::SeqCst); let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), lto_mode: LtoMode::None, - lto_supported: false, + lto_supported, temp_dir: None, }; From 0166bfc4fb5af4efb86aee5136263e0a21de47a0 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 09:27:34 -0400 Subject: [PATCH 42/67] Fix clippy warning --- Cargo.toml | 1 + src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6031933bd2d2b..2afa0c2a16655 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ gccjit = "2.8" [dev-dependencies] boml = "0.3.1" lang_tester = "0.8.0" +tempfile = "3.20.0" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/lib.rs b/src/lib.rs index ec3f5a919ab75..f30f3f1ed1587 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -205,7 +205,7 @@ impl CodegenBackend for GccCodegenBackend { // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. { let temp_dir = TempDir::new().expect("cannot create temporary directory"); - let temp_file = temp_dir.into_path().join("result.asm"); + let temp_file = temp_dir.keep().join("result.asm"); let context = Context::default(); let object_file_path = temp_file.to_str().expect("path to str"); context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); From 7a5ee0f585c978e4cba8b53736c85820ba0ef816 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 13:43:04 -0400 Subject: [PATCH 43/67] Only check if LTO is enabled when using the master branch of libgccjit --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f30f3f1ed1587..1e14d6bd60db9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,8 +202,15 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + // While not required by the API, we gate this code on the master feature to make sure we + // don't abort the process while checking if LTO is supported. + // The following could will emit a fatal error if LTO is not supported and older versions + // of libgccjit (the ones without this commit: + // https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will + // abort on fatal errors. + #[cfg(feature = "master")] { + // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. let temp_dir = TempDir::new().expect("cannot create temporary directory"); let temp_file = temp_dir.keep().join("result.asm"); let context = Context::default(); From 81bbe140a5d222ee809b397b5655f74280094e17 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 17:44:59 -0400 Subject: [PATCH 44/67] Remove comment --- src/back/write.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/back/write.rs b/src/back/write.rs index a598392511929..9f3ac6f682ec5 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -52,7 +52,6 @@ pub(crate) fn codegen( ); }*/ - // TODO: only emit if libgccjit is compiled with LTO enabled? if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof From ea362b21f0a31c453394642d38a5f0a6d50cfa7f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 9 Oct 2025 15:40:06 -0400 Subject: [PATCH 45/67] Fix to remove messages to stderr when LTO is not suppported by using the new API gccjit::is_lto_supported --- Cargo.lock | 8 ++++---- Cargo.toml | 3 +-- src/lib.rs | 31 +++---------------------------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5b972baf98e3..181d3aa89bc89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,18 +56,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a" +checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b" +checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 2afa0c2a16655..d3ff2757857b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default = ["master"] [dependencies] object = { version = "0.37.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" -gccjit = "2.8" +gccjit = "2.10" #gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } # Local copy. @@ -33,7 +33,6 @@ gccjit = "2.8" [dev-dependencies] boml = "0.3.1" lang_tester = "0.8.0" -tempfile = "3.20.0" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/lib.rs b/src/lib.rs index 1e14d6bd60db9..9854f3843c401 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,39 +202,14 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // While not required by the API, we gate this code on the master feature to make sure we - // don't abort the process while checking if LTO is supported. - // The following could will emit a fatal error if LTO is not supported and older versions - // of libgccjit (the ones without this commit: - // https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will - // abort on fatal errors. #[cfg(feature = "master")] { - // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. - let temp_dir = TempDir::new().expect("cannot create temporary directory"); - let temp_file = temp_dir.keep().join("result.asm"); - let context = Context::default(); - let object_file_path = temp_file.to_str().expect("path to str"); - context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); - - //let temp_dir = TempDir::new().expect("cannot create temporary directory"); - //let temp_file = temp_dir.into_path().join("result.asm"); - let check_context = Context::default(); - check_context.add_driver_option("-x"); - check_context.add_driver_option("lto"); - check_context.add_driver_option(object_file_path); - check_context.set_print_errors_to_stderr(false); - //context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str")); - // FIXME: compile gives the error as expected, but compile_to_file doesn't. - check_context.compile(); - let error = check_context.get_last_error(); - let lto_supported = error == Ok(None); + let lto_supported = gccjit::is_lto_supported(); LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst); self.lto_supported.store(lto_supported, Ordering::SeqCst); - } - #[cfg(feature = "master")] - gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); + gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); + } #[cfg(not(feature = "master"))] { From 1e4b27349b8376af1946b6ef2261c88526918d01 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 9 Oct 2025 15:48:29 -0400 Subject: [PATCH 46/67] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index 93cff753b14d6..b8d4166542bcd 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -0256a7539a83aa26aade8cca138d9c69634a51b1 +28b84db392ac0a572f1a2a2a1317aa5f2bc742cb From 7b71e5408d497d2121cb6a08f36dc31880963fa9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 26 Jun 2025 13:44:01 +0000 Subject: [PATCH 47/67] Support #[alloc_error_handler] without the allocator shim Currently it is possible to avoid linking the allocator shim when __rust_no_alloc_shim_is_unstable_v2 is defined when linking rlibs directly as some build systems need. However this requires liballoc to be compiled with --cfg no_global_oom_handling, which places huge restrictions on what functions you can call and makes it impossible to use libstd. Or alternatively you have to define __rust_alloc_error_handler and (when using libstd) __rust_alloc_error_handler_should_panic using #[rustc_std_internal_symbol]. With this commit you can either use libstd and define __rust_alloc_error_handler_should_panic or not use libstd and use #[alloc_error_handler] instead. Both options are still unstable though. Eventually the alloc_error_handler may either be removed entirely (though the PR for that has been stale for years now) or we may start using weak symbols for it instead. For the latter case this commit is a prerequisite anyway. --- src/allocator.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 2a95a7368aac6..3f99612fcdb02 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -2,8 +2,8 @@ use gccjit::FnAttribute; use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; use rustc_ast::expand::allocator::{ - ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, - alloc_error_handler_name, default_fn_name, global_fn_name, + ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, + default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; @@ -61,15 +61,17 @@ pub(crate) unsafe fn codegen( } } - // FIXME(bjorn3): Add noreturn attribute - create_wrapper_function( - tcx, - context, - &mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), - Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))), - &[usize, usize], - None, - ); + if alloc_error_handler_kind == AllocatorKind::Default { + // FIXME(bjorn3): Add noreturn attribute + create_wrapper_function( + tcx, + context, + &mangle_internal_symbol(tcx, &global_fn_name(ALLOC_ERROR_HANDLER)), + Some(&mangle_internal_symbol(tcx, &default_fn_name(ALLOC_ERROR_HANDLER))), + &[usize, usize], + None, + ); + } create_const_value_function( tcx, From 5f0d88ffcf4c97c062746e2c4dc4e68d5eab9cbc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:08:55 +0000 Subject: [PATCH 48/67] Move computation of allocator shim contents to cg_ssa In the future this should make it easier to use weak symbols for the allocator shim on platforms that properly support weak symbols. And it would allow reusing the allocator shim code for handling default implementations of the upcoming externally implementable items feature on platforms that don't properly support weak symbols. --- src/allocator.rs | 64 +++++++++++++++++++----------------------------- src/lib.rs | 7 +++--- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 3f99612fcdb02..647569694b04d 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -2,8 +2,7 @@ use gccjit::FnAttribute; use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; use rustc_ast::expand::allocator::{ - ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, - default_fn_name, global_fn_name, + AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; @@ -18,8 +17,7 @@ pub(crate) unsafe fn codegen( tcx: TyCtxt<'_>, mods: &mut GccContext, _module_name: &str, - kind: AllocatorKind, - alloc_error_handler_kind: AllocatorKind, + methods: &[AllocatorMethod], ) { let context = &mods.context; let usize = match tcx.sess.target.pointer_width { @@ -31,46 +29,34 @@ pub(crate) unsafe fn codegen( let i8 = context.new_type::(); let i8p = i8.make_pointer(); - if kind == AllocatorKind::Default { - for method in ALLOCATOR_METHODS { - let mut types = Vec::with_capacity(method.inputs.len()); - for input in method.inputs.iter() { - match input.ty { - AllocatorTy::Layout => { - types.push(usize); - types.push(usize); - } - AllocatorTy::Ptr => types.push(i8p), - AllocatorTy::Usize => types.push(usize), - - AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), + for method in methods { + let mut types = Vec::with_capacity(method.inputs.len()); + for input in method.inputs.iter() { + match input.ty { + AllocatorTy::Layout => { + types.push(usize); + types.push(usize); } - } - let output = match method.output { - AllocatorTy::ResultPtr => Some(i8p), - AllocatorTy::Unit => None, + AllocatorTy::Ptr => types.push(i8p), + AllocatorTy::Usize => types.push(usize), - AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { - panic!("invalid allocator output") + AllocatorTy::Never | AllocatorTy::ResultPtr | AllocatorTy::Unit => { + panic!("invalid allocator arg") } - }; - let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); - let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); - - create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); + } } - } + let output = match method.output { + AllocatorTy::ResultPtr => Some(i8p), + AllocatorTy::Never | AllocatorTy::Unit => None, - if alloc_error_handler_kind == AllocatorKind::Default { - // FIXME(bjorn3): Add noreturn attribute - create_wrapper_function( - tcx, - context, - &mangle_internal_symbol(tcx, &global_fn_name(ALLOC_ERROR_HANDLER)), - Some(&mangle_internal_symbol(tcx, &default_fn_name(ALLOC_ERROR_HANDLER))), - &[usize, usize], - None, - ); + AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { + panic!("invalid allocator output") + } + }; + let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); + let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); + + create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); } create_const_value_function( diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab8..c85ed0ebb3390 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,7 +92,7 @@ use back::lto::{ThinBuffer, ThinData}; use gccjit::{CType, Context, OptimizationLevel}; #[cfg(feature = "master")] use gccjit::{TargetInfo, Version}; -use rustc_ast::expand::allocator::AllocatorKind; +use rustc_ast::expand::allocator::AllocatorMethod; use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule}; use rustc_codegen_ssa::back::write::{ CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn, @@ -284,8 +284,7 @@ impl ExtraBackendMethods for GccCodegenBackend { &self, tcx: TyCtxt<'_>, module_name: &str, - kind: AllocatorKind, - alloc_error_handler_kind: AllocatorKind, + methods: &[AllocatorMethod], ) -> Self::Module { let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), @@ -295,7 +294,7 @@ impl ExtraBackendMethods for GccCodegenBackend { }; unsafe { - allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); + allocator::codegen(tcx, &mut mods, module_name, methods); } mods } From e83aa35949dbdce1f042ed9aba739a5a77c52f76 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:02 -0400 Subject: [PATCH 49/67] Remove remaining usage of EMBED_LTO_BITCODE --- .github/workflows/release.yml | 2 +- tests/cross_lang_lto/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a577c2eed712c..99cc123941fa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,7 +99,7 @@ jobs: ar rcs libadd.a add.o popd - EMBED_LTO_BITCODE=1 CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml + CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||: if [ $call_found -gt 0 ]; then echo "ERROR: call my_add found in asm" diff --git a/tests/cross_lang_lto/src/main.rs b/tests/cross_lang_lto/src/main.rs index a7180b3339630..3c64248ba2a05 100644 --- a/tests/cross_lang_lto/src/main.rs +++ b/tests/cross_lang_lto/src/main.rs @@ -4,7 +4,7 @@ * ar rcs libadd.a add.o * * Compile the Rust code with: - * EMBED_LTO_BITCODE=1 CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release + * CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release */ #[link(name="add")] From a50f0b42ab57fdb4d97898ff96b872eb22a605c6 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:50 -0400 Subject: [PATCH 50/67] Remove failing-lto-tests.txt --- .github/workflows/release.yml | 3 --- tests/failing-lto-tests.txt | 33 --------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 tests/failing-lto-tests.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99cc123941fa9..7803230087fd6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,9 +72,6 @@ jobs: git config --global user.name "User" ./y.sh prepare - - name: Add more failing tests because of undefined symbol errors (FIXME) - run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt - - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. diff --git a/tests/failing-lto-tests.txt b/tests/failing-lto-tests.txt deleted file mode 100644 index bf0633f732000..0000000000000 --- a/tests/failing-lto-tests.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/ui/lint/unsafe_code/forge_unsafe_block.rs -tests/ui/lint/unused-qualification-in-derive-expansion.rs -tests/ui/macros/macro-quote-test.rs -tests/ui/macros/proc_macro.rs -tests/ui/panic-runtime/lto-unwind.rs -tests/ui/resolve/derive-macro-1.rs -tests/ui/resolve/derive-macro-2.rs -tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs -tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs -tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs -tests/ui/rust-2018/suggestions-not-always-applicable.rs -tests/ui/rust-2021/reserved-prefixes-via-macro.rs -tests/ui/underscore-imports/duplicate.rs -tests/ui/async-await/issues/issue-60674.rs -tests/ui/attributes/main-removed-2/main.rs -tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs -tests/ui/crate-loading/cross-compiled-proc-macro.rs -tests/ui/derives/derive-marker-tricky.rs -tests/ui/diagnostic_namespace/existing_proc_macros.rs -tests/ui/fmt/format-args-capture-issue-106408.rs -tests/ui/fmt/indoc-issue-106408.rs -tests/ui/hygiene/issue-77523-def-site-async-await.rs -tests/ui/inherent-impls-overlap-check/no-overlap.rs -tests/ui/enum-discriminant/issue-46519.rs -tests/ui/issues/issue-45731.rs -tests/ui/lint/test-allow-dead-extern-static-no-warning.rs -tests/ui/macros/macro-comma-behavior-rpass.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs -tests/ui/macros/stringify.rs -tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs -tests/ui/binding/fn-arg-incomplete-pattern-drop-order.rs -tests/ui/lto/debuginfo-lto-alloc.rs From 784f11d17781774b775439699d5fef2f148e23e3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:25 -0400 Subject: [PATCH 51/67] Do not generate fat objects when not needed --- src/back/write.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/back/write.rs b/src/back/write.rs index 9f3ac6f682ec5..b654b34992c45 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -59,8 +59,6 @@ pub(crate) fn codegen( if lto_supported { context.add_command_line_option("-flto=auto"); context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); } context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); From e44d493cee3654be0c01fd39f92140a5795bea56 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:34 -0400 Subject: [PATCH 52/67] Correctly embed the bitcode when compiling the sysroot --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7803230087fd6..52f94dc2970a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,9 +75,7 @@ jobs: - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. - # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. - printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml - ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - name: LTO test run: | From 2cd4f6737533e6a72fa7ac8d4bba3e3d2c6b7ac9 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 11 Oct 2025 15:38:48 -0400 Subject: [PATCH 53/67] Clean the sysroot destination directory before copying the content into it --- build_system/src/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 94b40319f4a77..6aa5faec4c81e 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -149,6 +149,9 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu // Copy files to sysroot let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple)); + // To avoid errors like "multiple candidates for `rmeta` dependency `core` found", we clean the + // sysroot directory before copying the sysroot build artifacts. + let _ = fs::remove_dir_all(&sysroot_path); create_dir(&sysroot_path)?; let mut copier = |dir_to_copy: &Path| { // FIXME: should not use shell command! From 5544f5debba20d6e22e58f68dccc57fb09e6e4eb Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 12 Oct 2025 09:48:47 -0400 Subject: [PATCH 54/67] Remove passing tests from failing-ui-tests.txt --- build_system/src/test.rs | 52 +++++++++++++++++++++++--------------- tests/failing-ui-tests.txt | 12 --------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1823aa71f408e..d66cba3b0d113 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -910,6 +910,7 @@ fn test_rustc_inner( prepare_files_callback: F, run_error_pattern_test: bool, test_type: &str, + run_ignored_tests: bool, ) -> Result<(), String> where F: Fn(&Path) -> Result, @@ -1061,30 +1062,34 @@ where env.get_mut("RUSTFLAGS").unwrap().clear(); - run_command_with_output_and_env( - &[ - &"./x.py", - &"test", - &"--run", - &"always", - &"--stage", - &"0", - &"--set", - &"build.compiletest-allow-stage0=true", - &format!("tests/{test_type}"), - &"--compiletest-rustc-args", - &rustc_args, - ], - Some(&rust_path), - Some(&env), - )?; + let test_dir = format!("tests/{test_type}"); + let mut command: Vec<&dyn AsRef> = vec![ + &"./x.py", + &"test", + &"--run", + &"always", + &"--stage", + &"0", + &"--set", + &"build.compiletest-allow-stage0=true", + &test_dir, + &"--compiletest-rustc-args", + &rustc_args, + ]; + + if run_ignored_tests { + command.push(&"--"); + command.push(&"--ignored"); + } + + run_command_with_output_and_env(&command, Some(&rust_path), Some(&env))?; Ok(()) } fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; - test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?; - test_rustc_inner(env, args, |_| Ok(false), false, "ui") + test_rustc_inner(env, args, |_| Ok(false), false, "run-make", false)?; + test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo", false)?; + test_rustc_inner(env, args, |_| Ok(false), false, "ui", false) } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1094,6 +1099,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + true, ); let run_make_cargo_result = test_rustc_inner( @@ -1102,6 +1108,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), false, "run-make", + true, ); let ui_result = test_rustc_inner( @@ -1110,6 +1117,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-ui-tests.txt", "ui"), false, "ui", + true, ); run_make_result.and(run_make_cargo_result).and(ui_result) @@ -1122,6 +1130,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-ui-tests.txt", "ui"), false, "ui", + false, )?; test_rustc_inner( env, @@ -1129,6 +1138,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + false, )?; test_rustc_inner( env, @@ -1136,6 +1146,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), false, "run-make-cargo", + false, ) } @@ -1146,6 +1157,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String remove_files_callback("tests/failing-ice-tests.txt", "ui"), true, "ui", + false, ) } diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 9a44034c127c5..cc00432ceb54e 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -1,5 +1,3 @@ -tests/ui/allocator/no_std-alloc-error-handler-custom.rs -tests/ui/allocator/no_std-alloc-error-handler-default.rs tests/ui/asm/may_unwind.rs tests/ui/asm/x86_64/may_unwind.rs tests/ui/drop/dynamic-drop-async.rs @@ -17,7 +15,6 @@ tests/ui/panic-runtime/link-to-abort.rs tests/ui/parser/unclosed-delimiter-in-dep.rs tests/ui/consts/missing_span_in_backtrace.rs tests/ui/drop/dynamic-drop.rs -tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs tests/ui/simd/issue-17170.rs tests/ui/simd/issue-39720.rs tests/ui/drop/panic-during-drop-14875.rs @@ -31,11 +28,9 @@ tests/ui/coroutine/resume-after-return.rs tests/ui/simd/masked-load-store.rs tests/ui/simd/repr_packed.rs tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs -tests/ui/consts/try-operator.rs tests/ui/coroutine/unwind-abort-mix.rs tests/ui/consts/issue-miri-1910.rs tests/ui/consts/const_cmp_type_id.rs -tests/ui/consts/issue-73976-monomorphic.rs tests/ui/consts/issue-94675.rs tests/ui/traits/const-traits/const-drop-fail.rs tests/ui/runtime/on-broken-pipe/child-processes.rs @@ -53,7 +48,6 @@ tests/ui/sanitizer/cfi/virtual-auto.rs tests/ui/sanitizer/cfi/sized-associated-ty.rs tests/ui/sanitizer/cfi/can-reveal-opaques.rs tests/ui/sanitizer/kcfi-mangling.rs -tests/ui/statics/const_generics.rs tests/ui/backtrace/dylib-dep.rs tests/ui/delegation/fn-header.rs tests/ui/consts/const-eval/parse_ints.rs @@ -74,13 +68,7 @@ tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs tests/ui/simd/simd-bitmask-notpow2.rs tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs tests/ui/numbers-arithmetic/u128-as-f32.rs -tests/ui/lto/all-crates.rs -tests/ui/uninhabited/uninhabited-transparent-return-abi.rs -tests/ui/coroutine/panic-drops-resume.rs -tests/ui/coroutine/panic-drops.rs -tests/ui/coroutine/panic-safe.rs tests/ui/process/nofile-limit.rs -tests/ui/simd/intrinsic/generic-arithmetic-pass.rs tests/ui/linking/no-gc-encapsulation-symbols.rs tests/ui/panics/unwind-force-no-unwind-tables.rs tests/ui/attributes/fn-align-dyn.rs From a93f53190410f7f0e0b9e1d2c319a6be821a4be1 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 12 Oct 2025 11:03:13 -0400 Subject: [PATCH 55/67] Stop removing some test directories --- build_system/src/test.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index d66cba3b0d113..dbdaf2a63ef29 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -945,17 +945,7 @@ where rust_path.join("tests/ui"), &mut |dir| { let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); - if [ - "abi", - "extern", - "unsized-locals", - "proc-macro", - "threads-sendsync", - "borrowck", - "test-attrs", - ] - .contains(&dir_name) - { + if ["abi", "extern", "proc-macro", "threads-sendsync"].contains(&dir_name) { remove_dir_all(dir).map_err(|error| { format!("Failed to remove folder `{}`: {:?}", dir.display(), error) })?; From 2064793089c2d8656deda40dfee8e8d10b709f21 Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Fri, 19 Sep 2025 11:15:04 -0500 Subject: [PATCH 56/67] Allow vector-scalar (vs) registers in ppc inline assembly Where supported, VSX is a 64x128b register set which encompasses both the floating point and vector registers. In the type tests, xvsqrtdp is used as it is the only two-argument vsx opcode supported by all targets on llvm. If you need to copy a vsx register, the preferred way is "xxlor xt, xa, xa". --- src/asm.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index a14881c502cf3..81cdfc68737fd 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -698,6 +698,7 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => "v", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vsreg) => "wa", InlineAsmRegClass::PowerPC( PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr @@ -778,9 +779,9 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(), InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(), InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(), - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => { - cx.type_vector(cx.type_i32(), 4) - } + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg, + ) => cx.type_vector(cx.type_i32(), 4), InlineAsmRegClass::PowerPC( PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr @@ -957,6 +958,13 @@ fn modifier_to_gcc( InlineAsmRegClass::LoongArch(_) => None, InlineAsmRegClass::Mips(_) => None, InlineAsmRegClass::Nvptx(_) => None, + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vsreg) => { + if modifier.is_none() { + Some('x') + } else { + modifier + } + } InlineAsmRegClass::PowerPC(_) => None, InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) | InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => None, From d96167fc9a3e8e412b9933f423ab993336e7ee85 Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Mon, 22 Sep 2025 09:28:21 -0500 Subject: [PATCH 57/67] Implement ppc/ppc64 preserves_flags option for inline asm Implemented preserves_flags on powerpc by making it do nothing. This prevents having two different ways to mark `cr0` as clobbered. clang and gcc alias `cr0` to `cc`. The gcc inline documentation does not state what this does on powerpc* targets, but inspection of the source shows it is equivalent to condition register field `cr0`, so it should not be added. --- src/asm.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index 81cdfc68737fd..f237861b1595a 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -546,9 +546,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { } if !options.contains(InlineAsmOptions::PRESERVES_FLAGS) { - // TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient - // on all architectures. For instance, what about FP stack? - extended_asm.add_clobber("cc"); + match asm_arch { + InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => { + // "cc" is cr0 on powerpc. + } + // TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient + // on all architectures. For instance, what about FP stack? + _ => { + extended_asm.add_clobber("cc"); + } + } } if !options.contains(InlineAsmOptions::NOMEM) { extended_asm.add_clobber("memory"); From c5d02bbaf3715156f99d71248aa5925d7d2867b9 Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Sun, 6 Jul 2025 20:58:14 +0100 Subject: [PATCH 58/67] Restrict sysroot crate imports to those defined in this repo. It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve. To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`. --- src/back/lto.rs | 1 + src/back/write.rs | 1 + src/consts.rs | 1 + src/gcc_util.rs | 2 +- src/lib.rs | 7 +------ 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d29bba2570f67..598bbe74007d0 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -30,6 +30,7 @@ use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::memmap::Mmap; use rustc_errors::DiagCtxtHandle; +use rustc_log::tracing::info; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; use rustc_session::config::Lto; diff --git a/src/back/write.rs b/src/back/write.rs index 84bc70162719f..8ba730e325029 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -5,6 +5,7 @@ use rustc_codegen_ssa::back::link::ensure_removed; use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig}; use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_fs_util::link_or_copy; +use rustc_log::tracing::debug; use rustc_session::config::OutputType; use rustc_target::spec::SplitDebuginfo; diff --git a/src/consts.rs b/src/consts.rs index 7fe8fc122b3cc..ec7d4b285a3fd 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -8,6 +8,7 @@ use rustc_codegen_ssa::traits::{ use rustc_hir::attrs::Linkage; use rustc_hir::def::DefKind; use rustc_hir::def_id::LOCAL_CRATE; +use rustc_log::tracing::trace; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::mir::interpret::{ self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint, diff --git a/src/gcc_util.rs b/src/gcc_util.rs index 42ba40692b75c..702704ddf1369 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -1,8 +1,8 @@ #[cfg(feature = "master")] use gccjit::Context; use rustc_codegen_ssa::target_features; +use rustc_data_structures::smallvec::{SmallVec, smallvec}; use rustc_session::Session; -use smallvec::{SmallVec, smallvec}; fn gcc_features_by_flags(sess: &Session, features: &mut Vec) { target_features::retpoline_features_by_flags(sess, features); diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab8..e6d1dcccd442a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,12 +25,6 @@ #![deny(clippy::pattern_type_mismatch)] #![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)] -// These crates are pulled from the sysroot because they are part of -// rustc's public API, so we need to ensure version compatibility. -extern crate smallvec; -#[macro_use] -extern crate tracing; - // The rustc crates we need extern crate rustc_abi; extern crate rustc_apfloat; @@ -44,6 +38,7 @@ extern crate rustc_hir; extern crate rustc_index; #[cfg(feature = "master")] extern crate rustc_interface; +extern crate rustc_log; extern crate rustc_macros; extern crate rustc_middle; extern crate rustc_session; From 936805e3dbb33fa424d7a9f4a456401b196674b1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 10 Oct 2025 21:29:29 -0400 Subject: [PATCH 59/67] Fix ICE on offsetted ZST pointer A grep for `const_usize.*align` found the same code copied to rustc_codegen_gcc but I don't see other cases where we get this wrong. --- src/common.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.rs b/src/common.rs index 28848ca61845c..7c2969e587186 100644 --- a/src/common.rs +++ b/src/common.rs @@ -5,7 +5,7 @@ use rustc_codegen_ssa::traits::{ BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods, }; use rustc_middle::mir::Mutability; -use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; +use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, PointerArithmetic, Scalar}; use rustc_middle::ty::layout::LayoutOf; use crate::context::CodegenCx; @@ -247,8 +247,8 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> { // This avoids generating a zero-sized constant value and actually needing a // real address at runtime. if alloc.inner().len() == 0 { - assert_eq!(offset.bytes(), 0); - let val = self.const_usize(alloc.inner().align.bytes()); + let val = alloc.inner().align.bytes().wrapping_add(offset.bytes()); + let val = self.const_usize(self.tcx.truncate_to_target_usize(val)); return if matches!(layout.primitive(), Pointer(_)) { self.context.new_cast(None, val, ty) } else { From 0f5c80a560ed77790ccfc5b06e488ff5e0403cab Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Mon, 20 Oct 2025 20:36:55 +0000 Subject: [PATCH 60/67] remove broken link --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1f342061ec594..71500ded02038 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,5 @@ /* * TODO(antoyo): implement equality in libgccjit based on https://zpz.github.io/blog/overloading-equality-operator-in-cpp-class-hierarchy/ (for type equality?) - * TODO(antoyo): support #[inline] attributes. - * TODO(antoyo): support LTO (gcc's equivalent to Full LTO is -flto -flto-partition=one — https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html). * For Thin LTO, this might be helpful: // cspell:disable-next-line * In gcc 4.6 -fwhopr was removed and became default with -flto. The non-whopr path can still be executed via -flto-partition=none. From 77a97960514f6d24573e95abf1e02e7337abc193 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 25 Oct 2025 20:10:39 -0400 Subject: [PATCH 61/67] Fix RAM usage by splitting deeply nested expressions --- src/builder.rs | 61 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 5657620879ca1..481b12d842f44 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -668,32 +668,38 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { } fn add(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_add(a, b) + self.assign_to_var(self.gcc_add(a, b)) } fn fadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a + b + self.assign_to_var(a + b) } // TODO(antoyo): should we also override the `unchecked_` versions? fn sub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_sub(a, b) + self.assign_to_var(self.gcc_sub(a, b)) } fn fsub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a - b + self.assign_to_var(a - b) } fn mul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_mul(a, b) + self.assign_to_var(self.gcc_mul(a, b)) } fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.cx.context.new_binary_op(self.location, BinaryOp::Mult, a.get_type(), a, b) + self.assign_to_var(self.cx.context.new_binary_op( + self.location, + BinaryOp::Mult, + a.get_type(), + a, + b, + )) } fn udiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_udiv(a, b) + self.assign_to_var(self.gcc_udiv(a, b)) } fn exactudiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -702,11 +708,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { let a = self.gcc_int_cast(a, a_type); let b_type = b.get_type().to_unsigned(self); let b = self.gcc_int_cast(b, b_type); - self.gcc_udiv(a, b) + self.assign_to_var(self.gcc_udiv(a, b)) } fn sdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_sdiv(a, b) + self.assign_to_var(self.gcc_sdiv(a, b)) } fn exactsdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -715,19 +721,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { // should be the same. let typ = a.get_type().to_signed(self); let b = self.gcc_int_cast(b, typ); - self.gcc_sdiv(a, b) + self.assign_to_var(self.gcc_sdiv(a, b)) } fn fdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a / b + self.assign_to_var(a / b) } fn urem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_urem(a, b) + self.assign_to_var(self.gcc_urem(a, b)) } fn srem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_srem(a, b) + self.assign_to_var(self.gcc_srem(a, b)) } fn frem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -865,22 +871,26 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs + rhs) + let result = set_rvalue_location(self, lhs + rhs); + self.assign_to_var(result) } fn fsub_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs - rhs) + let result = set_rvalue_location(self, lhs - rhs); + self.assign_to_var(result) } fn fmul_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs * rhs) + let result = set_rvalue_location(self, lhs * rhs); + self.assign_to_var(result) } fn fdiv_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs / rhs) + let result = set_rvalue_location(self, lhs / rhs); + self.assign_to_var(result) } fn frem_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { @@ -892,22 +902,22 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn fadd_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs + rhs + self.assign_to_var(lhs + rhs) } fn fsub_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs - rhs + self.assign_to_var(lhs - rhs) } fn fmul_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs * rhs + self.assign_to_var(lhs * rhs) } fn fdiv_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs / rhs + self.assign_to_var(lhs / rhs) } fn frem_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { @@ -2409,6 +2419,15 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let res = then_vals | else_vals; self.bitcast_if_needed(res, result_type) } + + // GCC doesn't like deeply nested expressions. + // By assigning intermediate expressions to a variable, this allow us to avoid deeply nested + // expressions and GCC will use much less RAM. + fn assign_to_var(&self, value: RValue<'gcc>) -> RValue<'gcc> { + let var = self.current_func().new_local(self.location, value.get_type(), "opResult"); + self.llbb().add_assignment(self.location, var, value); + var.to_rvalue() + } } fn difference_or_zero<'gcc>( From f3ab60b1d0b6730c025d0ed57bc78524d0359b07 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 26 Oct 2025 19:34:27 -0400 Subject: [PATCH 62/67] Implement reg vector type --- src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 0b359f1c5c81b..93862a6b00ba7 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -88,7 +88,7 @@ impl GccType for Reg { 64 => cx.type_f64(), _ => bug!("unsupported float: {:?}", self), }, - RegKind::Vector => unimplemented!(), //cx.type_vector(cx.type_i8(), self.size.bytes()), + RegKind::Vector => cx.type_vector(cx.type_i8(), self.size.bytes()), } } } From 36c35d7ae499ec1d7deee5fc9d8645cf400ba0e2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Oct 2025 15:56:02 +0100 Subject: [PATCH 63/67] Regenerate intrinsics --- src/intrinsic/archs.rs | 156 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/src/intrinsic/archs.rs b/src/intrinsic/archs.rs index d1b2a93243d27..c51bcbcedd677 100644 --- a/src/intrinsic/archs.rs +++ b/src/intrinsic/archs.rs @@ -85,12 +85,41 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { fn amdgcn(name: &str, full_name: &str) -> &'static str { match name { // amdgcn + "add.max.i32" => "__builtin_amdgcn_add_max_i32", + "add.max.u32" => "__builtin_amdgcn_add_max_u32", + "add.min.i32" => "__builtin_amdgcn_add_min_i32", + "add.min.u32" => "__builtin_amdgcn_add_min_u32", "alignbyte" => "__builtin_amdgcn_alignbyte", "ashr.pk.i8.i32" => "__builtin_amdgcn_ashr_pk_i8_i32", "ashr.pk.u8.i32" => "__builtin_amdgcn_ashr_pk_u8_i32", "buffer.wbinvl1" => "__builtin_amdgcn_buffer_wbinvl1", "buffer.wbinvl1.sc" => "__builtin_amdgcn_buffer_wbinvl1_sc", "buffer.wbinvl1.vol" => "__builtin_amdgcn_buffer_wbinvl1_vol", + "cluster.id.x" => "__builtin_amdgcn_cluster_id_x", + "cluster.id.y" => "__builtin_amdgcn_cluster_id_y", + "cluster.id.z" => "__builtin_amdgcn_cluster_id_z", + "cluster.load.async.to.lds.b128" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b128" + } + "cluster.load.async.to.lds.b32" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b32" + } + "cluster.load.async.to.lds.b64" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b64" + } + "cluster.load.async.to.lds.b8" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b8" + } + "cluster.workgroup.flat.id" => "__builtin_amdgcn_cluster_workgroup_flat_id", + "cluster.workgroup.id.x" => "__builtin_amdgcn_cluster_workgroup_id_x", + "cluster.workgroup.id.y" => "__builtin_amdgcn_cluster_workgroup_id_y", + "cluster.workgroup.id.z" => "__builtin_amdgcn_cluster_workgroup_id_z", + "cluster.workgroup.max.flat.id" => { + "__builtin_amdgcn_cluster_workgroup_max_flat_id" + } + "cluster.workgroup.max.id.x" => "__builtin_amdgcn_cluster_workgroup_max_id_x", + "cluster.workgroup.max.id.y" => "__builtin_amdgcn_cluster_workgroup_max_id_y", + "cluster.workgroup.max.id.z" => "__builtin_amdgcn_cluster_workgroup_max_id_z", "cubeid" => "__builtin_amdgcn_cubeid", "cubema" => "__builtin_amdgcn_cubema", "cubesc" => "__builtin_amdgcn_cubesc", @@ -101,18 +130,36 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.f32.fp8" => "__builtin_amdgcn_cvt_f32_fp8", "cvt.f32.fp8.e5m3" => "__builtin_amdgcn_cvt_f32_fp8_e5m3", "cvt.off.f32.i4" => "__builtin_amdgcn_cvt_off_f32_i4", + "cvt.pk.bf8.f16" => "__builtin_amdgcn_cvt_pk_bf8_f16", "cvt.pk.bf8.f32" => "__builtin_amdgcn_cvt_pk_bf8_f32", "cvt.pk.f16.bf8" => "__builtin_amdgcn_cvt_pk_f16_bf8", "cvt.pk.f16.fp8" => "__builtin_amdgcn_cvt_pk_f16_fp8", "cvt.pk.f32.bf8" => "__builtin_amdgcn_cvt_pk_f32_bf8", "cvt.pk.f32.fp8" => "__builtin_amdgcn_cvt_pk_f32_fp8", + "cvt.pk.fp8.f16" => "__builtin_amdgcn_cvt_pk_fp8_f16", "cvt.pk.fp8.f32" => "__builtin_amdgcn_cvt_pk_fp8_f32", + "cvt.pk.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_pk_fp8_f32_e5m3", "cvt.pk.i16" => "__builtin_amdgcn_cvt_pk_i16", "cvt.pk.u16" => "__builtin_amdgcn_cvt_pk_u16", "cvt.pk.u8.f32" => "__builtin_amdgcn_cvt_pk_u8_f32", "cvt.pknorm.i16" => "__builtin_amdgcn_cvt_pknorm_i16", "cvt.pknorm.u16" => "__builtin_amdgcn_cvt_pknorm_u16", "cvt.pkrtz" => "__builtin_amdgcn_cvt_pkrtz", + "cvt.scale.pk16.bf16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_bf6", + "cvt.scale.pk16.bf16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_fp6", + "cvt.scale.pk16.f16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f16_bf6", + "cvt.scale.pk16.f16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f16_fp6", + "cvt.scale.pk16.f32.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f32_bf6", + "cvt.scale.pk16.f32.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f32_fp6", + "cvt.scale.pk8.bf16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_bf8", + "cvt.scale.pk8.bf16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp4", + "cvt.scale.pk8.bf16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp8", + "cvt.scale.pk8.f16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f16_bf8", + "cvt.scale.pk8.f16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp4", + "cvt.scale.pk8.f16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp8", + "cvt.scale.pk8.f32.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f32_bf8", + "cvt.scale.pk8.f32.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp4", + "cvt.scale.pk8.f32.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp8", "cvt.scalef32.2xpk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_bf6_f32", "cvt.scalef32.2xpk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_fp6_f32", "cvt.scalef32.f16.bf8" => "__builtin_amdgcn_cvt_scalef32_f16_bf8", @@ -137,6 +184,12 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.pk.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_bf16", "cvt.scalef32.pk.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f16", "cvt.scalef32.pk.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f32", + "cvt.scalef32.pk16.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_bf16", + "cvt.scalef32.pk16.bf6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f16", + "cvt.scalef32.pk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f32", + "cvt.scalef32.pk16.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_bf16", + "cvt.scalef32.pk16.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f16", + "cvt.scalef32.pk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f32", "cvt.scalef32.pk32.bf16.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_bf6", "cvt.scalef32.pk32.bf16.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_fp6", "cvt.scalef32.pk32.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_bf6_bf16", @@ -147,6 +200,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.pk32.f32.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_f32_fp6", "cvt.scalef32.pk32.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_bf16", "cvt.scalef32.pk32.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_f16", + "cvt.scalef32.pk8.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16", + "cvt.scalef32.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f16", + "cvt.scalef32.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f32", + "cvt.scalef32.pk8.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_bf16", + "cvt.scalef32.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f16", + "cvt.scalef32.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f32", + "cvt.scalef32.pk8.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16", + "cvt.scalef32.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16", + "cvt.scalef32.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f32", "cvt.scalef32.sr.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_bf16", "cvt.scalef32.sr.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f16", "cvt.scalef32.sr.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f32", @@ -156,6 +218,24 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.sr.pk.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_bf16", "cvt.scalef32.sr.pk.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f16", "cvt.scalef32.sr.pk.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f32", + "cvt.scalef32.sr.pk16.bf6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_bf16" + } + "cvt.scalef32.sr.pk16.bf6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f16" + } + "cvt.scalef32.sr.pk16.bf6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f32" + } + "cvt.scalef32.sr.pk16.fp6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_bf16" + } + "cvt.scalef32.sr.pk16.fp6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f16" + } + "cvt.scalef32.sr.pk16.fp6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f32" + } "cvt.scalef32.sr.pk32.bf6.bf16" => { "__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_bf16" } @@ -174,10 +254,30 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.sr.pk32.fp6.f32" => { "__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_f32" } + "cvt.scalef32.sr.pk8.bf8.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_bf16" + } + "cvt.scalef32.sr.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f16", + "cvt.scalef32.sr.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f32", + "cvt.scalef32.sr.pk8.fp4.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_bf16" + } + "cvt.scalef32.sr.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f16", + "cvt.scalef32.sr.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f32", + "cvt.scalef32.sr.pk8.fp8.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_bf16" + } + "cvt.scalef32.sr.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f16", + "cvt.scalef32.sr.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f32", "cvt.sr.bf16.f32" => "__builtin_amdgcn_cvt_sr_bf16_f32", + "cvt.sr.bf8.f16" => "__builtin_amdgcn_cvt_sr_bf8_f16", "cvt.sr.bf8.f32" => "__builtin_amdgcn_cvt_sr_bf8_f32", "cvt.sr.f16.f32" => "__builtin_amdgcn_cvt_sr_f16_f32", + "cvt.sr.fp8.f16" => "__builtin_amdgcn_cvt_sr_fp8_f16", "cvt.sr.fp8.f32" => "__builtin_amdgcn_cvt_sr_fp8_f32", + "cvt.sr.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_sr_fp8_f32_e5m3", + "cvt.sr.pk.bf16.f32" => "__builtin_amdgcn_cvt_sr_pk_bf16_f32", + "cvt.sr.pk.f16.f32" => "__builtin_amdgcn_cvt_sr_pk_f16_f32", "dispatch.id" => "__builtin_amdgcn_dispatch_id", "dot4.f32.bf8.bf8" => "__builtin_amdgcn_dot4_f32_bf8_bf8", "dot4.f32.bf8.fp8" => "__builtin_amdgcn_dot4_f32_bf8_fp8", @@ -297,8 +397,20 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "mqsad.u32.u8" => "__builtin_amdgcn_mqsad_u32_u8", "msad.u8" => "__builtin_amdgcn_msad_u8", "perm" => "__builtin_amdgcn_perm", + "perm.pk16.b4.u4" => "__builtin_amdgcn_perm_pk16_b4_u4", + "perm.pk16.b6.u4" => "__builtin_amdgcn_perm_pk16_b6_u4", + "perm.pk16.b8.u4" => "__builtin_amdgcn_perm_pk16_b8_u4", + "permlane.bcast" => "__builtin_amdgcn_permlane_bcast", + "permlane.down" => "__builtin_amdgcn_permlane_down", + "permlane.idx.gen" => "__builtin_amdgcn_permlane_idx_gen", + "permlane.up" => "__builtin_amdgcn_permlane_up", + "permlane.xor" => "__builtin_amdgcn_permlane_xor", "permlane16.var" => "__builtin_amdgcn_permlane16_var", "permlanex16.var" => "__builtin_amdgcn_permlanex16_var", + "pk.add.max.i16" => "__builtin_amdgcn_pk_add_max_i16", + "pk.add.max.u16" => "__builtin_amdgcn_pk_add_max_u16", + "pk.add.min.i16" => "__builtin_amdgcn_pk_add_min_i16", + "pk.add.min.u16" => "__builtin_amdgcn_pk_add_min_u16", "prng.b32" => "__builtin_amdgcn_prng_b32", "qsad.pk.u16.u8" => "__builtin_amdgcn_qsad_pk_u16_u8", "queue.ptr" => "__builtin_amdgcn_queue_ptr", @@ -306,11 +418,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "rcp.legacy" => "__builtin_amdgcn_rcp_legacy", "rsq.legacy" => "__builtin_amdgcn_rsq_legacy", "s.barrier" => "__builtin_amdgcn_s_barrier", + "s.barrier.init" => "__builtin_amdgcn_s_barrier_init", + "s.barrier.join" => "__builtin_amdgcn_s_barrier_join", + "s.barrier.leave" => "__builtin_amdgcn_s_barrier_leave", "s.barrier.signal" => "__builtin_amdgcn_s_barrier_signal", "s.barrier.signal.isfirst" => "__builtin_amdgcn_s_barrier_signal_isfirst", "s.barrier.signal.var" => "__builtin_amdgcn_s_barrier_signal_var", "s.barrier.wait" => "__builtin_amdgcn_s_barrier_wait", "s.buffer.prefetch.data" => "__builtin_amdgcn_s_buffer_prefetch_data", + "s.cluster.barrier" => "__builtin_amdgcn_s_cluster_barrier", "s.dcache.inv" => "__builtin_amdgcn_s_dcache_inv", "s.dcache.inv.vol" => "__builtin_amdgcn_s_dcache_inv_vol", "s.dcache.wb" => "__builtin_amdgcn_s_dcache_wb", @@ -1900,6 +2016,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vfneg.hf.128B" => "__builtin_HEXAGON_V6_vfneg_hf_128B", "V6.vfneg.sf" => "__builtin_HEXAGON_V6_vfneg_sf", "V6.vfneg.sf.128B" => "__builtin_HEXAGON_V6_vfneg_sf_128B", + "V6.vgather.vscattermh" => "__builtin_HEXAGON_V6_vgather_vscattermh", + "V6.vgather.vscattermh.128B" => "__builtin_HEXAGON_V6_vgather_vscattermh_128B", "V6.vgathermh" => "__builtin_HEXAGON_V6_vgathermh", "V6.vgathermh.128B" => "__builtin_HEXAGON_V6_vgathermh_128B", "V6.vgathermhq" => "__builtin_HEXAGON_V6_vgathermhq", @@ -2382,6 +2500,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vsub.hf.f8.128B" => "__builtin_HEXAGON_V6_vsub_hf_f8_128B", "V6.vsub.hf.hf" => "__builtin_HEXAGON_V6_vsub_hf_hf", "V6.vsub.hf.hf.128B" => "__builtin_HEXAGON_V6_vsub_hf_hf_128B", + "V6.vsub.hf.mix" => "__builtin_HEXAGON_V6_vsub_hf_mix", + "V6.vsub.hf.mix.128B" => "__builtin_HEXAGON_V6_vsub_hf_mix_128B", "V6.vsub.qf16" => "__builtin_HEXAGON_V6_vsub_qf16", "V6.vsub.qf16.128B" => "__builtin_HEXAGON_V6_vsub_qf16_128B", "V6.vsub.qf16.mix" => "__builtin_HEXAGON_V6_vsub_qf16_mix", @@ -2396,6 +2516,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vsub.sf.bf.128B" => "__builtin_HEXAGON_V6_vsub_sf_bf_128B", "V6.vsub.sf.hf" => "__builtin_HEXAGON_V6_vsub_sf_hf", "V6.vsub.sf.hf.128B" => "__builtin_HEXAGON_V6_vsub_sf_hf_128B", + "V6.vsub.sf.mix" => "__builtin_HEXAGON_V6_vsub_sf_mix", + "V6.vsub.sf.mix.128B" => "__builtin_HEXAGON_V6_vsub_sf_mix_128B", "V6.vsub.sf.sf" => "__builtin_HEXAGON_V6_vsub_sf_sf", "V6.vsub.sf.sf.128B" => "__builtin_HEXAGON_V6_vsub_sf_sf_128B", "V6.vsubb" => "__builtin_HEXAGON_V6_vsubb", @@ -4883,6 +5005,26 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "f2ull.rp.ftz" => "__nvvm_f2ull_rp_ftz", "f2ull.rz" => "__nvvm_f2ull_rz", "f2ull.rz.ftz" => "__nvvm_f2ull_rz_ftz", + "f32x4.to.e2m1x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e2m1x4_rs_relu_satfinite" + } + "f32x4.to.e2m1x4.rs.satfinite" => "__nvvm_f32x4_to_e2m1x4_rs_satfinite", + "f32x4.to.e2m3x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e2m3x4_rs_relu_satfinite" + } + "f32x4.to.e2m3x4.rs.satfinite" => "__nvvm_f32x4_to_e2m3x4_rs_satfinite", + "f32x4.to.e3m2x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e3m2x4_rs_relu_satfinite" + } + "f32x4.to.e3m2x4.rs.satfinite" => "__nvvm_f32x4_to_e3m2x4_rs_satfinite", + "f32x4.to.e4m3x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e4m3x4_rs_relu_satfinite" + } + "f32x4.to.e4m3x4.rs.satfinite" => "__nvvm_f32x4_to_e4m3x4_rs_satfinite", + "f32x4.to.e5m2x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e5m2x4_rs_relu_satfinite" + } + "f32x4.to.e5m2x4.rs.satfinite" => "__nvvm_f32x4_to_e5m2x4_rs_satfinite", "fabs.d" => "__nvvm_fabs_d", "fabs.f" => "__nvvm_fabs_f", "fabs.ftz.f" => "__nvvm_fabs_ftz_f", @@ -4902,10 +5044,18 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "ff.to.ue8m0x2.rz.satfinite" => "__nvvm_ff_to_ue8m0x2_rz_satfinite", "ff2bf16x2.rn" => "__nvvm_ff2bf16x2_rn", "ff2bf16x2.rn.relu" => "__nvvm_ff2bf16x2_rn_relu", + "ff2bf16x2.rs" => "__nvvm_ff2bf16x2_rs", + "ff2bf16x2.rs.relu" => "__nvvm_ff2bf16x2_rs_relu", + "ff2bf16x2.rs.relu.satfinite" => "__nvvm_ff2bf16x2_rs_relu_satfinite", + "ff2bf16x2.rs.satfinite" => "__nvvm_ff2bf16x2_rs_satfinite", "ff2bf16x2.rz" => "__nvvm_ff2bf16x2_rz", "ff2bf16x2.rz.relu" => "__nvvm_ff2bf16x2_rz_relu", "ff2f16x2.rn" => "__nvvm_ff2f16x2_rn", "ff2f16x2.rn.relu" => "__nvvm_ff2f16x2_rn_relu", + "ff2f16x2.rs" => "__nvvm_ff2f16x2_rs", + "ff2f16x2.rs.relu" => "__nvvm_ff2f16x2_rs_relu", + "ff2f16x2.rs.relu.satfinite" => "__nvvm_ff2f16x2_rs_relu_satfinite", + "ff2f16x2.rs.satfinite" => "__nvvm_ff2f16x2_rs_satfinite", "ff2f16x2.rz" => "__nvvm_ff2f16x2_rz", "ff2f16x2.rz.relu" => "__nvvm_ff2f16x2_rz_relu", "floor.d" => "__nvvm_floor_d", @@ -5129,6 +5279,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "read.ptx.sreg.envreg8" => "__nvvm_read_ptx_sreg_envreg8", "read.ptx.sreg.envreg9" => "__nvvm_read_ptx_sreg_envreg9", "read.ptx.sreg.globaltimer" => "__nvvm_read_ptx_sreg_globaltimer", + "read.ptx.sreg.globaltimer.lo" => "__nvvm_read_ptx_sreg_globaltimer_lo", "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_gridid", // [DUPLICATE]: "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_", "read.ptx.sreg.laneid" => "__nvvm_read_ptx_sreg_laneid", @@ -5803,6 +5954,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "altivec.vupklsw" => "__builtin_altivec_vupklsw", "bcdadd" => "__builtin_ppc_bcdadd", "bcdadd.p" => "__builtin_ppc_bcdadd_p", + "bcdcopysign" => "__builtin_ppc_bcdcopysign", + "bcdsetsign" => "__builtin_ppc_bcdsetsign", "bcdsub" => "__builtin_ppc_bcdsub", "bcdsub.p" => "__builtin_ppc_bcdsub_p", "bpermd" => "__builtin_bpermd", @@ -6160,6 +6313,9 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "aes64im" => "__builtin_riscv_aes64im", "aes64ks1i" => "__builtin_riscv_aes64ks1i", "aes64ks2" => "__builtin_riscv_aes64ks2", + "mips.ehb" => "__builtin_riscv_mips_ehb", + "mips.ihb" => "__builtin_riscv_mips_ihb", + "mips.pause" => "__builtin_riscv_mips_pause", "sha512sig0" => "__builtin_riscv_sha512sig0", "sha512sig0h" => "__builtin_riscv_sha512sig0h", "sha512sig0l" => "__builtin_riscv_sha512sig0l", From 02608ff7b568dadcc844a6a687f168a21c5d48b5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 1 Nov 2025 11:21:17 -0400 Subject: [PATCH 64/67] Update to nightly-2025-11-01 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index ec625481add1b..b7765a0d591fa 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-09-30" +channel = "nightly-2025-11-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From cd5a50d5088c4a86610f3a1bbde15c536b26b12f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 1 Nov 2025 11:31:16 -0400 Subject: [PATCH 65/67] Fix mini_core tests --- example/mini_core.rs | 24 +++++++++++++++++++++--- example/mini_core_hello_world.rs | 10 +++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 5afedf9d40172..64a5b431bd07e 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -603,7 +603,7 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> fo impl Box { pub fn new(val: T) -> Box { unsafe { - let size = intrinsics::size_of::(); + let size = size_of::(); let ptr = libc::malloc(size); intrinsics::copy(&val as *const T as *const u8, ptr, size); Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global) @@ -657,11 +657,11 @@ pub mod intrinsics { #[rustc_intrinsic] pub fn abort() -> !; #[rustc_intrinsic] - pub fn size_of() -> usize; + pub const fn size_of() -> usize; #[rustc_intrinsic] pub unsafe fn size_of_val(val: *const T) -> usize; #[rustc_intrinsic] - pub fn align_of() -> usize; + pub const fn align_of() -> usize; #[rustc_intrinsic] pub unsafe fn align_of_val(val: *const T) -> usize; #[rustc_intrinsic] @@ -699,6 +699,24 @@ pub mod libc { } } +pub const fn size_of() -> usize { + ::SIZE +} + +pub const fn align_of() -> usize { + ::ALIGN +} + +trait SizedTypeProperties: Sized { + #[lang = "mem_size_const"] + const SIZE: usize = intrinsics::size_of::(); + + #[lang = "mem_align_const"] + const ALIGN: usize = intrinsics::align_of::(); +} + +impl SizedTypeProperties for T {} + #[lang = "index"] pub trait Index { type Output: ?Sized; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1e601d42413cb..45154ff072f44 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -90,8 +90,8 @@ fn start( ) -> isize { if argc == 3 { unsafe { puts(*argv); } - unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); } - unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + 2 * size_of::<*const u8>()) as *const *const u8)); } } main().report(); @@ -154,7 +154,7 @@ fn main() { let slice = &[0, 1] as &[i32]; let slice_ptr = slice as *const [i32] as *const i32; - let align = intrinsics::align_of::<*const i32>(); + let align = align_of::<*const i32>(); assert_eq!(slice_ptr as usize % align, 0); //return; @@ -195,8 +195,8 @@ fn main() { assert_eq!(intrinsics::size_of_val(a) as u8, 8); assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); - assert_eq!(intrinsics::align_of::() as u8, 2); - assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8); + assert_eq!(align_of::() as u8, 2); + assert_eq!(intrinsics::align_of_val(&a) as u8, align_of::<&str>() as u8); let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); From 76a7e795f2545f82a8c3e91d16e4acc10724c308 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 4 Nov 2025 08:51:47 -0500 Subject: [PATCH 66/67] Update to nightly-2025-11-04 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index b7765a0d591fa..9813bbea00c41 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-11-01" +channel = "nightly-2025-11-04" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From dcc2f33c672a9803ff36e4ca36c6012695d82597 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 4 Nov 2025 16:22:37 +0100 Subject: [PATCH 67/67] Update GCC submodule --- src/gcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gcc b/src/gcc index 4e995bd73c449..28b84db392ac0 160000 --- a/src/gcc +++ b/src/gcc @@ -1 +1 @@ -Subproject commit 4e995bd73c4490edfe5080ec6014d63aa9abed5f +Subproject commit 28b84db392ac0a572f1a2a2a1317aa5f2bc742cb