Skip to content
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
86fbc24
Simplify running tests
GuillaumeGomez Jan 29, 2026
520806e
cg_gcc: remove Clippy expect attribute
flip1995 Feb 12, 2026
3c3d98f
Auto merge of #152533 - flip1995:clippy-subtree-update, r=Manishearth
bors Feb 13, 2026
d8d041d
Merge commit '70ae207ff5dcd67931c0e67cb62ebceec75a7436' into subtree-…
GuillaumeGomez Feb 14, 2026
e96a4e2
Fix libgccjit version
GuillaumeGomez Feb 14, 2026
2d960ba
Remove code for ThinLTO from cg_gcc
bjorn3 Feb 13, 2026
813ddbf
Correctly split between release and debug lang tests run
GuillaumeGomez Feb 12, 2026
0be3954
Merge pull request #845 from GuillaumeGomez/simplify-tests
GuillaumeGomez Feb 16, 2026
d02e45a
add write_box_via_move intrinsic and use it for vec!
RalfJung Oct 26, 2025
dc3e9cc
Remove ModuleBuffer ThinBuffer duplication
bjorn3 Feb 12, 2026
b1ab6bc
Simplify function signatures of serialize_module and prepare_thin
bjorn3 Feb 12, 2026
0aa7ba6
Remove last remaining ModuleBuffer/ThinBuffer duplication
bjorn3 Feb 13, 2026
0ca7071
Fix CI
antoyo Feb 21, 2026
2640671
Merge pull request #855 from rust-lang/fix/ci
antoyo Feb 21, 2026
ea89e82
Allow to have compile-only tests
GuillaumeGomez Feb 23, 2026
615476a
Move intrinsics tests into `tests/compile` since they only need to co…
GuillaumeGomez Jan 29, 2026
ec14a11
Move more code between the `run_binary` condition since it's only nee…
GuillaumeGomez Feb 23, 2026
01cda7d
Ignore `compile/simd-ffi.rs` test on `m68k` target
GuillaumeGomez Feb 23, 2026
2bb1a43
Improve code readability of `tests/lang_tests.rs`
GuillaumeGomez Feb 23, 2026
dc273bf
Merge pull request #846 from GuillaumeGomez/compile-only
GuillaumeGomez Feb 23, 2026
383bd74
Merge typeid_metadata into type_checked_load
bjorn3 Feb 24, 2026
755b5b0
Reorder associated types in BackendTypes to be a bit more logical
bjorn3 Feb 24, 2026
9604a5f
allow clippy::collapsible_match in cg_gcc
flip1995 Feb 24, 2026
2818318
Add regression test for <https://github.com/rust-lang/rustc_codegen_g…
GuillaumeGomez Feb 24, 2026
977712b
Introduce FunctionSignature associated type for BackendTypes
bjorn3 Feb 24, 2026
097b6b3
Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup
hoodmane Jan 27, 2026
1827789
Merge const_data_from_alloc into static_addr_of
bjorn3 Feb 24, 2026
bc4a848
Merge pull request #847 from GuillaumeGomez/log-test
antoyo Feb 25, 2026
f99b85c
Update GCC version
antoyo Feb 25, 2026
66d6f7b
Merge pull request #856 from rust-lang/update-gcc
antoyo Feb 25, 2026
1b01acd
Rollup merge of #151771 - hoodmane:wasm-double-panic, r=bjorn3
jhpratt Feb 26, 2026
ceafbd1
Rollup merge of #153046 - bjorn3:cg_ssa_cleanups, r=TaKO8Ki
JonathanBrouwer Mar 2, 2026
4598930
Replace CodegenResults with CompiledModules
bjorn3 Oct 23, 2025
3cd6b24
Move print_pass_timings and print_statistics calls to rustc_interface
bjorn3 Feb 15, 2026
8e7a49f
Fuse codegen into LTO optimize methods
bjorn3 Feb 15, 2026
459d84d
Move some methods to WriteBackendMethods
bjorn3 Feb 15, 2026
0e15610
refactor `PointeeInfo`
WaffleLapkin Feb 19, 2026
e88e7b9
make `PointeeInfo::align` non-optional
WaffleLapkin Feb 25, 2026
1c333b6
Auto merge of #150447 - WaffleLapkin:maybe-dangling-semantics, r=Ralf…
bors Mar 5, 2026
241a104
Change TODO in compiler to FIXME
reddevilmidzy Feb 27, 2026
1219e46
abi: s/ScalableVector/SimdScalableVector
davidtwco Mar 2, 2026
20229d7
Move `Spanned`.
nnethercote Mar 10, 2026
ad5b7a3
Auto merge of #153673 - JonathanBrouwer:rollup-cGOKonI, r=JonathanBro…
bors Mar 11, 2026
f898471
de-duplicate LayoutError formatting
RalfJung Mar 9, 2026
25a7f23
Move `powif16` next to `powif128`
N1ark Mar 14, 2026
99aecac
handle minimumf128/maximumf128 in get_simple_function_f128_2args
N1ark Mar 14, 2026
f67c935
Simplify get_simple_function
N1ark Mar 14, 2026
2acd77e
Fix TODO: only call f128 fns if is a f128 fn
N1ark Mar 14, 2026
41f5085
Inline `get_simple_function`
N1ark Mar 14, 2026
2205317
Merge pull request #863 from N1ark/tidy-float-intrinsics
antoyo Mar 15, 2026
8ed9af7
rename min/maxnum intrinsics to min/maximum_number and fix their LLVM…
RalfJung Mar 3, 2026
f2aa873
Auto merge of #153166 - reddevilmidzy:codegen-tidy, r=lcnr
bors Mar 15, 2026
071a36d
Merge `fabsfN` into `fabs::<F>`
N1ark Mar 15, 2026
383705e
Remove `InvalidMonomorphization::FloatingPointType`
N1ark Mar 14, 2026
646b64f
simd_fmin/fmax: make semantics and name consistent with scalar intrin…
RalfJung Mar 18, 2026
552fc2f
Errored when inline asm contans null bytes (#859)
harin-ramesh Mar 26, 2026
66d7029
Merge branch 'master' into sync_from_rust_2026_03_13-2
antoyo Mar 26, 2026
6504b84
Update to nightly-2026-03-13
antoyo Mar 13, 2026
030fc0b
Remove duplicated tests
antoyo Mar 13, 2026
e2bac36
Fix asm test
antoyo Mar 13, 2026
522eeb4
Disable ThinLTO on jobs that don't support LTO
bjorn3 Mar 23, 2026
fc56ab4
Add patch for testing sysroot
bjorn3 Mar 23, 2026
20563ee
Update list of failing tests
bjorn3 Mar 23, 2026
891c9ce
Implement missing f16/f128 intrinsics
antoyo Feb 27, 2026
445413c
Merge pull request #865 from rust-lang/sync_from_rust_2026_03_13-2
antoyo Mar 26, 2026
b4c6aea
Merge branch 'master' into sync_from_rust_2026_03_26
antoyo Mar 26, 2026
cb6ac84
Update to nightly-2026-03-26
antoyo Mar 26, 2026
c45e0fc
Remove useless patch
antoyo Mar 26, 2026
822e759
Fix rebase
antoyo Mar 26, 2026
76c348d
Format code
antoyo Mar 26, 2026
daf8bb9
Fix #570: Honor #![no_builtins] attribute by passing -fno-builtin to …
harin-ramesh Mar 27, 2026
5d08e76
Rollup merge of #154043 - RalfJung:simd-min-max, r=Amanieu,calebzulaw…
GuillaumeGomez Mar 28, 2026
3af067d
Use closures more consistently in `dep_graph.rs`.
nnethercote Mar 17, 2026
4205004
Move some thin local LTO handling to start_executing_work
bjorn3 Feb 12, 2026
2bf125f
Introduce ThinLtoInput
bjorn3 Feb 13, 2026
36ac535
Revert "Fix: On wasm targets, call `panic_in_cleanup` if panic occurs…
wesleywiser Apr 2, 2026
c5fc579
ty_utils: lower tuples to `ScalableVector` repr
davidtwco Feb 19, 2026
165fa89
cg_llvm/debuginfo: scalable vectors
davidtwco Feb 26, 2026
36360f8
Add dummy implementation of mory tile intrinsics
antoyo Apr 5, 2026
62d5f3c
Update GCC version
antoyo Apr 5, 2026
0252670
Update Intel SDE version used to fix the stdarch tests
antoyo Apr 5, 2026
9886ca5
Merge pull request #866 from rust-lang/sync_from_rust_2026_03_26
antoyo Apr 5, 2026
e35c0b8
Rollup merge of #153440 - bjorn3:lto_refactors13, r=TaKO8Ki
JonathanBrouwer Apr 6, 2026
40746da
Move `rustc_middle::mir::mono` to `rustc_middle::mono`
nnethercote Mar 24, 2026
17d844f
Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register …
androm3da Apr 2, 2026
6a4344b
Merge branch 'master' into sync_from_rust_2026_04_05
antoyo Apr 8, 2026
b26e2fd
Update to nightly-2026-04-05
antoyo Apr 8, 2026
2a8edb2
Format the code
antoyo Apr 8, 2026
8d47a1a
Rollup merge of #154719 - androm3da:hexagon-inline-asm-register-class…
JonathanBrouwer Apr 8, 2026
da0c871
Store a PathBuf rather than SerializedModule for cached modules
bjorn3 Apr 8, 2026
1a8c5be
Fix transmuted function pointer calls
cijiugechu Apr 10, 2026
ed85398
Use crate_type = lib
cijiugechu Apr 10, 2026
d252dd6
Refactor
cijiugechu Apr 10, 2026
e41c82a
Fix on-stack handling for indirect calls
cijiugechu Apr 10, 2026
c863465
Add `#[unsafe(no_mangle)]`
cijiugechu Apr 10, 2026
1bf42b4
preseve SIMD element type information
folkertdev Apr 8, 2026
f0ff3e5
Rollup merge of #153997 - nnethercote:closure-consistency, r=petroche…
JonathanBrouwer Apr 13, 2026
92c02ec
Use `!null` pattern type in libcore
oli-obk May 17, 2025
9871c07
Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
bors Apr 13, 2026
2980d50
Rollup merge of #155005 - folkertdev:simd-element-type-llvm, r=nnethe…
jhpratt Apr 14, 2026
60ef0f0
Refactor FnDecl and FnSig flags into packed structs
teor2345 Apr 8, 2026
6824c31
Use FnAbi for indirect call ABI
cijiugechu Apr 17, 2026
9eac862
Unmark dylib-dep.rs as failing
cijiugechu Apr 17, 2026
3084520
Rename invoke fn_abi param
cijiugechu Apr 17, 2026
7db7c9b
Ignore failing UI tests
antoyo Apr 17, 2026
0c99072
Fix maximum/minimum float intrinsics
antoyo Apr 17, 2026
d10ab82
fix all errors
adwinwhite Apr 15, 2026
af8efe2
Rollup merge of #155036 - bjorn3:lto_refactors16, r=TaKO8Ki
JonathanBrouwer Apr 21, 2026
529953e
Fix fabs bug
antoyo Apr 29, 2026
f2a236e
Add some float tests from libcore
antoyo Apr 29, 2026
c936fd9
Merge pull request #870 from rust-lang/sync_from_rust_2026_04_05
antoyo Apr 29, 2026
39e47ae
Merge branch 'master' into sync_from_rust_2026_04_29
antoyo Apr 29, 2026
228e254
Update to nightly-2026-04-29
antoyo Apr 29, 2026
d2b7a2e
Fix minicore
antoyo Apr 29, 2026
d46f3aa
Add failing UI tests
antoyo Apr 29, 2026
897df45
Merge pull request #878 from rust-lang/sync_from_rust_2026_04_29
antoyo Apr 29, 2026
d189e9f
Merge pull request #873 from cijiugechu/fix/transmuted-fn-ptr-call
antoyo Apr 29, 2026
4a36bb0
Merge commit 'd189e9f23c4c971546cb59bf43ab4df0e5552770' into subtree-…
GuillaumeGomez Apr 29, 2026
04c5d1e
Update GCC submodule
GuillaumeGomez Apr 29, 2026
f3d34dc
Fix tidy errors in cg_gcc
GuillaumeGomez Apr 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:

- name: Run y.sh cargo build
run: |
./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml
CARGO_PROFILE_DEV_LTO=no ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml

- name: Clean
run: |
Expand All @@ -119,7 +119,7 @@ jobs:

- name: Run tests
run: |
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }}
./y.sh test --release --clean --build-sysroot --no-builtins-tests ${{ matrix.commands }}

duplicates:
runs-on: ubuntu-24.04
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_gcc/.github/workflows/failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ jobs:

- name: Install libgccjit12
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
run: sudo apt-get install libgccjit-12-dev
run: |
sudo apt-get update
sudo apt-get install libgccjit-12-dev
- name: Setup path to libgccjit
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_gcc/.github/workflows/gcc12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ jobs:

- name: Install packages
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
run: sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev
run: |
sudo apt-get update
sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev

- name: Setup path to libgccjit
run: echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/.github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: |
./y.sh prepare --only-libcore --cross
./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 -Zjson-target-spec --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
CARGO_PROFILE_DEV_LTO=no CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build -Zjson-target-spec --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh clean all

- name: Build
Expand All @@ -110,7 +110,7 @@ jobs:

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
CARGO_PROFILE_DEV_LTO=no 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"
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ jobs:
run: |
mkdir intel-sde
cd intel-sde
dir=sde-external-9.33.0-2024-01-07-lin
version=10.8.0-2026-03-15
url_path=915934
dir=sde-external-$version-lin
file=$dir.tar.xz
wget https://downloadmirror.intel.com/813591/$file
wget https://downloadmirror.intel.com/$url_path/$file
tar xvf $file
sudo mkdir /usr/share/intel-sde
sudo cp -r $dir/* /usr/share/intel-sde
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_codegen_gcc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ license = "MIT OR Apache-2.0"
crate-type = ["dylib"]

[[test]]
name = "lang_tests_debug"
path = "tests/lang_tests_debug.rs"
harness = false
[[test]]
name = "lang_tests_release"
path = "tests/lang_tests_release.rs"
name = "lang_tests"
path = "tests/lang_tests.rs"
harness = false

[features]
Expand Down
61 changes: 61 additions & 0 deletions compiler/rustc_codegen_gcc/build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn get_runners() -> Runners {
runners.insert("--extended-regex-tests", ("Run extended regex tests", extended_regex_tests));
runners.insert("--mini-tests", ("Run mini tests", mini_tests));
runners.insert("--cargo-tests", ("Run cargo tests", cargo_tests));
runners.insert("--no-builtins-tests", ("Test #![no_builtins] attribute", no_builtins_tests));
runners
}

Expand Down Expand Up @@ -317,6 +318,65 @@ fn maybe_run_command_in_vm(
Ok(())
}

/// Compile a source file to an object file and check if it contains a memset reference.
fn object_has_memset(
env: &Env,
args: &TestArg,
src_file: &str,
obj_file_name: &str,
) -> Result<bool, String> {
let cargo_target_dir = Path::new(&args.config_info.cargo_target_dir);
let obj_file = cargo_target_dir.join(obj_file_name);
let obj_file_str = obj_file.to_str().expect("obj_file to_str");

let mut command = args.config_info.rustc_command_vec();
command.extend_from_slice(&[
&src_file,
&"--emit",
&"obj",
&"-O",
&"--target",
&args.config_info.target_triple,
&"-o",
]);
command.push(&obj_file_str);
run_command_with_env(&command, None, Some(env))?;

let nm_output = run_command_with_env(&[&"nm", &obj_file_str], None, Some(env))?;
let nm_stdout = String::from_utf8_lossy(&nm_output.stdout);

Ok(nm_stdout.contains("memset"))
}

fn no_builtins_tests(env: &Env, args: &TestArg) -> Result<(), String> {
// Test that the #![no_builtins] attribute prevents GCC from replacing
// code patterns (like loops) with calls to builtins (like memset).
// See https://github.com/rust-lang/rustc_codegen_gcc/issues/570

// Test 1: WITH #![no_builtins] - memset should NOT be present
println!("[TEST] no_builtins attribute (with #![no_builtins])");
let has_memset =
object_has_memset(env, args, "tests/no_builtins/no_builtins.rs", "no_builtins_test.o")?;
if has_memset {
return Err("no_builtins test FAILED: Found 'memset' in object file.\n\
The #![no_builtins] attribute should prevent GCC from replacing \n\
code patterns with builtin calls."
.to_string());
}

// Test 2: WITHOUT #![no_builtins] - memset SHOULD be present
println!("[TEST] no_builtins attribute (without #![no_builtins])");
let has_memset =
object_has_memset(env, args, "tests/no_builtins/with_builtins.rs", "with_builtins_test.o")?;
if !has_memset {
return Err("no_builtins test FAILED: 'memset' NOT found in object file.\n\
Without #![no_builtins], GCC should replace the loop with memset."
.to_string());
}

Ok(())
}

fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
let cargo_target_dir = Path::new(&args.config_info.cargo_target_dir);
// FIXME: create a function "display_if_not_quiet" or something along the line.
Expand Down Expand Up @@ -1248,6 +1308,7 @@ fn run_all(env: &Env, args: &TestArg) -> Result<(), String> {
test_libcore(env, args)?;
extended_sysroot_tests(env, args)?;
cargo_tests(env, args)?;
no_builtins_tests(env, args)?;
test_rustc(env, args)?;

Ok(())
Expand Down
56 changes: 49 additions & 7 deletions compiler/rustc_codegen_gcc/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@
#![no_core]
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]

#[lang = "pointee_trait"]
pub trait Pointee: PointeeSized {
#[lang = "metadata_type"]
// needed so that layout_of will return `TooGeneric` instead of `Unknown`
// when asked for the layout of `*const T`. Which is important for making
// transmutes between raw pointers (and especially pattern types of raw pointers)
// work.
type Metadata: Copy + Sync + Unpin + Freeze;
}

#[lang = "dyn_metadata"]
pub struct DynMetadata<Dyn: PointeeSized> {
_vtable_ptr: NonNull<VTable>,
_phantom: PhantomData<Dyn>,
}

unsafe extern "C" {
/// Opaque type for accessing vtables.
///
/// Private implementation detail of `DynMetadata::size_of` etc.
/// There is conceptually not actually any Abstract Machine memory behind this pointer.
type VTable;
}

#[no_mangle]
unsafe extern "C" fn _Unwind_Resume() {
intrinsics::unreachable();
Expand Down Expand Up @@ -113,7 +137,7 @@ unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
unsafe impl Sync for [u8; 16] {}

#[lang = "freeze"]
unsafe auto trait Freeze {}
pub unsafe auto trait Freeze {}

unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
unsafe impl<T: PointeeSized> Freeze for *const T {}
Expand Down Expand Up @@ -592,6 +616,13 @@ macro_rules! pattern_type {
};
}

impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<pattern_type!(*const U is !null)> for pattern_type!(*const T is !null) where
T: Unsize<U>
{
}

impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<pattern_type!(U is !null)> for pattern_type!(T is !null) {}

impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}

Expand All @@ -604,26 +635,37 @@ impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> wh
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}

#[lang = "owned_box"]
pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);
pub struct Box<T: ?Sized, A = Global>(Unique<T>, A);

impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}

impl<T> Box<T> {
pub fn new(val: T) -> Box<T> {
unsafe {
let size = size_of::<T>();
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)
Box(
Unique {
pointer: NonNull(intrinsics::transmute::<
*mut u8,
pattern_type!(*const T is !null),
>(ptr)),
_marker: PhantomData,
},
Global,
)
}
}
}

impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
impl<T: ?Sized, A> Drop for Box<T, A> {
fn drop(&mut self) {
// inner value is dropped by compiler.
// inner value is dropped by compiler
unsafe {
libc::free(self.0.pointer.0 as *mut u8);
libc::free(intrinsics::transmute::<pattern_type!(*const T is !null), *const T>(
self.0.pointer.0,
) as *mut u8);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
efdd0a7290c22f5438d7c5380105d353ee3e8518
6f155cc3f5a2dff33afe6cc3ed6c2e0e605ae6a3
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2026-02-14"
channel = "nightly-2026-04-29"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
11 changes: 2 additions & 9 deletions compiler/rustc_codegen_gcc/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,8 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {

fn ptr_to_gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
// FIXME(antoyo): Should we do something with `FnAbiGcc::fn_attributes`?
let FnAbiGcc { return_type, arguments_type, is_c_variadic, on_stack_param_indices, .. } =
self.gcc_type(cx);
let pointer_type =
cx.context.new_function_pointer_type(None, return_type, &arguments_type, is_c_variadic);
cx.on_stack_params.borrow_mut().insert(
pointer_type.dyncast_function_ptr_type().expect("function ptr type"),
on_stack_param_indices,
);
pointer_type
let FnAbiGcc { return_type, arguments_type, is_c_variadic, .. } = self.gcc_type(cx);
cx.context.new_function_pointer_type(None, return_type, &arguments_type, is_c_variadic)
}

#[cfg(feature = "master")]
Expand Down
22 changes: 18 additions & 4 deletions compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use rustc_codegen_ssa::traits::{
};
use rustc_middle::bug;
use rustc_middle::ty::Instance;
use rustc_span::Span;
use rustc_span::{DUMMY_SP, Span};
use rustc_target::asm::*;

use crate::builder::Builder;
use crate::callee::get_fn;
use crate::context::CodegenCx;
use crate::errors::UnwindingInlineAsm;
use crate::errors::{NulBytesInAsm, UnwindingInlineAsm};
use crate::type_of::LayoutGccExt;

// Rust asm! and GCC Extended Asm semantics differ substantially.
Expand Down Expand Up @@ -530,8 +530,15 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
template_str.push_str(INTEL_SYNTAX_INS);
}

// 4. Generate Extended Asm block
// NOTE: GCC's extended asm uses CString which cannot contain nul bytes.
// Emit an error if there are any nul bytes in the template string.
if template_str.contains('\0') {
let err_sp = span.first().copied().unwrap_or(DUMMY_SP);
self.sess().dcx().emit_err(NulBytesInAsm { span: err_sp });
return;
}

// 4. Generate Extended Asm block
let block = self.llbb();
let extended_asm = if let Some(dest) = dest {
assert!(!labels.is_empty());
Expand Down Expand Up @@ -875,7 +882,7 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
template: &[InlineAsmTemplatePiece],
operands: &[GlobalAsmOperandRef<'tcx>],
options: InlineAsmOptions,
_line_spans: &[Span],
line_spans: &[Span],
) {
let asm_arch = self.tcx.sess.asm_arch.unwrap();

Expand Down Expand Up @@ -942,6 +949,13 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}
// NOTE: seems like gcc will put the asm in the wrong section, so set it to .text manually.
template_str.push_str("\n.popsection");
// NOTE: GCC's add_top_level_asm uses CString which cannot contain nul bytes.
// Emit an error if there are any nul bytes in the template string.
if template_str.contains('\0') {
let span = line_spans.first().copied().unwrap_or(DUMMY_SP);
self.tcx.dcx().emit_err(NulBytesInAsm { span });
return;
}
self.context.add_top_level_asm(None, &template_str);
}

Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_codegen_ssa::traits::DebugInfoCodegenMethods;
use rustc_hir::attrs::Linkage;
use rustc_hir::attrs::{AttributeKind, Linkage};
use rustc_hir::find_attr;
use rustc_middle::dep_graph;
#[cfg(feature = "master")]
use rustc_middle::mono::Visibility;
Expand Down Expand Up @@ -137,6 +138,17 @@ pub fn compile_codegen_unit(
// NOTE: Rust relies on LLVM doing wrapping on overflow.
context.add_command_line_option("-fwrapv");

// NOTE: We need to honor the `#![no_builtins]` attribute to prevent GCC from
// replacing code patterns (like loops) with calls to builtins (like memset).
// The `-fno-tree-loop-distribute-patterns` flag disables the loop distribution pass
// that transforms loops into calls to library functions (memset, memcpy, etc.).
// See GCC handling for more details:
// https://github.com/rust-lang/gcc/blob/efdd0a7290c22f5438d7c5380105d353ee3e8518/gcc/c-family/c-opts.cc#L953
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
if find_attr!(crate_attrs, AttributeKind::NoBuiltins) {
context.add_command_line_option("-fno-tree-loop-distribute-patterns");
}

if let Some(model) = tcx.sess.code_model() {
use rustc_target::spec::CodeModel;

Expand Down
Loading
Loading