Skip to content

Commit

Permalink
Auto merge of #138202 - jhpratt:rollup-kqrl5xn, r=jhpratt
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

Successful merges:

 - #137337 (Add verbatim linker to AIXLinker)
 - #137363 (compiler: factor Windows x86-32 ABI impl into its own file)
 - #137537 (Prevent `rmake.rs` from using unstable features, and fix 3 run-make tests that currently do)
 - #137606 (add a "future" edition)
 - #137957 (Remove i586-pc-windows-msvc)
 - #138000 (atomic: clarify that failing conditional RMW operations are not 'writes')
 - #138013 (Add post-merge analysis CI workflow)
 - #138033 (rustdoc: Add attribute-related tests for rustdoc JSON.)
 - #138137 (setTargetTriple now accepts Triple rather than string)
 - #138173 (Delay bug for negative auto trait rather than ICEing)
 - #138184 (Allow anyone to relabel `CI-spurious-*`)
 - #138187 (remove clones)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 8, 2025
2 parents f5a1ef7 + dad4c8b commit 20f0108
Show file tree
Hide file tree
Showing 43 changed files with 644 additions and 99 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Workflow that runs after a merge to master, analyses changes in test executions
# and posts the result to the merged PR.

name: Post merge analysis

on:
push:
branches:
- master

jobs:
analysis:
runs-on: ubuntu-24.04
if: github.repository == 'rust-lang/rust'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Perform analysis and send PR
run: |
# Get closest bors merge commit
PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1`
# Find PR for the current commit
HEAD_PR=`gh pr list --search "${{ github.sha }}" --state merged --json number --jq '.[0].number'`
echo "Parent: ${PARENT_COMMIT}"
echo "HEAD: ${{ github.sha }} (#${HEAD_PR})"
cd src/ci/citool
echo "Post-merge analysis result" > output.log
cargo run --release post-merge-analysis ${PARENT_COMMIT} ${{ github.sha }} >> output.log
cat output.log
gh pr comment ${HEAD_PR} -F output.log
11 changes: 11 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2526,6 +2526,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"

[[package]]
name = "os_pipe"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
dependencies = [
"libc",
"windows-sys 0.59.0",
]

[[package]]
name = "overload"
version = "0.1.1"
Expand Down Expand Up @@ -3050,6 +3060,7 @@ dependencies = [
"gimli 0.31.1",
"libc",
"object 0.36.7",
"os_pipe",
"regex",
"serde_json",
"similar",
Expand Down
29 changes: 10 additions & 19 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod llvm_enzyme {
let orig_annotatable: Annotatable = match item {
Annotatable::Item(ref mut iitem) => {
if !iitem.attrs.iter().any(|a| a.id == attr.id) {
iitem.attrs.push(attr.clone());
iitem.attrs.push(attr);
}
if !iitem.attrs.iter().any(|a| a.id == inline_never.id) {
iitem.attrs.push(inline_never.clone());
Expand All @@ -295,7 +295,7 @@ mod llvm_enzyme {
}
Annotatable::AssocItem(ref mut assoc_item, i @ Impl) => {
if !assoc_item.attrs.iter().any(|a| a.id == attr.id) {
assoc_item.attrs.push(attr.clone());
assoc_item.attrs.push(attr);
}
if !assoc_item.attrs.iter().any(|a| a.id == inline_never.id) {
assoc_item.attrs.push(inline_never.clone());
Expand All @@ -322,7 +322,7 @@ mod llvm_enzyme {
let d_annotatable = if is_impl {
let assoc_item: AssocItemKind = ast::AssocItemKind::Fn(asdf);
let d_fn = P(ast::AssocItem {
attrs: thin_vec![d_attr.clone(), inline_never],
attrs: thin_vec![d_attr, inline_never],
id: ast::DUMMY_NODE_ID,
span,
vis,
Expand All @@ -332,12 +332,8 @@ mod llvm_enzyme {
});
Annotatable::AssocItem(d_fn, Impl)
} else {
let mut d_fn = ecx.item(
span,
d_ident,
thin_vec![d_attr.clone(), inline_never],
ItemKind::Fn(asdf),
);
let mut d_fn =
ecx.item(span, d_ident, thin_vec![d_attr, inline_never], ItemKind::Fn(asdf));
d_fn.vis = vis;
Annotatable::Item(d_fn)
};
Expand Down Expand Up @@ -446,7 +442,7 @@ mod llvm_enzyme {

if primal_ret && n_active == 0 && x.mode.is_rev() {
// We only have the primal ret.
body.stmts.push(ecx.stmt_expr(black_box_primal_call.clone()));
body.stmts.push(ecx.stmt_expr(black_box_primal_call));
return body;
}

Expand All @@ -471,7 +467,7 @@ mod llvm_enzyme {
if primal_ret {
// We have both primal ret and active floats.
// primal ret is first, by construction.
exprs.push(primal_call.clone());
exprs.push(primal_call);
}

// Now construct default placeholder for each active float.
Expand Down Expand Up @@ -538,16 +534,11 @@ mod llvm_enzyme {
return body;
}
[arg] => {
ret = ecx.expr_call(
new_decl_span,
blackbox_call_expr.clone(),
thin_vec![arg.clone()],
);
ret = ecx.expr_call(new_decl_span, blackbox_call_expr, thin_vec![arg.clone()]);
}
args => {
let ret_tuple: P<ast::Expr> = ecx.expr_tuple(span, args.into());
ret =
ecx.expr_call(new_decl_span, blackbox_call_expr.clone(), thin_vec![ret_tuple]);
ret = ecx.expr_call(new_decl_span, blackbox_call_expr, thin_vec![ret_tuple]);
}
}
assert!(has_ret(&d_sig.decl.output));
Expand All @@ -567,7 +558,7 @@ mod llvm_enzyme {
let args: ThinVec<_> =
idents[1..].iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();
let self_expr = ecx.expr_self(span);
ecx.expr_method_call(span, self_expr, primal, args.clone())
ecx.expr_method_call(span, self_expr, primal, args)
} else {
let args: ThinVec<_> =
idents.iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub fn inject(
Edition2018 => sym::rust_2018,
Edition2021 => sym::rust_2021,
Edition2024 => sym::rust_2024,
EditionFuture => sym::rust_future,
}])
.map(|&symbol| Ident::new(symbol, span))
.collect();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1655,9 +1655,9 @@ impl<'a> Linker for AixLinker<'a> {
}
}

fn link_dylib_by_name(&mut self, name: &str, _verbatim: bool, _as_needed: bool) {
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, _as_needed: bool) {
self.hint_dynamic();
self.link_or_cc_arg(format!("-l{name}"));
self.link_or_cc_arg(if verbatim { String::from(name) } else { format!("-l{name}") });
}

fn link_dylib_by_path(&mut self, path: &Path, _as_needed: bool) {
Expand All @@ -1668,7 +1668,7 @@ impl<'a> Linker for AixLinker<'a> {
fn link_staticlib_by_name(&mut self, name: &str, verbatim: bool, whole_archive: bool) {
self.hint_static();
if !whole_archive {
self.link_or_cc_arg(format!("-l{name}"));
self.link_or_cc_arg(if verbatim { String::from(name) } else { format!("-l{name}") });
} else {
let mut arg = OsString::from("-bkeepfile:");
arg.push(find_native_static_library(name, verbatim, self.sess));
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_hir_analysis/src/check/always_applicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ pub(crate) fn check_negative_auto_trait_impl<'tcx>(
// be implemented here to handle non-ADT rigid types.
Ok(())
} else {
span_bug!(tcx.def_span(impl_def_id), "incoherent impl of negative auto trait");
Err(tcx.dcx().span_delayed_bug(
tcx.def_span(impl_def_id),
"incoherent impl of negative auto trait",
))
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) {
}

extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M,
const char *Triple) {
unwrap(M)->setTargetTriple(Triple::normalize(Triple));
const char *Target) {
#if LLVM_VERSION_GE(21, 0)
unwrap(M)->setTargetTriple(Triple(Triple::normalize(Target)));
#else
unwrap(M)->setTargetTriple(Triple::normalize(Target));
#endif
}

extern "C" void LLVMRustPrintPassTimings(RustStringRef OutBuf) {
Expand Down
29 changes: 27 additions & 2 deletions compiler/rustc_span/src/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,27 @@ pub enum Edition {
Edition2021,
/// The 2024 edition
Edition2024,
/// The future edition - this variant will always exist and features associated with this
/// edition can be moved to the next 20XX edition when it is established and it is confirmed
/// that those features will be part of that edition.
///
/// This variant allows edition changes to be implemented before being assigned to a concrete
/// edition - primarily when there are two different unstable behaviours that need tested across
/// an edition boundary.
///
/// This edition will be permanently unstable and any features associated with this edition
/// must also be behind a feature gate.
EditionFuture,
}

// Must be in order from oldest to newest.
pub const ALL_EDITIONS: &[Edition] =
&[Edition::Edition2015, Edition::Edition2018, Edition::Edition2021, Edition::Edition2024];
pub const ALL_EDITIONS: &[Edition] = &[
Edition::Edition2015,
Edition::Edition2018,
Edition::Edition2021,
Edition::Edition2024,
Edition::EditionFuture,
];

pub const EDITION_NAME_LIST: &str = "2015|2018|2021|2024";

Expand All @@ -42,6 +58,7 @@ impl fmt::Display for Edition {
Edition::Edition2018 => "2018",
Edition::Edition2021 => "2021",
Edition::Edition2024 => "2024",
Edition::EditionFuture => "future",
};
write!(f, "{s}")
}
Expand All @@ -54,6 +71,7 @@ impl Edition {
Edition::Edition2018 => "rust_2018_compatibility",
Edition::Edition2021 => "rust_2021_compatibility",
Edition::Edition2024 => "rust_2024_compatibility",
Edition::EditionFuture => "edition_future_compatibility",
}
}

Expand All @@ -63,6 +81,7 @@ impl Edition {
Edition::Edition2018 => true,
Edition::Edition2021 => true,
Edition::Edition2024 => true,
Edition::EditionFuture => false,
}
}

Expand All @@ -85,6 +104,11 @@ impl Edition {
pub fn at_least_rust_2024(self) -> bool {
self >= Edition::Edition2024
}

/// Are we allowed to use features from the future edition?
pub fn at_least_edition_future(self) -> bool {
self >= Edition::EditionFuture
}
}

impl FromStr for Edition {
Expand All @@ -95,6 +119,7 @@ impl FromStr for Edition {
"2018" => Ok(Edition::Edition2018),
"2021" => Ok(Edition::Edition2021),
"2024" => Ok(Edition::Edition2024),
"future" => Ok(Edition::EditionFuture),
_ => Err(()),
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ symbols! {
rust_cold_cc,
rust_eh_catch_typeinfo,
rust_eh_personality,
rust_future,
rust_logo,
rust_out,
rustc,
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_target/src/callconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mod sparc64;
mod wasm;
mod x86;
mod x86_64;
mod x86_win32;
mod x86_win64;
mod xtensa;

Expand Down Expand Up @@ -649,7 +650,11 @@ impl<'a, Ty> FnAbi<'a, Ty> {
};
let reg_struct_return = cx.x86_abi_opt().reg_struct_return;
let opts = x86::X86Options { flavor, regparm, reg_struct_return };
x86::compute_abi_info(cx, self, opts);
if spec.is_like_msvc {
x86_win32::compute_abi_info(cx, self, opts);
} else {
x86::compute_abi_info(cx, self, opts);
}
}
"x86_64" => match abi {
ExternAbi::SysV64 { .. } => x86_64::compute_abi_info(cx, self),
Expand Down
24 changes: 2 additions & 22 deletions compiler/rustc_target/src/callconv/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ where
if t.abi_return_struct_as_int || opts.reg_struct_return {
// According to Clang, everyone but MSVC returns single-element
// float aggregates directly in a floating-point register.
if !t.is_like_msvc && fn_abi.ret.layout.is_single_fp_element(cx) {
if fn_abi.ret.layout.is_single_fp_element(cx) {
match fn_abi.ret.layout.size.bytes() {
4 => fn_abi.ret.cast_to(Reg::f32()),
8 => fn_abi.ret.cast_to(Reg::f64()),
Expand Down Expand Up @@ -64,31 +64,11 @@ where
continue;
}

// FIXME: MSVC 2015+ will pass the first 3 vector arguments in [XYZ]MM0-2
// See https://reviews.llvm.org/D72114 for Clang behavior

let t = cx.target_spec();
let align_4 = Align::from_bytes(4).unwrap();
let align_16 = Align::from_bytes(16).unwrap();

if t.is_like_msvc
&& arg.layout.is_adt()
&& let Some(max_repr_align) = arg.layout.max_repr_align
&& max_repr_align > align_4
{
// MSVC has special rules for overaligned arguments: https://reviews.llvm.org/D72114.
// Summarized here:
// - Arguments with _requested_ alignment > 4 are passed indirectly.
// - For backwards compatibility, arguments with natural alignment > 4 are still passed
// on stack (via `byval`). For example, this includes `double`, `int64_t`,
// and structs containing them, provided they lack an explicit alignment attribute.
assert!(
arg.layout.align.abi >= max_repr_align,
"abi alignment {:?} less than requested alignment {max_repr_align:?}",
arg.layout.align.abi,
);
arg.make_indirect();
} else if arg.layout.is_aggregate() {
if arg.layout.is_aggregate() {
// We need to compute the alignment of the `byval` argument. The rules can be found in
// `X86_32ABIInfo::getTypeStackAlignInBytes` in Clang's `TargetInfo.cpp`. Summarized
// here, they are:
Expand Down
Loading

0 comments on commit 20f0108

Please sign in to comment.