Skip to content

Commit

Permalink
Merge pull request #535 from rust-lang/sync_from_rust_2024_07_02
Browse files Browse the repository at this point in the history
Sync from rust 2024/07/02
  • Loading branch information
antoyo authored Jul 5, 2024
2 parents 173773e + 5681c3c commit 98ed962
Show file tree
Hide file tree
Showing 43 changed files with 953 additions and 356 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ jobs:
run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt

- name: Run tests
# TODO: re-enable those tests for libgccjit 12.
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
id: tests
run: |
${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY
- name: Run failing ui pattern tests for ICE
# TODO: re-enable those tests for libgccjit 12.
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
id: ui-tests
run: |
${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log_ui
Expand Down
40 changes: 21 additions & 19 deletions .github/workflows/gcc12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,24 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore --libgccjit12-patches
./y.sh build --sysroot --no-default-features --sysroot-panic-abort
cargo test --no-default-features
./y.sh clean all
- name: Prepare dependencies
run: |
git config --global user.email "user@example.com"
git config --global user.name "User"
./y.sh prepare --libgccjit12-patches
- name: Add more failing tests for GCC 12
run: cat tests/failing-ui-tests12.txt >> tests/failing-ui-tests.txt

- name: Add more failing tests because the sysroot is not compiled with LTO
run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt

- name: Run tests
run: |
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }} --no-default-features
./y.sh build --no-default-features --sysroot-panic-abort
# Uncomment when we no longer need to remove global variables.
#./y.sh build --sysroot --no-default-features --sysroot-panic-abort
#cargo test --no-default-features
#./y.sh clean all
#- name: Prepare dependencies
#run: |
#git config --global user.email "user@example.com"
#git config --global user.name "User"
#./y.sh prepare --libgccjit12-patches

#- name: Add more failing tests for GCC 12
#run: cat tests/failing-ui-tests12.txt >> tests/failing-ui-tests.txt

#- name: Add more failing tests because the sysroot is not compiled with LTO
#run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt

#- name: Run tests
#run: |
#./y.sh test --release --clean --build-sysroot ${{ matrix.commands }} --no-default-features
3 changes: 2 additions & 1 deletion .github/workflows/stdarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ jobs:
if: ${{ matrix.cargo_runner }}
run: |
# FIXME: these tests fail when the sysroot is compiled with LTO because of a missing symbol in proc-macro.
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml -- --skip rtm --skip tbm --skip sse4a
# TODO: remove --skip test_mm512_stream_ps when stdarch is updated in rustc.
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml -- --skip rtm --skip tbm --skip sse4a --skip test_mm512_stream_ps
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ master = ["gccjit/master"]
default = ["master"]

[dependencies]
gccjit = { git = "https://github.com/antoyo/gccjit.rs" }
gccjit = "2.1"

# Local copy.
#gccjit = { path = "../gccjit.rs" }
Expand Down
3 changes: 1 addition & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y

### LTO

To use LTO, you need to set the variable `FAT_LTO=1` and `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`.
Don't set `FAT_LTO` when compiling the sysroot, though: only set `EMBED_LTO_BITCODE=1`.
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:

Expand Down
5 changes: 0 additions & 5 deletions build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,6 @@ impl ConfigInfo {
rustflags.push("-Csymbol-mangling-version=v0".to_string());
}

// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
// TODO(antoyo): remove when we can handle ThinLTO.
if !env.contains_key(&"FAT_LTO".to_string()) {
rustflags.push("-Clto=off".to_string());
}
// FIXME(antoyo): remove once the atomic shim is gone
if os_name == "Darwin" {
rustflags.extend_from_slice(&[
Expand Down
20 changes: 13 additions & 7 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,16 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
//"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
];

let mut env = env.clone();
let rustflags =
format!("{} --cap-lints allow", env.get("RUSTFLAGS").cloned().unwrap_or_default());
env.insert("RUSTFLAGS".to_string(), rustflags);
let run_tests = |projects_path, iter: &mut dyn Iterator<Item = &&str>| -> Result<(), String> {
for project in iter {
let clone_result = git_clone_root_dir(project, projects_path, true)?;
let repo_path = Path::new(&clone_result.repo_dir);
run_cargo_command(&[&"build", &"--release"], Some(repo_path), env, args)?;
run_cargo_command(&[&"test"], Some(repo_path), env, args)?;
run_cargo_command(&[&"build", &"--release"], Some(repo_path), &env, args)?;
run_cargo_command(&[&"test"], Some(repo_path), &env, args)?;
}

Ok(())
Expand Down Expand Up @@ -1034,18 +1038,19 @@ 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")?;
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 result1 = Ok(());
/*test_rustc_inner(
env,
args,
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
);
)*/

let result2 = test_rustc_inner(
env,
Expand All @@ -1066,13 +1071,14 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
false,
"ui",
)?;
test_rustc_inner(
Ok(())
/*test_rustc_inner(
env,
args,
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
)
)*/
}

fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String> {
Expand Down
2 changes: 1 addition & 1 deletion example/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn array_as_slice(arr: &[u8; 3]) -> &[u8] {
arr
}

unsafe fn use_ctlz_nonzero(a: u16) -> u16 {
unsafe fn use_ctlz_nonzero(a: u16) -> u32 {
intrinsics::ctlz_nonzero(a)
}

Expand Down
33 changes: 31 additions & 2 deletions example/mini_core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
decl_macro, rustc_attrs, transparent_unions, auto_traits,
decl_macro, rustc_attrs, transparent_unions, auto_traits, freeze_impls,
thread_local
)]
#![no_core]
Expand Down Expand Up @@ -418,6 +418,35 @@ pub fn panic(_msg: &'static str) -> ! {
}
}

macro_rules! panic_const {
($($lang:ident = $message:expr,)+) => {
pub mod panic_const {
use super::*;

$(
#[track_caller]
#[lang = stringify!($lang)]
pub fn $lang() -> ! {
panic($message);
}
)+
}
}
}

panic_const! {
panic_const_add_overflow = "attempt to add with overflow",
panic_const_sub_overflow = "attempt to subtract with overflow",
panic_const_mul_overflow = "attempt to multiply with overflow",
panic_const_div_overflow = "attempt to divide with overflow",
panic_const_rem_overflow = "attempt to calculate the remainder with overflow",
panic_const_neg_overflow = "attempt to negate with overflow",
panic_const_shr_overflow = "attempt to shift right with overflow",
panic_const_shl_overflow = "attempt to shift left with overflow",
panic_const_div_by_zero = "attempt to divide by zero",
panic_const_rem_by_zero = "attempt to calculate the remainder with a divisor of zero",
}

#[lang = "panic_cannot_unwind"]
fn panic_cannot_unwind() -> ! {
unsafe {
Expand Down Expand Up @@ -563,7 +592,7 @@ pub mod intrinsics {
pub fn min_align_of_val<T: ?Sized>(val: *const T) -> usize;
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
pub fn transmute<T, U>(e: T) -> U;
pub fn ctlz_nonzero<T>(x: T) -> T;
pub fn ctlz_nonzero<T>(x: T) -> u32;
#[rustc_safe_intrinsic]
pub fn needs_drop<T: ?Sized>() -> bool;
#[rustc_safe_intrinsic]
Expand Down
6 changes: 2 additions & 4 deletions example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![feature(
no_core, unboxed_closures, start, lang_items, never_type, linkage,
extern_types, thread_local
extern_types, thread_local, raw_ref_op
)]
#![no_core]
#![allow(dead_code, internal_features, non_camel_case_types)]
Expand Down Expand Up @@ -99,9 +99,7 @@ fn start<T: Termination + 'static>(

static mut NUM: u8 = 6 * 7;

// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
static NUM_REF: &'static u8 = unsafe { &NUM };
static NUM_REF: &'static u8 = unsafe { &* &raw const NUM };

macro_rules! assert {
($e:expr) => {
Expand Down
4 changes: 2 additions & 2 deletions example/std_example.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(internal_features)]
#![feature(core_intrinsics, coroutines, coroutine_trait, is_sorted)]
#![feature(core_intrinsics, coroutines, coroutine_trait, is_sorted, stmt_expr_attributes)]

#[cfg(feature="master")]
#[cfg(target_arch="x86_64")]
Expand Down Expand Up @@ -103,7 +103,7 @@ fn main() {
test_simd();
}

Box::pin(move |mut _task_context| {
Box::pin(#[coroutine] move |mut _task_context| {
yield ();
}).as_mut().resume(0);

Expand Down
2 changes: 1 addition & 1 deletion libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d61ce945badf4c9d8237a13ca135e3c46ad13be3
341be3b7d7ac6976cfed8ed59da3573c040d0776
2 changes: 1 addition & 1 deletion patches/0001-Add-stdarch-Cargo.toml-for-testing.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ index 0000000..4c63700
+members = [
+ "crates/core_arch",
+ "crates/std_detect",
+ "crates/stdarch-gen",
+ "crates/stdarch-gen-arm",
+ #"examples/"
+]
+exclude = [
Expand Down
2 changes: 1 addition & 1 deletion patches/0022-core-Disable-not-compiling-tests.patch
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ index 42a26ae..5ac1042 100644
+#![cfg(test)]
#![feature(alloc_layout_extra)]
#![feature(array_chunks)]
#![feature(array_windows)]
#![feature(array_ptr_get)]
14 changes: 7 additions & 7 deletions patches/libgccjit12/0001-core-Disable-portable-simd-test.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From a5663265f797a43c502915c356fe7899c16cee92 Mon Sep 17 00:00:00 2001
From 124a11ce086952a5794d5cfbaa45175809497b81 Mon Sep 17 00:00:00 2001
From: None <none@example.com>
Date: Sat, 18 Nov 2023 10:50:36 -0500
Subject: [PATCH] [core] Disable portable-simd test
Expand All @@ -8,18 +8,18 @@ Subject: [PATCH] [core] Disable portable-simd test
1 file changed, 2 deletions(-)

diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index d0a119c..76fdece 100644
index b71786c..cf484d5 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -89,7 +89,6 @@
@@ -95,7 +95,6 @@
#![feature(never_type)]
#![feature(unwrap_infallible)]
#![feature(pointer_is_aligned)]
#![feature(pointer_is_aligned_to)]
-#![feature(portable_simd)]
#![feature(ptr_metadata)]
#![feature(lazy_cell)]
#![feature(unsized_tuple_coercion)]
@@ -155,7 +154,6 @@ mod pin;
#![feature(const_option)]
@@ -157,7 +156,6 @@ mod pin;
mod pin_macro;
mod ptr;
mod result;
Expand All @@ -28,5 +28,5 @@ index d0a119c..76fdece 100644
mod str;
mod str_lossy;
--
2.42.1
2.45.2

2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-03-10"
channel = "nightly-2024-07-02"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
2 changes: 1 addition & 1 deletion src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
let builtin_unreachable: RValue<'gcc> =
unsafe { std::mem::transmute(builtin_unreachable) };
self.call(self.type_void(), None, None, builtin_unreachable, &[], None);
self.call(self.type_void(), None, None, builtin_unreachable, &[], None, None);
}

// Write results to outputs.
Expand Down
Loading

0 comments on commit 98ed962

Please sign in to comment.