Skip to content
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

x86_64 asm: Build error when using r[8-15]b #485

Open
taiki-e opened this issue Apr 4, 2024 · 1 comment
Open

x86_64 asm: Build error when using r[8-15]b #485

taiki-e opened this issue Apr 4, 2024 · 1 comment

Comments

@taiki-e
Copy link
Member

taiki-e commented Apr 4, 2024

The following code passes build with cg_llvm, but fails with cg_gcc.

#[inline(never)]
pub unsafe fn f() {
    core::arch::asm!(
        "",
        out("al") _,
        out("bl") _,
        out("cl") _,
        out("dl") _,
        out("sil") _,
        out("dil") _,
        // out("bpl") _, // frame pointer
        out("r8b") _,
        out("r9b") _,
        out("r10b") _,
        out("r11b") _,
        out("r12b") _,
        out("r13b") _,
        out("r14b") _,
        out("r15b") _,
    );
}

The following is the error message when building with cg_gcc.

libgccjit.so: error: unknown register name 'r15b' in 'asm'
libgccjit.so: error: unknown register name 'r14b' in 'asm'
libgccjit.so: error: unknown register name 'r13b' in 'asm'
libgccjit.so: error: unknown register name 'r12b' in 'asm'
libgccjit.so: error: unknown register name 'r11b' in 'asm'
libgccjit.so: error: unknown register name 'r10b' in 'asm'
libgccjit.so: error: unknown register name 'r9b' in 'asm'
libgccjit.so: error: unknown register name 'r8b' in 'asm'
error: could not copy "/app/output.example.fb61ce7e3f5ff483-cgu.0.rcgu.s" to "/app/output.s": No such file or directory (os error 2)

playground

I could reproduce this with both playground and the latest master branch (75f0ab5).

Reference: https://doc.rust-lang.org/nightly/reference/inline-assembly.html#register-operands

Architecture Register class Registers LLVM constraint code
x86-64 reg_byte* al, bl, cl, dl, sil, dil, bpl, r[8-15]b q
@antoyo
Copy link
Contributor

antoyo commented Apr 4, 2024

Thanks for the bug report!

It seems GCC doesn't support the b suffix, so we'll need to convert those to the GCC way.

taiki-e added a commit to taiki-e/portable-atomic that referenced this issue Apr 5, 2024
rust-lang/rustc_codegen_gcc#485

```
libgccjit.so: error: invalid register name for 'output_register'
error: could not copy "/app/output.example.fb61ce7e3f5ff483-cgu.0.rcgu.s" to "/app/output.s": No such file or directory (os error 2)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants