1
Fork 0

Auto merge of #127956 - tgross35:rollup-8ten7pk, r=tgross35

Rollup of 7 pull requests

Successful merges:

 - #121533 (Handle .init_array link_section specially on wasm)
 - #127825 (Migrate `macos-fat-archive`, `manual-link` and `archive-duplicate-names` `run-make` tests to rmake)
 - #127891 (Tweak suggestions when using incorrect type of enum literal)
 - #127902 (`collect_tokens_trailing_token` cleanups)
 - #127928 (Migrate `lto-smoke-c` and `link-path-order` `run-make` tests to rmake)
 - #127935 (Change `binary_asm_labels` to only fire on x86 and x86_64)
 - #127953 ([compiletest] Search *.a when getting dynamic libraries on AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-07-19 11:08:02 +00:00
commit 11e57241f1
47 changed files with 1904 additions and 281 deletions

View file

@ -66,6 +66,7 @@ use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{BytePos, InnerSpan, Span};
use rustc_target::abi::Abi;
use rustc_target::asm::InlineAsmArch;
use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy};
@ -2739,8 +2740,9 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// # #![feature(asm_experimental_arch)]
/// ```rust,ignore (fails on non-x86_64)
/// #![cfg(target_arch = "x86_64")]
///
/// use std::arch::asm;
///
/// fn main() {
@ -2750,19 +2752,32 @@ declare_lint! {
/// }
/// ```
///
/// {{produces}}
/// This will produce:
///
/// ```text
/// error: avoid using labels containing only the digits `0` and `1` in inline assembly
/// --> <source>:7:15
/// |
/// 7 | asm!("0: jmp 0b");
/// | ^ use a different label that doesn't start with `0` or `1`
/// |
/// = help: start numbering with `2` instead
/// = note: an LLVM bug makes these labels ambiguous with a binary literal number on x86
/// = note: see <https://github.com/llvm/llvm-project/issues/99547> for more information
/// = note: `#[deny(binary_asm_labels)]` on by default
/// ```
///
/// ### Explanation
///
/// A [LLVM bug] causes this code to fail to compile because it interprets the `0b` as a binary
/// literal instead of a reference to the previous local label `0`. Note that even though the
/// bug is marked as fixed, it only fixes a specific usage of intel syntax within standalone
/// files, not inline assembly. To work around this bug, don't use labels that could be
/// confused with a binary literal.
/// An [LLVM bug] causes this code to fail to compile because it interprets the `0b` as a binary
/// literal instead of a reference to the previous local label `0`. To work around this bug,
/// don't use labels that could be confused with a binary literal.
///
/// This behavior is platform-specific to x86 and x86-64.
///
/// See the explanation in [Rust By Example] for more details.
///
/// [LLVM bug]: https://bugs.llvm.org/show_bug.cgi?id=36144
/// [LLVM bug]: https://github.com/llvm/llvm-project/issues/99547
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels
pub BINARY_ASM_LABELS,
Deny,
@ -2908,16 +2923,22 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
InvalidAsmLabel::FormatArg { missing_precise_span },
);
}
AsmLabelKind::Binary => {
// the binary asm issue only occurs when using intel syntax
if !options.contains(InlineAsmOptions::ATT_SYNTAX) {
cx.emit_span_lint(
BINARY_ASM_LABELS,
span,
InvalidAsmLabel::Binary { missing_precise_span, span },
)
}
// the binary asm issue only occurs when using intel syntax on x86 targets
AsmLabelKind::Binary
if !options.contains(InlineAsmOptions::ATT_SYNTAX)
&& matches!(
cx.tcx.sess.asm_arch,
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) | None
) =>
{
cx.emit_span_lint(
BINARY_ASM_LABELS,
span,
InvalidAsmLabel::Binary { missing_precise_span, span },
)
}
// No lint on anything other than x86
AsmLabelKind::Binary => (),
};
}
}

View file

@ -2074,7 +2074,9 @@ pub enum InvalidAsmLabel {
missing_precise_span: bool,
},
#[diag(lint_invalid_asm_label_binary)]
#[note]
#[help]
#[note(lint_note1)]
#[note(lint_note2)]
Binary {
#[note(lint_invalid_asm_label_no_span)]
missing_precise_span: bool,