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

Bug in inline assembly for arm #85183

Closed
Sp00ph opened this issue May 11, 2021 · 2 comments
Closed

Bug in inline assembly for arm #85183

Sp00ph opened this issue May 11, 2021 · 2 comments
Labels
C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`)

Comments

@Sp00ph
Copy link
Member

Sp00ph commented May 11, 2021

When trying to compile the gba crate(gba = { git = "https://github.com/rust-console/gba", rev = "127f31e" }) using the following target:

{
  "abi-blacklist": [
    "stdcall",
    "fastcall",
    "vectorcall",
    "thiscall",
    "win64",
    "sysv64"
  ],
  "arch": "arm",
  "atomic-cas": false,
  "cpu": "arm7tdmi",
  "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
  "emit-debug-gdb-scripts": false,
  "env": "agb",
  "executables": true,
  "features": "+soft-float,+strict-align",
  "linker": "arm-none-eabi-ld",
  "linker-flavor": "ld",
  "linker-is-gnu": true,
  "llvm-target": "thumbv4-none-agb",
  "os": "none",
  "panic-strategy": "abort",
  "pre-link-args-crt": {
        "ld": [
            "crt0.o"
        ]
    },
  "pre-link-args": {
    "ld": [
      "-Tlinker.ld"
    ]
  },
  "relocation-model": "static",
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-pointer-width": "32",
  "vendor": "nintendo"
}

I get this compiler error:

error: invalid register `r9`: r9 is used internally by LLVM and cannot be used as an operand for inline asm
   --> C:\Users\anon\.cargo\git\checkouts\gba-4ba04b9d61fb788f\127f31e\src\sync\statics.rs:106:72
    |
106 |       out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _, out("r9") _,
    |                                                                        ^^^^^^^^^^^

error: invalid register `r9`: r9 is used internally by LLVM and cannot be used as an operand for inline asm
   --> C:\Users\anon\.cargo\git\checkouts\gba-4ba04b9d61fb788f\127f31e\src\sync\statics.rs:113:72
    |
113 |       out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _, out("r9") _,
    |                                                                        ^^^^^^^^^^^

error: invalid register `r9`: r9 is used internally by LLVM and cannot be used as an operand for inline asm
   --> C:\Users\anon\.cargo\git\checkouts\gba-4ba04b9d61fb788f\127f31e\src\sync\statics.rs:121:72
    |
121 |       out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _, out("r9") _,
    |                                                                        ^^^^^^^^^^^

error: invalid register `r9`: r9 is used internally by LLVM and cannot be used as an operand for inline asm
   --> C:\Users\anon\.cargo\git\checkouts\gba-4ba04b9d61fb788f\127f31e\src\sync\statics.rs:129:72
    |
129 |       out("r2") _, out("r3") _, out("r4") _, out("r5") _, out("r8") _, out("r9") _,
    |                                                                        ^^^^^^^^^^^

error: aborting due to 4 previous errors

error: could not compile `gba`

This seems to be a bug in the asm! macro as this code used to compile just fine.

I'm using the latest nightly rustc release:

$ rustc --version --verbose
rustc 1.54.0-nightly (79e50bf77 2021-05-10)
binary: rustc
commit-hash: 79e50bf77928f374921a6bcafee3fcff1915f062
commit-date: 2021-05-10
host: x86_64-pc-windows-msvc
release: 1.54.0-nightly
LLVM version: 12.0.1

The same thing also happens when using the gnu toolchain:

$ rustc --version --verbose
rustc 1.54.0-nightly (79e50bf77 2021-05-10)
binary: rustc
commit-hash: 79e50bf77928f374921a6bcafee3fcff1915f062
commit-date: 2021-05-10
host: x86_64-pc-windows-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1
@Sp00ph Sp00ph added the C-bug Category: This is a bug. label May 11, 2021
@jonas-schievink jonas-schievink added the F-asm `#![feature(asm)]` (not `llvm_asm`) label May 11, 2021
@PatchMixolydic
Copy link
Contributor

cc #85247, which has information about the commit that made r9 a reserved register

@Amanieu
Copy link
Member

Amanieu commented Jun 3, 2021

Closing as a duplicate of #85247

@Amanieu Amanieu closed this as completed Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`)
Projects
None yet
Development

No branches or pull requests

4 participants