Skip to content

Sync from rust 2025/01/12 #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91425f2
codegen `#[naked]` functions using `global_asm!`
folkertdev Aug 8, 2024
a1374f5
generalize 'forbidden feature' concept so that even (un)stable featur…
RalfJung Nov 16, 2024
d31c5e9
apply review feedback
RalfJung Dec 2, 2024
ca71dc1
Auto merge of #128004 - folkertdev:naked-fn-asm, r=Amanieu
bors Dec 11, 2024
90a7089
Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=work…
bors Dec 13, 2024
1ff0558
target_features: control separately whether enabling and disabling a …
RalfJung Nov 24, 2024
a845ca7
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_st…
jdonszelmann Dec 13, 2024
4d1e772
Variants::Single: do not use invalid VariantIdx for uninhabited enums
RalfJung Dec 1, 2024
bd26db4
make no-variant types a dedicated Variants variant
RalfJung Dec 1, 2024
c3eed20
chore: fix some typos
acceptacross Dec 18, 2024
b39498c
Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk
jieyouxu Dec 19, 2024
e6e72ce
adjust GCC backend
RalfJung Dec 26, 2024
f06f568
x86-64 hardfloat actually requires sse2
RalfJung Dec 26, 2024
940cbb8
add ABI target features *before* -Ctarget-features
RalfJung Dec 27, 2024
d7685c4
upstream rustc_codegen_llvm changes for enzyme/autodiff
ZuseZ4 Jan 1, 2025
3aba2d9
add dedicated type for ABI target feature constraints
RalfJung Jan 5, 2025
7991f17
Auto merge of #134794 - RalfJung:abi-required-target-features, r=work…
bors Jan 5, 2025
3323e5a
llvm: Ignore error value that is always false
maurer Jan 7, 2025
90ae2cf
mir_transform: implement forced inlining
davidtwco Sep 23, 2024
c6f258d
migrate `rustc_codegen_gcc` to the `DenseBitSet` name
lqd Jan 7, 2025
b44f371
Merge branch 'master' into sync_from_rust_2025_01_12
antoyo Jan 13, 2025
59689c4
Update to nightly-2025-01-12
antoyo Jan 13, 2025
b4418b8
Fix clippy warnings
antoyo Jan 13, 2025
06fdf3d
Use mini_core in the tests
antoyo Jan 13, 2025
500fce1
Add error pattern
antoyo Jan 13, 2025
10d745c
Do not run UI tests in the error-emitter directory
antoyo Jan 13, 2025
17f5a4f
Add support for fmaf16
antoyo Jan 13, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- { gcc: "gcc-13.deb" }
- { gcc: "gcc-13-without-int128.deb" }
commands: [
"--mini-tests",
"--std-tests",
# FIXME: re-enable asm tests when GCC can emit in the right syntax.
# "--asm-tests",
Expand Down Expand Up @@ -79,6 +78,7 @@ jobs:
run: |
./y.sh prepare --only-libcore
./y.sh build --sysroot
./y.sh test --mini-tests
cargo test

- name: Run y.sh cargo build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
fail-fast: false
matrix:
commands: [
"--mini-tests",
"--std-tests",
# TODO(antoyo): fix those on m68k.
#"--test-libcore",
Expand Down Expand Up @@ -93,6 +92,7 @@ jobs:
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 test --mini-tests
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
./y.sh clean all

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
run: |
./y.sh prepare --only-libcore
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
./y.sh test --mini-tests
cargo test
./y.sh clean all

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/stdarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ jobs:
echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV

- name: Build (part 2)
run: |
cargo test

- name: Clean
if: ${{ !matrix.cargo_runner }}
run: |
Expand All @@ -92,6 +88,7 @@ jobs:
if: ${{ !matrix.cargo_runner }}
run: |
./y.sh test --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore
cargo test

- name: Run stdarch tests
if: ${{ !matrix.cargo_runner }}
Expand Down
21 changes: 17 additions & 4 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,17 @@ fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<
if line.is_empty() {
continue;
}
if ["//@ error-pattern:", "//@ build-fail", "//@ run-fail", "-Cllvm-args", "//~", "thread"]
.iter()
.any(|check| line.contains(check))
if [
"//@ error-pattern:",
"//@ build-fail",
"//@ run-fail",
"//@ known-bug",
"-Cllvm-args",
"//~",
"thread",
]
.iter()
.any(|check| line.contains(check))
{
return Ok(true);
}
Expand All @@ -868,9 +876,14 @@ fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<
return Ok(true);
}
}
if file_path.display().to_string().contains("ambiguous-4-extern.rs") {
let file_path = file_path.display().to_string();
if file_path.contains("ambiguous-4-extern.rs") {
eprintln!("nothing found for {file_path:?}");
}
// The files in this directory contain errors.
if file_path.contains("/error-emitter/") {
return Ok(true);
}
Ok(false)
}

Expand Down
8 changes: 8 additions & 0 deletions example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ impl Add for usize {
}
}

impl Add for isize {
type Output = Self;

fn add(self, rhs: Self) -> Self {
self + rhs
}
}

#[lang = "sub"]
pub trait Sub<RHS = Self> {
type Output;
Expand Down
2 changes: 1 addition & 1 deletion messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ codegen_gcc_lto_not_supported =
LTO is not supported. You may get a linker error.

codegen_gcc_forbidden_ctarget_feature =
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}

codegen_gcc_unwinding_inline_asm =
GCC backend does not support unwinding from inline asm
Expand Down
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-12-11"
channel = "nightly-2025-01-12"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
7 changes: 7 additions & 0 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,13 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
template_str.push_str("\n.popsection");
self.context.add_top_level_asm(None, &template_str);
}

fn mangled_name(&self, instance: Instance<'tcx>) -> String {
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
// or byte count suffixes (x86 Windows).
self.tcx.symbol_name(instance).name.to_string()
}
}

fn modifier_to_gcc(
Expand Down
6 changes: 3 additions & 3 deletions src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use gccjit::FnAttribute;
use gccjit::Function;
#[cfg(feature = "master")]
use rustc_attr::InlineAttr;
use rustc_attr::InstructionSetAttr;
use rustc_attr_parsing::InlineAttr;
use rustc_attr_parsing::InstructionSetAttr;
#[cfg(feature = "master")]
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty;
Expand All @@ -20,7 +20,7 @@ fn inline_attr<'gcc, 'tcx>(
) -> Option<FnAttribute<'gcc>> {
match inline {
InlineAttr::Hint => Some(FnAttribute::Inline),
InlineAttr::Always => Some(FnAttribute::AlwaysInline),
InlineAttr::Always | InlineAttr::Force { .. } => Some(FnAttribute::AlwaysInline),
InlineAttr::Never => {
if cx.sess().target.arch != "amdgpu" {
Some(FnAttribute::NoInline)
Expand Down
4 changes: 1 addition & 3 deletions src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,7 @@ pub unsafe fn optimize_thin_module(
{
let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) {
return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule));
}
unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
}

Expand Down
2 changes: 1 addition & 1 deletion src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>)
// This is a monomorphization of a generic function.
if !(cx.tcx.sess.opts.share_generics()
|| tcx.codegen_fn_attrs(instance_def_id).inline
== rustc_attr::InlineAttr::Never)
== rustc_attr_parsing::InlineAttr::Never)
{
// When not sharing generics, all instances are in the same
// crate and have hidden visibility.
Expand Down
10 changes: 5 additions & 5 deletions src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use gccjit::{Location, RValue};
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoCodegenMethods};
use rustc_data_structures::sync::Lrc;
use rustc_index::bit_set::BitSet;
use rustc_index::bit_set::DenseBitSet;
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::{self, Body, SourceScope};
use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty};
Expand Down Expand Up @@ -69,7 +69,7 @@ fn compute_mir_scopes<'gcc, 'tcx>(
) {
// Find all scopes with variables defined in them.
let variables = if cx.sess().opts.debuginfo == DebugInfo::Full {
let mut vars = BitSet::new_empty(mir.source_scopes.len());
let mut vars = DenseBitSet::new_empty(mir.source_scopes.len());
// FIXME(eddyb) take into account that arguments always have debuginfo,
// irrespective of their name (assuming full debuginfo is enabled).
// NOTE(eddyb) actually, on second thought, those are always in the
Expand All @@ -82,7 +82,7 @@ fn compute_mir_scopes<'gcc, 'tcx>(
// Nothing to emit, of course.
None
};
let mut instantiated = BitSet::new_empty(mir.source_scopes.len());
let mut instantiated = DenseBitSet::new_empty(mir.source_scopes.len());
// Instantiate all scopes.
for idx in 0..mir.source_scopes.len() {
let scope = SourceScope::new(idx);
Expand All @@ -101,9 +101,9 @@ fn make_mir_scope<'gcc, 'tcx>(
cx: &CodegenCx<'gcc, 'tcx>,
_instance: Instance<'tcx>,
mir: &Body<'tcx>,
variables: &Option<BitSet<SourceScope>>,
variables: &Option<DenseBitSet<SourceScope>>,
debug_context: &mut FunctionDebugContext<'tcx, (), Location<'gcc>>,
instantiated: &mut BitSet<SourceScope>,
instantiated: &mut DenseBitSet<SourceScope>,
scope: SourceScope,
) {
if instantiated.contains(scope) {
Expand Down
2 changes: 2 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub(crate) struct UnstableCTargetFeature<'a> {
#[diag(codegen_gcc_forbidden_ctarget_feature)]
pub(crate) struct ForbiddenCTargetFeature<'a> {
pub feature: &'a str,
pub enabled: &'a str,
pub reason: &'a str,
}

#[derive(Subdiagnostic)]
Expand Down
Loading
Loading