Skip to content

Commit 46ecc10

Browse files
committed
Auto merge of #118082 - compiler-errors:rollup-ejsc8yd, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #117828 (Avoid iterating over hashmaps in astconv) - #117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - #117891 (Recover `dyn` and `impl` after `for<...>`) - #117957 (if available use a Child's pidfd for kill/wait) - #117988 (Handle attempts to have multiple `cfg`d tail expressions) - #117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - #118000 (Make regionck care about placeholders in outlives components) - #118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 79e961f + 791ed33 commit 46ecc10

File tree

54 files changed

+795
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+795
-147
lines changed

compiler/rustc_codegen_gcc/.github/workflows/ci.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ jobs:
9999
- name: Build
100100
run: |
101101
./y.sh prepare --only-libcore
102-
./y.sh build
103-
cargo test
102+
# TODO: remove --features master when it is back to the default.
103+
./y.sh build --features master
104+
# TODO: remove --features master when it is back to the default.
105+
cargo test --features master
104106
./clean_all.sh
105107
106108
- name: Prepare dependencies
@@ -121,7 +123,8 @@ jobs:
121123

122124
- name: Run tests
123125
run: |
124-
./test.sh --release --clean --build-sysroot ${{ matrix.commands }}
126+
# TODO: remove --features master when it is back to the default.
127+
./test.sh --features master --release --clean --build-sysroot ${{ matrix.commands }}
125128
126129
duplicates:
127130
runs-on: ubuntu-latest

compiler/rustc_codegen_gcc/.github/workflows/failures.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ jobs:
2121
libgccjit_version:
2222
- gcc: "libgccjit.so"
2323
artifacts_branch: "master"
24+
# TODO: switch back to --no-default-features in the case of libgccjit 12 when the default is to enable
25+
# master again.
26+
extra: "--features master"
2427
- gcc: "libgccjit_without_int128.so"
2528
artifacts_branch: "master-without-128bit-integers"
29+
extra: "--features master"
2630
- gcc: "libgccjit12.so"
2731
artifacts_branch: "gcc12"
28-
extra: "--no-default-features"
2932
# FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin.
3033
# Not sure why it's not found otherwise.
3134
env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/"

compiler/rustc_codegen_gcc/.github/workflows/m68k.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ jobs:
114114
- name: Build
115115
run: |
116116
./y.sh prepare --only-libcore --cross
117-
./y.sh build --target-triple m68k-unknown-linux-gnu
118-
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
117+
# TODO: remove --features master when it is back to the default.
118+
./y.sh build --target-triple m68k-unknown-linux-gnu --features master
119+
# TODO: remove --features master when it is back to the default.
120+
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test --features master
119121
./clean_all.sh
120122
121123
- name: Prepare dependencies
@@ -136,4 +138,5 @@ jobs:
136138

137139
- name: Run tests
138140
run: |
139-
./test.sh --release --clean --build-sysroot ${{ matrix.commands }}
141+
# TODO: remove --features master when it is back to the default.
142+
./test.sh --release --features master --clean --build-sysroot ${{ matrix.commands }}

compiler/rustc_codegen_gcc/.github/workflows/release.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ jobs:
7878
- name: Build
7979
run: |
8080
./y.sh prepare --only-libcore
81-
EMBED_LTO_BITCODE=1 ./y.sh build --release --release-sysroot
82-
cargo test
81+
# TODO: remove --features master when it is back to the default.
82+
EMBED_LTO_BITCODE=1 ./y.sh build --release --release-sysroot --features master
83+
# TODO: remove --features master when it is back to the default.
84+
cargo test --features master
8385
./clean_all.sh
8486
8587
- name: Prepare dependencies
@@ -102,4 +104,5 @@ jobs:
102104

103105
- name: Run tests
104106
run: |
105-
EMBED_LTO_BITCODE=1 ./test.sh --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}
107+
# TODO: remove --features master when it is back to the default.
108+
EMBED_LTO_BITCODE=1 ./test.sh --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }} --features master

compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ jobs:
9292
- name: Build
9393
run: |
9494
./y.sh prepare --only-libcore
95-
./y.sh build --release --release-sysroot
96-
cargo test
95+
# TODO: remove `--features master` when it is back to the default.
96+
./y.sh build --release --release-sysroot --features master
97+
# TODO: remove --features master when it is back to the default.
98+
cargo test --features master
9799
98100
- name: Clean
99101
if: ${{ !matrix.cargo_runner }}
@@ -111,12 +113,14 @@ jobs:
111113
uses: actions-rs/[email protected]
112114
with:
113115
command: build
114-
args: --release
116+
# TODO: remove `--features master` when it is back to the default.
117+
args: --release --features master
115118

116119
- name: Run tests
117120
if: ${{ !matrix.cargo_runner }}
118121
run: |
119-
./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore
122+
# TODO: remove `--features master` when it is back to the default.
123+
./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore --features master
120124
121125
- name: Run stdarch tests
122126
if: ${{ !matrix.cargo_runner }}

compiler/rustc_codegen_gcc/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ dependencies = [
7474
[[package]]
7575
name = "gccjit"
7676
version = "1.0.0"
77-
source = "git+https://github.com/antoyo/gccjit.rs#c52a218f5529321285b4489e5562a00e5428e033"
77+
source = "git+https://github.com/antoyo/gccjit.rs#6e290f25b1d1edab5ae9ace486fd2dc8c08d6421"
7878
dependencies = [
7979
"gccjit_sys",
8080
]
8181

8282
[[package]]
8383
name = "gccjit_sys"
8484
version = "0.0.1"
85-
source = "git+https://github.com/antoyo/gccjit.rs#c52a218f5529321285b4489e5562a00e5428e033"
85+
source = "git+https://github.com/antoyo/gccjit.rs#6e290f25b1d1edab5ae9ace486fd2dc8c08d6421"
8686
dependencies = [
8787
"libc",
8888
]

compiler/rustc_codegen_gcc/build_sysroot/build_sysroot.sh

+4
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ fi
2828
# Copy files to sysroot
2929
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
3030
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
31+
# Copy the source files to the sysroot (Rust for Linux needs this).
32+
source_dir=sysroot/lib/rustlib/src/rust
33+
mkdir -p $source_dir
34+
cp -r sysroot_src/library/ $source_dir

compiler/rustc_codegen_gcc/build_system/src/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ fn build_sysroot(
194194
copier,
195195
)?;
196196

197+
// Copy the source files to the sysroot (Rust for Linux needs this).
198+
let sysroot_src_path = "sysroot/lib/rustlib/src/rust";
199+
fs::create_dir_all(&sysroot_src_path)
200+
.map_err(|error| format!("Failed to create directory `{}`: {:?}", sysroot_src_path, error))?;
201+
run_command(&[&"cp", &"-r", &"sysroot_src/library/", &sysroot_src_path], None)?;
202+
197203
Ok(())
198204
}
199205

compiler/rustc_codegen_gcc/failing-ui-tests12.txt

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ tests/ui/target-feature/missing-plusminus.rs
3838
tests/ui/sse2.rs
3939
tests/ui/codegen/issue-79865-llvm-miscompile.rs
4040
tests/ui/intrinsics/intrinsics-integer.rs
41+
tests/ui/std-backtrace.rs
42+
tests/ui/mir/alignment/packed.rs
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
From 7bcd24ec6d4a96121874cb1ae5a23ea274aeff34 Mon Sep 17 00:00:00 2001
1+
From a5663265f797a43c502915c356fe7899c16cee92 Mon Sep 17 00:00:00 2001
22
From: None <[email protected]>
3-
Date: Thu, 19 Oct 2023 13:12:51 -0400
3+
Date: Sat, 18 Nov 2023 10:50:36 -0500
44
Subject: [PATCH] [core] Disable portable-simd test
55

66
---
77
library/core/tests/lib.rs | 2 --
88
1 file changed, 2 deletions(-)
99

1010
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
11-
index 5814ed4..194ad4c 100644
11+
index d0a119c..76fdece 100644
1212
--- a/library/core/tests/lib.rs
1313
+++ b/library/core/tests/lib.rs
14-
@@ -90,7 +90,6 @@
14+
@@ -89,7 +89,6 @@
15+
#![feature(never_type)]
1516
#![feature(unwrap_infallible)]
16-
#![feature(pointer_byte_offsets)]
1717
#![feature(pointer_is_aligned)]
1818
-#![feature(portable_simd)]
1919
#![feature(ptr_metadata)]
2020
#![feature(lazy_cell)]
2121
#![feature(unsized_tuple_coercion)]
22-
@@ -157,7 +156,6 @@ mod pin;
22+
@@ -155,7 +154,6 @@ mod pin;
2323
mod pin_macro;
2424
mod ptr;
2525
mod result;
@@ -28,5 +28,5 @@ index 5814ed4..194ad4c 100644
2828
mod str;
2929
mod str_lossy;
3030
--
31-
2.42.0
31+
2.42.1
3232

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-10-21"
2+
channel = "nightly-2023-11-17"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

compiler/rustc_codegen_gcc/src/base.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::env;
33
use std::time::Instant;
44

55
use gccjit::{
6-
Context,
76
FunctionType,
87
GlobalKind,
98
};
@@ -18,8 +17,9 @@ use rustc_codegen_ssa::mono_item::MonoItemExt;
1817
use rustc_codegen_ssa::traits::DebugInfoMethods;
1918
use rustc_session::config::DebugInfo;
2019
use rustc_span::Symbol;
20+
use rustc_target::spec::PanicStrategy;
2121

22-
use crate::{LockedTargetInfo, gcc_util};
22+
use crate::{LockedTargetInfo, gcc_util, new_context};
2323
use crate::GccContext;
2424
use crate::builder::Builder;
2525
use crate::context::CodegenCx;
@@ -88,20 +88,18 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
8888
fn module_codegen(tcx: TyCtxt<'_>, (cgu_name, target_info): (Symbol, LockedTargetInfo)) -> ModuleCodegen<GccContext> {
8989
let cgu = tcx.codegen_unit(cgu_name);
9090
// Instantiate monomorphizations without filling out definitions yet...
91-
let context = Context::default();
91+
let context = new_context(tcx);
9292

93-
context.add_command_line_option("-fexceptions");
94-
context.add_driver_option("-fexceptions");
93+
if tcx.sess.panic_strategy() == PanicStrategy::Unwind {
94+
context.add_command_line_option("-fexceptions");
95+
context.add_driver_option("-fexceptions");
96+
}
9597

9698
let disabled_features: HashSet<_> = tcx.sess.opts.cg.target_feature.split(',')
9799
.filter(|feature| feature.starts_with('-'))
98100
.map(|string| &string[1..])
99101
.collect();
100102

101-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
102-
context.add_command_line_option("-masm=intel");
103-
}
104-
105103
if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" {
106104
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
107105
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.

compiler/rustc_codegen_gcc/src/int.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
7676
a >> b
7777
}
7878
}
79+
else if a_type.is_vector() && a_type.is_vector() {
80+
a >> b
81+
}
7982
else if a_native && !b_native {
8083
self.gcc_lshr(a, self.gcc_int_cast(b, a_type))
8184
}
@@ -144,7 +147,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
144147
fn additive_operation(&self, operation: BinaryOp, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
145148
let a_type = a.get_type();
146149
let b_type = b.get_type();
147-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
150+
if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) || (a_type.is_vector() && b_type.is_vector()) {
148151
if a_type != b_type {
149152
if a_type.is_vector() {
150153
// Vector types need to be bitcast.
@@ -158,6 +161,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
158161
self.context.new_binary_op(None, operation, a_type, a, b)
159162
}
160163
else {
164+
debug_assert!(a_type.dyncast_array().is_some());
165+
debug_assert!(b_type.dyncast_array().is_some());
161166
let signed = a_type.is_compatible_with(self.i128_type);
162167
let func_name =
163168
match (operation, signed) {
@@ -189,10 +194,12 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
189194
fn multiplicative_operation(&self, operation: BinaryOp, operation_name: &str, signed: bool, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
190195
let a_type = a.get_type();
191196
let b_type = b.get_type();
192-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
197+
if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) || (a_type.is_vector() && b_type.is_vector()) {
193198
self.context.new_binary_op(None, operation, a_type, a, b)
194199
}
195200
else {
201+
debug_assert!(a_type.dyncast_array().is_some());
202+
debug_assert!(b_type.dyncast_array().is_some());
196203
let sign =
197204
if signed {
198205
""
@@ -337,6 +344,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
337344
pub fn operation_with_overflow(&self, func_name: &str, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
338345
let a_type = lhs.get_type();
339346
let b_type = rhs.get_type();
347+
debug_assert!(a_type.dyncast_array().is_some());
348+
debug_assert!(b_type.dyncast_array().is_some());
340349
let param_a = self.context.new_parameter(None, a_type, "a");
341350
let param_b = self.context.new_parameter(None, b_type, "b");
342351
let result_field = self.context.new_field(None, a_type, "result");
@@ -496,7 +505,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
496505
pub fn gcc_xor(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
497506
let a_type = a.get_type();
498507
let b_type = b.get_type();
499-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
508+
if a_type.is_vector() && b_type.is_vector() {
509+
let b = self.bitcast_if_needed(b, a_type);
510+
a ^ b
511+
}
512+
else if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
500513
a ^ b
501514
}
502515
else {
@@ -527,6 +540,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
527540
a << b
528541
}
529542
}
543+
else if a_type.is_vector() && a_type.is_vector() {
544+
a << b
545+
}
530546
else if a_native && !b_native {
531547
self.gcc_shl(a, self.gcc_int_cast(b, a_type))
532548
}
@@ -690,6 +706,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
690706
let a_native = self.is_native_int_type_or_bool(a_type);
691707
let b_native = self.is_native_int_type_or_bool(b_type);
692708
if a_type.is_vector() && b_type.is_vector() {
709+
let b = self.bitcast_if_needed(b, a_type);
693710
self.context.new_binary_op(None, operation, a_type, a, b)
694711
}
695712
else if a_native && b_native {
@@ -748,6 +765,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
748765
return self.context.new_cast(None, value, dest_typ);
749766
}
750767

768+
debug_assert!(value_type.dyncast_array().is_some());
751769
let name_suffix =
752770
match self.type_kind(dest_typ) {
753771
TypeKind::Float => "tisf",
@@ -781,6 +799,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
781799
return self.context.new_cast(None, value, dest_typ);
782800
}
783801

802+
debug_assert!(value_type.dyncast_array().is_some());
784803
let name_suffix =
785804
match self.type_kind(value_type) {
786805
TypeKind::Float => "sfti",

compiler/rustc_codegen_gcc/src/lib.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ extern crate rustc_errors;
3939
extern crate rustc_fluent_macro;
4040
extern crate rustc_fs_util;
4141
extern crate rustc_hir;
42+
#[cfg(feature="master")]
43+
extern crate rustc_interface;
4244
extern crate rustc_macros;
4345
extern crate rustc_metadata;
4446
extern crate rustc_middle;
@@ -86,7 +88,7 @@ use std::sync::atomic::Ordering;
8688

8789
use gccjit::{Context, OptimizationLevel};
8890
#[cfg(feature="master")]
89-
use gccjit::TargetInfo;
91+
use gccjit::{TargetInfo, Version};
9092
#[cfg(not(feature="master"))]
9193
use gccjit::CType;
9294
use errors::LTONotSupported;
@@ -244,17 +246,33 @@ impl CodegenBackend for GccCodegenBackend {
244246
}
245247
}
246248

249+
fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> {
250+
let context = Context::default();
251+
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
252+
context.add_command_line_option("-masm=intel");
253+
}
254+
#[cfg(feature="master")]
255+
{
256+
let version = Version::get();
257+
let version = format!("{}.{}.{}", version.major, version.minor, version.patch);
258+
context.set_output_ident(&format!("rustc version {} with libgccjit {}",
259+
rustc_interface::util::rustc_version_str().unwrap_or("unknown version"),
260+
version,
261+
));
262+
}
263+
// TODO(antoyo): check if this should only be added when using -Cforce-unwind-tables=n.
264+
context.add_command_line_option("-fno-asynchronous-unwind-tables");
265+
context
266+
}
267+
247268
impl ExtraBackendMethods for GccCodegenBackend {
248269
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind) -> Self::Module {
249270
let mut mods = GccContext {
250-
context: Context::default(),
271+
context: new_context(tcx),
251272
should_combine_object_files: false,
252273
temp_dir: None,
253274
};
254275

255-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
256-
mods.context.add_command_line_option("-masm=intel");
257-
}
258276
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); }
259277
mods
260278
}

0 commit comments

Comments
 (0)