Auto merge of #145890 - GuillaumeGomez:subtree-update_cg_gcc_2025-08-26, r=GuillaumeGomez
GCC backend subtree update
cc `@antoyo`
r? ghost
diff --git a/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml b/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml
index 759d0d5..e49c62d 100644
--- a/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml
+++ b/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml
@@ -82,20 +82,16 @@
- 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 @@
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 }}
+ - name: Run tests
+ run: |
+ ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot ${{ 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
+ - 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)
+ 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/compiler/rustc_codegen_gcc/Cargo.lock b/compiler/rustc_codegen_gcc/Cargo.lock
index 7f35c1a..a5b972b 100644
--- a/compiler/rustc_codegen_gcc/Cargo.lock
+++ b/compiler/rustc_codegen_gcc/Cargo.lock
@@ -56,18 +56,18 @@
[[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/compiler/rustc_codegen_gcc/Cargo.toml b/compiler/rustc_codegen_gcc/Cargo.toml
index 193348d..6031933 100644
--- a/compiler/rustc_codegen_gcc/Cargo.toml
+++ b/compiler/rustc_codegen_gcc/Cargo.toml
@@ -24,7 +24,7 @@
[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/compiler/rustc_codegen_gcc/build_system/src/fmt.rs b/compiler/rustc_codegen_gcc/build_system/src/fmt.rs
index 7e6594f..91535f2 100644
--- a/compiler/rustc_codegen_gcc/build_system/src/fmt.rs
+++ b/compiler/rustc_codegen_gcc/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<P>(dir: P, check: bool) -> Result<(), String>
+where
+ P: AsRef<Path>,
+{
+ 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<OsStr>] = 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/compiler/rustc_codegen_gcc/build_system/src/test.rs b/compiler/rustc_codegen_gcc/build_system/src/test.rs
index 2c8271c..3dd3fce 100644
--- a/compiler/rustc_codegen_gcc/build_system/src/test.rs
+++ b/compiler/rustc_codegen_gcc/build_system/src/test.rs
@@ -531,7 +531,7 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
r#"change-id = 115898
[rust]
-codegen-backends = []
+codegen-backends = ["gcc"]
deny-warnings = false
verbose-tests = true
diff --git a/compiler/rustc_codegen_gcc/libgccjit.version b/compiler/rustc_codegen_gcc/libgccjit.version
index f621549..dc9a001 100644
--- a/compiler/rustc_codegen_gcc/libgccjit.version
+++ b/compiler/rustc_codegen_gcc/libgccjit.version
@@ -1 +1 @@
-04ce66d8c918de9273bd7101638ad8724edf5e21
+4e995bd73c4490edfe5080ec6014d63aa9abed5f
diff --git a/compiler/rustc_codegen_gcc/rust-toolchain b/compiler/rustc_codegen_gcc/rust-toolchain
index 058e734..04d33df 100644
--- a/compiler/rustc_codegen_gcc/rust-toolchain
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs
index fdc15d5..41363d6 100644
--- a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt
index 29032b3..c5e2297 100644
--- a/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt
+++ b/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt
@@ -6,7 +6,6 @@
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/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/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt
index 41fb472..e2615bc 100644
--- a/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt
+++ b/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt
@@ -20,7 +20,7 @@
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/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/compiler/rustc_codegen_gcc/tests/run/int.rs b/compiler/rustc_codegen_gcc/tests/run/int.rs
index e20ecc2..78675ac 100644
--- a/compiler/rustc_codegen_gcc/tests/run/int.rs
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs b/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
index 7887215..78e1cac 100644
--- a/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/tests/run/structs.rs b/compiler/rustc_codegen_gcc/tests/run/structs.rs
index da73cbe..e08e678 100644
--- a/compiler/rustc_codegen_gcc/tests/run/structs.rs
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/tests/run/volatile.rs b/compiler/rustc_codegen_gcc/tests/run/volatile.rs
index 94a7bdc..dc11fbf 100644
--- a/compiler/rustc_codegen_gcc/tests/run/volatile.rs
+++ b/compiler/rustc_codegen_gcc/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/compiler/rustc_codegen_gcc/tests/run/volatile2.rs b/compiler/rustc_codegen_gcc/tests/run/volatile2.rs
index bdcb825..ada1126 100644
--- a/compiler/rustc_codegen_gcc/tests/run/volatile2.rs
+++ b/compiler/rustc_codegen_gcc/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");
}
diff --git a/src/gcc b/src/gcc
index 04ce66d..4e995bd 160000
--- a/src/gcc
+++ b/src/gcc
@@ -1 +1 @@
-Subproject commit 04ce66d8c918de9273bd7101638ad8724edf5e21
+Subproject commit 4e995bd73c4490edfe5080ec6014d63aa9abed5f