Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #137816 (attempt to support `BinaryFormat::Xcoff` in `naked_asm!`) - #138109 (make precise capturing args in rustdoc Json typed) - #138343 (Enable `f16` tests for `powf`) - #138356 (bump libc to 0.2.171 to fix xous) - #138371 (Update compiletest's `has_asm_support` to match rustc) - #138404 (Cleanup sysroot locating a bit) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
93257e2d20
33 changed files with 268 additions and 127 deletions
|
@ -1288,8 +1288,7 @@ fn link_sanitizer_runtime(
|
|||
if path.exists() {
|
||||
sess.target_tlib_path.dir.clone()
|
||||
} else {
|
||||
let default_sysroot =
|
||||
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
|
||||
let default_sysroot = filesearch::get_or_default_sysroot();
|
||||
let default_tlib =
|
||||
filesearch::make_target_lib_path(&default_sysroot, sess.opts.target_triple.tuple());
|
||||
default_tlib
|
||||
|
|
|
@ -125,7 +125,8 @@ fn prefix_and_suffix<'tcx>(
|
|||
// the alignment from a `#[repr(align(<n>))]` is used if it specifies a higher alignment.
|
||||
// if no alignment is specified, an alignment of 4 bytes is used.
|
||||
let min_function_alignment = tcx.sess.opts.unstable_opts.min_function_alignment;
|
||||
let align = Ord::max(min_function_alignment, attrs.alignment).map(|a| a.bytes()).unwrap_or(4);
|
||||
let align_bytes =
|
||||
Ord::max(min_function_alignment, attrs.alignment).map(|a| a.bytes()).unwrap_or(4);
|
||||
|
||||
// In particular, `.arm` can also be written `.code 32` and `.thumb` as `.code 16`.
|
||||
let (arch_prefix, arch_suffix) = if is_arm {
|
||||
|
@ -157,12 +158,16 @@ fn prefix_and_suffix<'tcx>(
|
|||
}
|
||||
Linkage::LinkOnceAny | Linkage::LinkOnceODR | Linkage::WeakAny | Linkage::WeakODR => {
|
||||
match asm_binary_format {
|
||||
BinaryFormat::Elf
|
||||
| BinaryFormat::Coff
|
||||
| BinaryFormat::Wasm
|
||||
| BinaryFormat::Xcoff => {
|
||||
BinaryFormat::Elf | BinaryFormat::Coff | BinaryFormat::Wasm => {
|
||||
writeln!(w, ".weak {asm_name}")?;
|
||||
}
|
||||
BinaryFormat::Xcoff => {
|
||||
// FIXME: there is currently no way of defining a weak symbol in inline assembly
|
||||
// for AIX. See https://github.com/llvm/llvm-project/issues/130269
|
||||
emit_fatal(
|
||||
"cannot create weak symbols from inline assembly for this target",
|
||||
)
|
||||
}
|
||||
BinaryFormat::MachO => {
|
||||
writeln!(w, ".globl {asm_name}")?;
|
||||
writeln!(w, ".weak_definition {asm_name}")?;
|
||||
|
@ -189,7 +194,7 @@ fn prefix_and_suffix<'tcx>(
|
|||
let mut begin = String::new();
|
||||
let mut end = String::new();
|
||||
match asm_binary_format {
|
||||
BinaryFormat::Elf | BinaryFormat::Xcoff => {
|
||||
BinaryFormat::Elf => {
|
||||
let section = link_section.unwrap_or(format!(".text.{asm_name}"));
|
||||
|
||||
let progbits = match is_arm {
|
||||
|
@ -203,7 +208,7 @@ fn prefix_and_suffix<'tcx>(
|
|||
};
|
||||
|
||||
writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
|
||||
writeln!(begin, ".balign {align}").unwrap();
|
||||
writeln!(begin, ".balign {align_bytes}").unwrap();
|
||||
write_linkage(&mut begin).unwrap();
|
||||
if let Visibility::Hidden = item_data.visibility {
|
||||
writeln!(begin, ".hidden {asm_name}").unwrap();
|
||||
|
@ -224,7 +229,7 @@ fn prefix_and_suffix<'tcx>(
|
|||
BinaryFormat::MachO => {
|
||||
let section = link_section.unwrap_or("__TEXT,__text".to_string());
|
||||
writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
|
||||
writeln!(begin, ".balign {align}").unwrap();
|
||||
writeln!(begin, ".balign {align_bytes}").unwrap();
|
||||
write_linkage(&mut begin).unwrap();
|
||||
if let Visibility::Hidden = item_data.visibility {
|
||||
writeln!(begin, ".private_extern {asm_name}").unwrap();
|
||||
|
@ -240,7 +245,7 @@ fn prefix_and_suffix<'tcx>(
|
|||
BinaryFormat::Coff => {
|
||||
let section = link_section.unwrap_or(format!(".text.{asm_name}"));
|
||||
writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
|
||||
writeln!(begin, ".balign {align}").unwrap();
|
||||
writeln!(begin, ".balign {align_bytes}").unwrap();
|
||||
write_linkage(&mut begin).unwrap();
|
||||
writeln!(begin, ".def {asm_name}").unwrap();
|
||||
writeln!(begin, ".scl 2").unwrap();
|
||||
|
@ -279,6 +284,33 @@ fn prefix_and_suffix<'tcx>(
|
|||
// .size is ignored for function symbols, so we can skip it
|
||||
writeln!(end, "end_function").unwrap();
|
||||
}
|
||||
BinaryFormat::Xcoff => {
|
||||
// the LLVM XCOFFAsmParser is extremely incomplete and does not implement many of the
|
||||
// documented directives.
|
||||
//
|
||||
// - https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp
|
||||
// - https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf
|
||||
//
|
||||
// Consequently, we try our best here but cannot do as good a job as for other binary
|
||||
// formats.
|
||||
|
||||
// FIXME: start a section. `.csect` is not currently implemented in LLVM
|
||||
|
||||
// fun fact: according to the assembler documentation, .align takes an exponent,
|
||||
// but LLVM only accepts powers of 2 (but does emit the exponent)
|
||||
// so when we hand `.align 32` to LLVM, the assembly output will contain `.align 5`
|
||||
writeln!(begin, ".align {}", align_bytes).unwrap();
|
||||
|
||||
write_linkage(&mut begin).unwrap();
|
||||
if let Visibility::Hidden = item_data.visibility {
|
||||
// FIXME apparently `.globl {asm_name}, hidden` is valid
|
||||
// but due to limitations with `.weak` (see above) we can't really use that in general yet
|
||||
}
|
||||
writeln!(begin, "{asm_name}:").unwrap();
|
||||
|
||||
writeln!(end).unwrap();
|
||||
// FIXME: end the section?
|
||||
}
|
||||
}
|
||||
|
||||
(begin, end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue