Skip to content

Commit a08ea6e

Browse files
committed
Merge branch 'master' into sync_from_rust_2026_03_13
2 parents f898471 + 66d6f7b commit a08ea6e

File tree

14 files changed

+409
-193
lines changed

14 files changed

+409
-193
lines changed

.github/workflows/failures.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ jobs:
4848

4949
- name: Install libgccjit12
5050
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
51-
run: sudo apt-get install libgccjit-12-dev
51+
run: |
52+
sudo apt-get update
53+
sudo apt-get install libgccjit-12-dev
5254
5355
- name: Setup path to libgccjit
5456
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'

.github/workflows/gcc12.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ jobs:
4646

4747
- name: Install packages
4848
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
49-
run: sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev
5052
5153
- name: Setup path to libgccjit
5254
run: echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml

Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ license = "MIT OR Apache-2.0"
99
crate-type = ["dylib"]
1010

1111
[[test]]
12-
name = "lang_tests_debug"
13-
path = "tests/lang_tests_debug.rs"
14-
harness = false
15-
[[test]]
16-
name = "lang_tests_release"
17-
path = "tests/lang_tests_release.rs"
12+
name = "lang_tests"
13+
path = "tests/lang_tests.rs"
1814
harness = false
1915

2016
[features]

example/mini_core_hello_world.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
)]
77
#![no_core]
88
#![allow(dead_code, internal_features, non_camel_case_types)]
9-
#![rustfmt_skip]
9+
#![cfg_attr(rustfmt, rustfmt_skip)]
1010

1111
extern crate mini_core;
1212

libgccjit.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
efdd0a7290c22f5438d7c5380105d353ee3e8518
1+
2e6a09afb8d9ee9e190a81b0d7e3118251ebcb9a

src/archive.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::path::Path;
2+
3+
use rustc_codegen_ssa::back::archive::{
4+
ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
5+
};
6+
use rustc_session::Session;
7+
8+
pub(crate) struct ArArchiveBuilderBuilder;
9+
10+
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
11+
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
12+
Box::new(ArArchiveBuilder::new(sess, &DEFAULT_OBJECT_READER))
13+
}
14+
15+
fn create_dll_import_lib(
16+
&self,
17+
_sess: &Session,
18+
_lib_name: &str,
19+
_import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
20+
_output_path: &Path,
21+
) {
22+
unimplemented!("creating dll imports is not yet supported");
23+
}
24+
}

src/intrinsic/mod.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,44 +74,8 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
7474
sym::fabsf64 => "fabs",
7575
sym::minnumf32 => "fminf",
7676
sym::minnumf64 => "fmin",
77-
sym::minimumf32 => "fminimumf",
78-
sym::minimumf64 => "fminimum",
79-
sym::minimumf128 => {
80-
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
81-
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html
82-
let f128_type = cx.type_f128();
83-
return Some(cx.context.new_function(
84-
None,
85-
FunctionType::Extern,
86-
f128_type,
87-
&[
88-
cx.context.new_parameter(None, f128_type, "a"),
89-
cx.context.new_parameter(None, f128_type, "b"),
90-
],
91-
"fminimumf128",
92-
false,
93-
));
94-
}
9577
sym::maxnumf32 => "fmaxf",
9678
sym::maxnumf64 => "fmax",
97-
sym::maximumf32 => "fmaximumf",
98-
sym::maximumf64 => "fmaximum",
99-
sym::maximumf128 => {
100-
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
101-
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html
102-
let f128_type = cx.type_f128();
103-
return Some(cx.context.new_function(
104-
None,
105-
FunctionType::Extern,
106-
f128_type,
107-
&[
108-
cx.context.new_parameter(None, f128_type, "a"),
109-
cx.context.new_parameter(None, f128_type, "b"),
110-
],
111-
"fmaximumf128",
112-
false,
113-
));
114-
}
11579
sym::copysignf32 => "copysignf",
11680
sym::copysignf64 => "copysign",
11781
sym::floorf32 => "floorf",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Compiler:
2+
3+
// FIXME: Remove this test once rustc's `./tests/codegen/riscv-abi/call-llvm-intrinsics.rs`
4+
// stops ignoring GCC backend.
5+
6+
#![feature(link_llvm_intrinsics)]
7+
#![crate_type = "lib"]
8+
#![allow(internal_features)]
9+
10+
struct A;
11+
12+
impl Drop for A {
13+
fn drop(&mut self) {
14+
println!("A");
15+
}
16+
}
17+
18+
extern "C" {
19+
#[link_name = "llvm.sqrt.f32"]
20+
fn sqrt(x: f32) -> f32;
21+
}
22+
23+
pub fn do_call() {
24+
let _a = A;
25+
26+
unsafe {
27+
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
28+
// CHECK: store float 4.000000e+00, float* %{{.}}, align 4
29+
// CHECK: call float @llvm.sqrt.f32(float %{{.}}
30+
sqrt(4.0);
31+
}
32+
}

tests/compile/log.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Compiler:
2+
3+
extern "C" {
4+
fn log(message_data: u32, message_size: u32);
5+
}
6+
7+
pub fn main() {
8+
let message = "Hello, world!";
9+
unsafe {
10+
log(message.as_ptr() as u32, message.len() as u32);
11+
}
12+
}

tests/compile/simd-ffi.rs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Compiler:
2+
3+
// FIXME: Remove this test once <tests/run-make/simd-ffi/simd.rs> stops
4+
// ignoring GCC backend.
5+
6+
#![allow(internal_features, non_camel_case_types)]
7+
#![crate_type = "lib"]
8+
9+
// we can compile to a variety of platforms, because we don't need
10+
// cross-compiled standard libraries.
11+
#![feature(no_core, auto_traits)]
12+
#![no_core]
13+
#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
14+
15+
#[derive(Copy)]
16+
#[repr(simd)]
17+
pub struct f32x4([f32; 4]);
18+
19+
extern "C" {
20+
#[link_name = "llvm.sqrt.v4f32"]
21+
fn vsqrt(x: f32x4) -> f32x4;
22+
}
23+
24+
pub fn foo(x: f32x4) -> f32x4 {
25+
unsafe { vsqrt(x) }
26+
}
27+
28+
#[derive(Copy)]
29+
#[repr(simd)]
30+
pub struct i32x4([i32; 4]);
31+
32+
extern "C" {
33+
// _mm_sll_epi32
34+
#[cfg(all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"))]
35+
#[link_name = "llvm.x86.sse2.psll.d"]
36+
fn integer(a: i32x4, b: i32x4) -> i32x4;
37+
38+
// vmaxq_s32
39+
#[cfg(target_arch = "arm")]
40+
#[link_name = "llvm.arm.neon.vmaxs.v4i32"]
41+
fn integer(a: i32x4, b: i32x4) -> i32x4;
42+
// vmaxq_s32
43+
#[cfg(target_arch = "aarch64")]
44+
#[link_name = "llvm.aarch64.neon.maxs.v4i32"]
45+
fn integer(a: i32x4, b: i32x4) -> i32x4;
46+
47+
// Use a generic LLVM intrinsic to do type checking on other platforms
48+
#[cfg(not(any(
49+
all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"),
50+
target_arch = "arm",
51+
target_arch = "aarch64"
52+
)))]
53+
#[link_name = "llvm.smax.v4i32"]
54+
fn integer(a: i32x4, b: i32x4) -> i32x4;
55+
}
56+
57+
pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
58+
unsafe { integer(a, b) }
59+
}
60+
61+
#[lang = "pointee_sized"]
62+
pub trait PointeeSized {}
63+
64+
#[lang = "meta_sized"]
65+
pub trait MetaSized: PointeeSized {}
66+
67+
#[lang = "sized"]
68+
pub trait Sized: MetaSized {}
69+
70+
#[lang = "copy"]
71+
pub trait Copy {}
72+
73+
impl Copy for f32 {}
74+
impl Copy for i32 {}
75+
impl Copy for [f32; 4] {}
76+
impl Copy for [i32; 4] {}
77+
78+
pub mod marker {
79+
pub use Copy;
80+
}
81+
82+
#[lang = "freeze"]
83+
auto trait Freeze {}
84+
85+
#[macro_export]
86+
#[rustc_builtin_macro]
87+
macro_rules! Copy {
88+
() => {};
89+
}
90+
#[macro_export]
91+
#[rustc_builtin_macro]
92+
macro_rules! derive {
93+
() => {};
94+
}

0 commit comments

Comments
 (0)