Skip to content

Rollup of 8 pull requests #145063

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

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ed50029
ci: Switch to nightly rustfmt
tgross35 Jul 21, 2025
08bca4d
ci: Add native PowerPC64LE and s390x jobs
tgross35 Jul 23, 2025
fcc7824
ci: Update to the latest ubuntu:25.04 Docker images
tgross35 Jul 24, 2025
95c4263
symcheck: Switch the `object` dependency from git to crates.io
tgross35 Jul 24, 2025
83aea65
ci: Use a mirror for musl
tgross35 Jul 24, 2025
5c4abe9
ci: Upgrade ubuntu:25.04 for the PowerPC64LE test
tgross35 Jul 24, 2025
43c3e1b
Enable tests that were skipped on PowerPC
tgross35 Jul 24, 2025
b168793
Enable tests that were skipped on aarch64
tgross35 Jul 24, 2025
0b6c1d3
Enable skipped `f32` and `f64` multiplication tests
tgross35 Jul 24, 2025
9dad77f
Use `x86_no_sse` configuration in more places
tgross35 Jul 24, 2025
4743158
libm: Update for new warn-by-default clippy lints
tgross35 Jul 26, 2025
c061e73
Avoid inlining `floor` into `rem_pio2`
quaternic Jul 27, 2025
9c683d3
Implement `floor` and `ceil` in assembly on `i586`
folkertdev Jul 27, 2025
16cb37c
Remove `no-asm` gating when there is no alternative implementation
tgross35 Jul 25, 2025
54f6ab7
Switch to using a GH app for authenticating sync PRs
Kobzol Jul 29, 2025
54a4f86
cleanup: Trim trailing whitespace
tgross35 Jul 29, 2025
97c35d3
ci: Simplify tests for verbatim paths
tgross35 Jul 29, 2025
ab8a2e1
ci: Switch to strongly typed directives
tgross35 Jul 30, 2025
eafafc4
ci: Don't print output twice in `ci-util`
tgross35 Jul 30, 2025
c045c9b
ci: Commonize the way `PrInfo` is loaded from env
tgross35 Jul 30, 2025
4ebfdf7
ci: Add a way to run `libm` tests that would otherwise be skipped
tgross35 Jul 30, 2025
3cbd088
ci: Set pipefail before running ci-util
tgross35 Jul 30, 2025
ecf6d3c
Simplify the configuration for no-panic
tgross35 Jul 30, 2025
d2cfe48
remove feature gate
Kivooeo Aug 4, 2025
b7f5392
remove begin prefix
Kivooeo Aug 4, 2025
3b50253
compiler-builtins: plumb LSE support for aarch64 on linux
pmur Aug 4, 2025
6936bb9
Dynamically enable LSE for aarch64 rust provided intrinsics
pmur Jul 31, 2025
fbc700f
configure: Use `CARGO_CFG_*_{F16,F128}` rather than invoking rustc
tgross35 Aug 5, 2025
2472d19
Include allocator module in LLVM_passes timer
bjorn3 Aug 6, 2025
ee38bc0
Remove unused field from ModuleConfig
bjorn3 Aug 6, 2025
6fbea4f
Remove bitcode_llvm_cmdline
bjorn3 Aug 6, 2025
b1f49d8
Fix build/doc/test of error index generator
Kobzol Aug 6, 2025
56d5aab
make rustc_public types derive `Hash`
AlexanderPortland Aug 6, 2025
4f7a6ac
Port `#[allow_internal_unsafe]` to the new attribute system
scrabsha Aug 3, 2025
b9e6bd7
derive hash for placeholder automatically
AlexanderPortland Aug 7, 2025
46a1ed2
Rollup merge of #144705 - pmur:murp/aarch64-lse, r=Amanieu
tgross35 Aug 7, 2025
b30ed11
Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmann
tgross35 Aug 7, 2025
e521b69
Rollup merge of #144900 - Kivooeo:unsigned_signed_diff-stabilize, r=d…
tgross35 Aug 7, 2025
a8bb6ff
Rollup merge of #144903 - Kivooeo:panic_handler-is-not-begin, r=m-ou-se
tgross35 Aug 7, 2025
5fff7c6
Rollup merge of #144974 - tgross35:update-builtins, r=tgross35
tgross35 Aug 7, 2025
44163e3
Rollup merge of #145004 - bjorn3:remove_unused_fields, r=WaffleLapkin
tgross35 Aug 7, 2025
ef4cc9b
Rollup merge of #145007 - Kobzol:error-index, r=jieyouxu
tgross35 Aug 7, 2025
da9f352
Rollup merge of #145018 - AlexanderPortland:rustc-public-hash, r=scot…
tgross35 Aug 7, 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
8 changes: 8 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ impl<S: Stage> AttributeParser<S> for MacroUseParser {
Some(AttributeKind::MacroUse { span: self.first_span?, arguments: self.state })
}
}

pub(crate) struct AllowInternalUnsafeParser;

impl<S: Stage> NoArgsAttributeParser<S> for AllowInternalUnsafeParser {
const PATH: &[Symbol] = &[sym::allow_internal_unsafe];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::AllowInternalUnsafe(span);
}
5 changes: 4 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
};
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
use crate::attributes::macro_attrs::{MacroEscapeParser, MacroUseParser};
use crate::attributes::macro_attrs::{
AllowInternalUnsafeParser, MacroEscapeParser, MacroUseParser,
};
use crate::attributes::must_use::MustUseParser;
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
use crate::attributes::non_exhaustive::NonExhaustiveParser;
Expand Down Expand Up @@ -178,6 +180,7 @@ attribute_parsers!(
Single<SkipDuringMethodDispatchParser>,
Single<TransparencyParser>,
Single<WithoutArgs<AllowIncoherentImplParser>>,
Single<WithoutArgs<AllowInternalUnsafeParser>>,
Single<WithoutArgs<AsPtrParser>>,
Single<WithoutArgs<AutomaticallyDerivedParser>>,
Single<WithoutArgs<CoherenceIsCoreParser>>,
Expand Down
57 changes: 20 additions & 37 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ pub(crate) fn codegen(
.generic_activity_with_arg("LLVM_module_codegen_embed_bitcode", &*module.name);
let thin_bc =
module.thin_lto_buffer.as_deref().expect("cannot find embedded bitcode");
embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, &thin_bc);
embed_bitcode(cgcx, llcx, llmod, &thin_bc);
}
}

Expand Down Expand Up @@ -1058,40 +1058,38 @@ fn embed_bitcode(
cgcx: &CodegenContext<LlvmCodegenBackend>,
llcx: &llvm::Context,
llmod: &llvm::Module,
cmdline: &str,
bitcode: &[u8],
) {
// We're adding custom sections to the output object file, but we definitely
// do not want these custom sections to make their way into the final linked
// executable. The purpose of these custom sections is for tooling
// surrounding object files to work with the LLVM IR, if necessary. For
// example rustc's own LTO will look for LLVM IR inside of the object file
// in these sections by default.
// executable. The purpose of this custom section is for tooling surrounding
// object files to work with the LLVM IR, if necessary. For example rustc's
// own LTO will look for LLVM IR inside of the object file in this section
// by default.
//
// To handle this is a bit different depending on the object file format
// used by the backend, broken down into a few different categories:
//
// * Mach-O - this is for macOS. Inspecting the source code for the native
// linker here shows that the `.llvmbc` and `.llvmcmd` sections are
// automatically skipped by the linker. In that case there's nothing extra
// that we need to do here.
// linker here shows that the `.llvmbc` section is automatically skipped
// by the linker. In that case there's nothing extra that we need to do
// here.
//
// * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` and
// `.llvmcmd` sections, so there's nothing extra we need to do.
// * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` section,
// so there's nothing extra we need to do.
//
// * COFF - if we don't do anything the linker will by default copy all
// these sections to the output artifact, not what we want! To subvert
// this we want to flag the sections we inserted here as
// `IMAGE_SCN_LNK_REMOVE`.
// * COFF - if we don't do anything the linker will by default copy this
// section to the output artifact, not what we want! To subvert this we
// want to flag the section we inserted here as `IMAGE_SCN_LNK_REMOVE`.
//
// * ELF - this is very similar to COFF above. One difference is that these
// sections are removed from the output linked artifact when
// `--gc-sections` is passed, which we pass by default. If that flag isn't
// passed though then these sections will show up in the final output.
// Additionally the flag that we need to set here is `SHF_EXCLUDE`.
// * ELF - this is very similar to COFF above. One difference is that this
// section is removed from the output linked artifact when `--gc-sections`
// is passed, which we pass by default. If that flag isn't passed through
// then this section will show up in the final output. Additionally the
// flag that we need to set here is `SHF_EXCLUDE`.
//
// * XCOFF - AIX linker ignores content in .ipa and .info if no auxiliary
// symbol associated with these sections.
// * XCOFF - AIX linker ignores content in .ipa if no auxiliary symbol
// associated with this section.
//
// Unfortunately, LLVM provides no way to set custom section flags. For ELF
// and COFF we emit the sections using module level inline assembly for that
Expand All @@ -1110,26 +1108,11 @@ fn embed_bitcode(
llvm::set_section(llglobal, bitcode_section_name(cgcx));
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);

let llconst = common::bytes_in_context(llcx, cmdline.as_bytes());
let llglobal = llvm::add_global(llmod, common::val_ty(llconst), c"rustc.embedded.cmdline");
llvm::set_initializer(llglobal, llconst);
let section = if cgcx.target_is_like_darwin {
c"__LLVM,__cmdline"
} else if cgcx.target_is_like_aix {
c".info"
} else {
c".llvmcmd"
};
llvm::set_section(llglobal, section);
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
} else {
// We need custom section flags, so emit module-level inline assembly.
let section_flags = if cgcx.is_pe_coff { "n" } else { "e" };
let asm = create_section_with_flags_asm(".llvmbc", section_flags, bitcode);
llvm::append_module_inline_asm(llmod, &asm);
let asm = create_section_with_flags_asm(".llvmcmd", section_flags, cmdline.as_bytes());
llvm::append_module_inline_asm(llmod, &asm);
}
}

Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ pub struct ModuleConfig {
/// Names of additional optimization passes to run.
pub passes: Vec<String>,
/// Some(level) to optimize at a certain level, or None to run
/// absolutely no optimizations (used for the metadata module).
/// absolutely no optimizations (used for the allocator module).
pub opt_level: Option<config::OptLevel>,

/// Some(level) to optimize binary size, or None to not affect program size.
pub opt_size: Option<config::OptLevel>,

pub pgo_gen: SwitchWithOptPath,
pub pgo_use: Option<PathBuf>,
pub pgo_sample_use: Option<PathBuf>,
Expand All @@ -102,15 +99,13 @@ pub struct ModuleConfig {
pub emit_obj: EmitObj,
pub emit_thin_lto: bool,
pub emit_thin_lto_summary: bool,
pub bc_cmdline: String,

// Miscellaneous flags. These are mostly copied from command-line
// options.
pub verify_llvm_ir: bool,
pub lint_llvm_ir: bool,
pub no_prepopulate_passes: bool,
pub no_builtins: bool,
pub time_module: bool,
pub vectorize_loop: bool,
pub vectorize_slp: bool,
pub merge_functions: bool,
Expand Down Expand Up @@ -171,7 +166,6 @@ impl ModuleConfig {
passes: if_regular!(sess.opts.cg.passes.clone(), vec![]),

opt_level: opt_level_and_size,
opt_size: opt_level_and_size,

pgo_gen: if_regular!(
sess.opts.cg.profile_generate.clone(),
Expand Down Expand Up @@ -221,17 +215,12 @@ impl ModuleConfig {
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
false
),
bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(),

verify_llvm_ir: sess.verify_llvm_ir(),
lint_llvm_ir: sess.opts.unstable_opts.lint_llvm_ir,
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
no_builtins: no_builtins || sess.target.no_builtins,

// Exclude metadata and allocator modules from time_passes output,
// since they throw off the "LLVM passes" measurement.
time_module: if_regular!(true, false),

// Copy what clang does by turning on loop vectorization at O2 and
// slp vectorization at O3.
vectorize_loop: !sess.opts.cg.no_vectorize_loops
Expand Down Expand Up @@ -1740,7 +1729,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
work: WorkItem<B>,
) {
if cgcx.config(work.module_kind()).time_module && llvm_start_time.is_none() {
if llvm_start_time.is_none() {
*llvm_start_time = Some(cgcx.prof.verbose_generic_activity("LLVM_passes"));
}

Expand Down
56 changes: 29 additions & 27 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,33 +681,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(

let ongoing_codegen = start_async_codegen(backend.clone(), tcx, target_cpu, autodiff_items);

// Codegen an allocator shim, if necessary.
if let Some(kind) = allocator_kind_for_codegen(tcx) {
let llmod_id =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
let module_llvm = tcx.sess.time("write_allocator_module", || {
backend.codegen_allocator(
tcx,
&llmod_id,
kind,
// If allocator_kind is Some then alloc_error_handler_kind must
// also be Some.
tcx.alloc_error_handler_kind(()).unwrap(),
)
});

ongoing_codegen.wait_for_signal_to_codegen_item();
ongoing_codegen.check_for_errors(tcx.sess);

// These modules are generally cheap and won't throw off scheduling.
let cost = 0;
submit_codegened_module_to_llvm(
&ongoing_codegen.coordinator,
ModuleCodegen::new_allocator(llmod_id, module_llvm),
cost,
);
}

// For better throughput during parallel processing by LLVM, we used to sort
// CGUs largest to smallest. This would lead to better thread utilization
// by, for example, preventing a large CGU from being processed last and
Expand Down Expand Up @@ -823,6 +796,35 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
}
}

// Codegen an allocator shim, if necessary.
// Do this last to ensure the LLVM_passes timer doesn't start while no CGUs have been codegened
// yet for the backend to optimize.
if let Some(kind) = allocator_kind_for_codegen(tcx) {
let llmod_id =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
let module_llvm = tcx.sess.time("write_allocator_module", || {
backend.codegen_allocator(
tcx,
&llmod_id,
kind,
// If allocator_kind is Some then alloc_error_handler_kind must
// also be Some.
tcx.alloc_error_handler_kind(()).unwrap(),
)
});

ongoing_codegen.wait_for_signal_to_codegen_item();
ongoing_codegen.check_for_errors(tcx.sess);

// These modules are generally cheap and won't throw off scheduling.
let cost = 0;
submit_codegened_module_to_llvm(
&ongoing_codegen.coordinator,
ModuleCodegen::new_allocator(llmod_id, module_llvm),
cost,
);
}

ongoing_codegen.codegen_finished(tcx);

// Since the main thread is sometimes blocked during codegen, we keep track
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,10 +905,7 @@ impl SyntaxExtension {
find_attr!(attrs, AttributeKind::AllowInternalUnstable(i, _) => i)
.map(|i| i.as_slice())
.unwrap_or_default();
// FIXME(jdonszelman): allow_internal_unsafe isn't yet new-style
// let allow_internal_unsafe = find_attr!(attrs, AttributeKind::AllowInternalUnsafe);
let allow_internal_unsafe =
ast::attr::find_by_name(attrs, sym::allow_internal_unsafe).is_some();
let allow_internal_unsafe = find_attr!(attrs, AttributeKind::AllowInternalUnsafe(_));

let local_inner_macros = ast::attr::find_by_name(attrs, sym::macro_export)
.and_then(|macro_export| macro_export.meta_item_list())
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_allow_incoherent_impl]`.
AllowIncoherentImpl(Span),

/// Represents `#[allow_internal_unsafe]`.
AllowInternalUnsafe(Span),

/// Represents `#[allow_internal_unstable]`.
AllowInternalUnstable(ThinVec<(Symbol, Span)>, Span),

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl AttributeKind {
Align { .. } => No,
AllowConstFnUnstable(..) => No,
AllowIncoherentImpl(..) => No,
AllowInternalUnsafe(..) => Yes,
AllowInternalUnstable(..) => Yes,
AsPtr(..) => Yes,
AutomaticallyDerived(..) => Yes,
Expand Down
13 changes: 12 additions & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
//! [`crate::late_lint_methods!`] invocation in `lib.rs`.

use std::fmt::Write;
use std::slice;

use ast::token::TokenKind;
use rustc_abi::BackendRepr;
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast::visit::{FnCtxt, FnKind};
use rustc_ast::{self as ast, *};
use rustc_ast_pretty::pprust::expr_to_string;
use rustc_attr_parsing::AttributeParser;
use rustc_errors::{Applicability, LintDiagnostic};
use rustc_feature::GateIssue;
use rustc_hir as hir;
Expand Down Expand Up @@ -249,7 +251,16 @@ impl UnsafeCode {

impl EarlyLintPass for UnsafeCode {
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
if attr.has_name(sym::allow_internal_unsafe) {
if AttributeParser::parse_limited(
cx.builder.sess(),
slice::from_ref(attr),
sym::allow_internal_unsafe,
attr.span,
DUMMY_NODE_ID,
Some(cx.builder.features()),
)
.is_some()
{
self.report_unsafe(cx, attr.span, BuiltinUnsafe::AllowInternalUnsafe);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ passes_allow_incoherent_impl =
`rustc_allow_incoherent_impl` attribute should be applied to impl items
.label = the only currently supported targets are inherent methods
passes_allow_internal_unstable =
passes_macro_only_attribute =
attribute should be applied to a macro
.label = not a macro
Expand Down
Loading
Loading