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

mipsel targets: compilation fails with "Undefined temporary symbol $BB0_4" #108835

Closed
Mrmaxmeier opened this issue Mar 7, 2023 · 9 comments
Closed
Labels
C-bug Category: This is a bug. llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade, or backported fixes O-MIPS Target: MIPS processors

Comments

@Mrmaxmeier
Copy link
Contributor

Hi,

I hit a strange build failure in CI where rustc-demangle fails to build for mipsel-unknown-linux-gnu .

Here's a reduced reproducer:

// ⋊> rustc ./repro.rs --crate-type=lib --target mipsel-unknown-linux-gnu
// error: Undefined temporary symbol $BB0_4
//
// error: aborting due to previous error
pub fn func(s: &()) -> usize {
    #[allow(dead_code)]
    enum Error {
        VarA,
        VarB,
    }

    fn subfunc<'a>(_s: &'a ()) -> Result<&'a str, Error> {
        loop {}
    }
    match subfunc(s) {
        Ok(_d) => 1,
        Err(Error::VarA) | Err(Error::VarB) => 2,
    }
}

Meta

I'm using current nightly, but this is a regression from stable (1.67.1) to beta (1.68.0-beta.7).

rustc --version --verbose:

rustc 1.70.0-nightly (7820b62d2 2023-03-05)
binary: rustc
commit-hash: 7820b62d20bc548096d4632a3487987308cb4b5d
commit-date: 2023-03-05
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

cargo bisect-rustc points to d726c84 (in nightly-2022-11-01), but this feels like an LLVM bug.
I can't trigger it via --emit=llvm-ir and llc repro.ll -o repro.o -filetype=obj though. The LLVM version matches, but I'm probably not reproducing rustc's interactions with LLVM faithfully..

Sorry for the noise with obscure target architectures, but I'm reporting the issue here because I don't know how to reproduce it on LLVM's side 🙂

@Mrmaxmeier Mrmaxmeier added the C-bug Category: This is a bug. label Mar 7, 2023
@workingjubilee workingjubilee added the O-MIPS Target: MIPS processors label Mar 7, 2023
@workingjubilee
Copy link
Member

Sorry for the noise with obscure target architectures

It's fine. We may not offer the best support for them due to technical and resource constraints, but we still want people to have the option to run Rust code on their OpenWRT router or their PlayStation or whatever.

bors bot added a commit to rust-embedded/gpio-cdev that referenced this issue May 25, 2023
71: Do not run CI tests on mips r=ryankurte a=eldruin

It seems we have been hit by rust-lang/rust#108835 
Until that is fixed, let's not run the tests on mips targets.
Also, I raised the MSRV due to the dependencies.

Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
@cnjn
Copy link

cnjn commented Jun 29, 2023

i hit the same problem. build rustc-demangle failed for mipsel-unknown-linux-gnu

@workingjubilee
Copy link
Member

May be caused by a trigger for #113065

@taiki-e
Copy link
Member

taiki-e commented Jul 16, 2023

FYI, this can be worked around by enabling optimization.

$ cargo +1.67 build --target mipsel-unknown-linux-gnu
   Compiling repro v0.1.0 (...)
error: Undefined temporary symbol $BB0_4

error: could not compile `repro` due to previous error

$ cargo +1.67 build --target mipsel-unknown-linux-gnu --release
   Compiling repro v0.1.0 (...)
    Finished release [optimized] target(s) in 0.09s

$ RUSTFLAGS='-C opt-level=1' cargo +1.67 build --target mipsel-unknown-linux-gnu
   Compiling repro v0.1.0 (...)
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s

The same workaround works for error from rustc-demangle when using build-std in the latest nightly. (taiki-e/rust-cross-toolchain@e820504, taiki-e/setup-cross-toolchain-action@1ca8c89, taiki-e/atomic-maybe-uninit@ec71c70, taiki-e/portable-atomic@d47811e)

@Fearyncess
Copy link
Contributor

FYI, this can be worked around by enabling optimization.

Maybe its relocation is too far then that has been truncated?

MaskRay added a commit to MaskRay/llvm-project that referenced this issue Feb 6, 2024
This should fix rust-lang/rust#108835

FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.
MaskRay added a commit to llvm/llvm-project that referenced this issue Feb 6, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Feb 6, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Feb 6, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
@urosbericsyrmia
Copy link

This issue should be fixed by llvm/llvm-project#80799.
Initially, the cause of the issue and the solution are explained in llvm/llvm-project#80666, but more elegant solution is just to remove derived isBlockOnlyReachableByFallthrough for Mips architecture.

@DianQK
Copy link
Member

DianQK commented Feb 7, 2024

@rustbot label llvm-fixed-upstream

@rustbot rustbot added the llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade, or backported fixes label Feb 7, 2024
@nikic
Copy link
Contributor

nikic commented Feb 14, 2024

Can someone confirm that this is fixed on nightly?

@Mrmaxmeier
Copy link
Contributor Author

Yep. My initial reproducer fails with rustc 1.76.0 (07dca489a 2024-02-04) but compiles on 1.78.0-nightly (a84bb95a1 2024-02-13). 📈

tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
rust-lang/rust#108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9f for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7a)
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. llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade, or backported fixes O-MIPS Target: MIPS processors
Projects
None yet
Development

No branches or pull requests

9 participants