Open eigenform opened 1 year ago
$ rustc --version --verbose rustc 1.71.0-nightly (2f2c438dc 2023-05-08) binary: rustc commit-hash: 2f2c438dce75d8cc532c3baa849eeddc0901802c commit-date: 2023-05-08 host: x86_64-unknown-linux-gnu release: 1.71.0-nightly LLVM version: 16.0.2
global_asm! prints errors about missing target features even when they are enabled. I think this is the same behavior as
global_asm!
In this case, rustc emits errors but doesn't abort and produces the correct, expected output file.
rustc
/// foo.rs core::arch::global_asm!(" .section .text .global my_func my_func: sb ret "); #[no_mangle] #[inline(never)] fn main() { //unsafe { core::arch::asm!("sb"); } }
$ rustc foo.rs --target aarch64-unknown-linux-gnu --crate-type lib -C target-feature=+sb error: instruction requires: sb sb ^ error: instruction requires: sb sb ^ $ aarch64-linux-gnu-objdump -C -d libfoo.rlib In archive libfoo.rlib: lib.rmeta: file format elf64-littleaarch64 foo.foo.bbcbb88c88589229-cgu.0.rcgu.o: file format elf64-littleaarch64 Disassembly of section .text: 0000000000000000 <my_func>: 0: d50330ff sb 4: d65f03c0 ret Disassembly of section .text.main: 0000000000000000 <main>: 0: d65f03c0 ret
For comparison, here's the same situation with asm! instead:
asm!
/// foo.rs //core::arch::global_asm!(" //.section .text //.global my_func //my_func: // sb // ret //");
fn main() { unsafe { core::arch::asm!("sb"); } }
note: instantiated into assembly here --> :1:2 | 1 | sb | ^
error: aborting due to previous error
$ rustc foo.rs --target aarch64-unknown-linux-gnu --crate-type lib -C target-feature=+sb $ aarch64-linux-gnu-objdump -C -d libfoo.rlib In archive libfoo.rlib:
lib.rmeta: file format elf64-littleaarch64
foo.foo.bbcbb88c88589229-cgu.0.rcgu.o: file format elf64-littleaarch64
Disassembly of section .text.main:
0000000000000000 : 0: d50330ff sb 4: d65f03c0 ret
@rustbot label C-bug A-inline-assembly
global_asm!
prints errors about missing target features even when they are enabled. I think this is the same behavior as50477.
In this case,
rustc
emits errors but doesn't abort and produces the correct, expected output file.For comparison, here's the same situation with
asm!
instead:rustc
prints errors about the missing feature and aborts (generating no output file)rustc
produces the correct, expected output file[no_mangle]
[inline(never)]
fn main() { unsafe { core::arch::asm!("sb"); } }
note: instantiated into assembly here -->:1:2
|
1 | sb
| ^
error: aborting due to previous error
$ rustc foo.rs --target aarch64-unknown-linux-gnu --crate-type lib -C target-feature=+sb $ aarch64-linux-gnu-objdump -C -d libfoo.rlib In archive libfoo.rlib:
lib.rmeta: file format elf64-littleaarch64
foo.foo.bbcbb88c88589229-cgu.0.rcgu.o: file format elf64-littleaarch64
Disassembly of section .text.main:
0000000000000000:
0: d50330ff sb
4: d65f03c0 ret