Skip to content

[LoongArch] dead loop after nightly-2024-02-12 #121289

Closed

Description

@heiher

I tried this code:

rustc -vV
cargo -vV

I expected to see this happen: outputs version info

Instead, this happened: dead loop in main entry function.

Meta

rustc --version --verbose:

a84bb95a1 2024-02-13
b381d3ab2 2024-02-12 good
a84bb95a1 2024-02-13 bad

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 19, 2024
  2. changed the title [-][Loongarch] dead loop after nightly-2024-02-12[/-] [+][LoongArch] dead loop after nightly-2024-02-12[/+] on Feb 19, 2024
  3. heiher commented on Feb 19, 2024

    @heiher
    ContributorAuthor

    @rustbot label O-loongarch

  4. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 19, 2024
  5. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    on Feb 19, 2024
  6. nikic commented on Feb 19, 2024

    @nikic
    Contributor

    That would be due to the LLVM 18 upgrade.

  7. heiher commented on Feb 19, 2024

    @heiher
    ContributorAuthor

    That would be due to the LLVM 18 upgrade.

    Yeah. It seems that the CI loongarch64-unknown-linux-gnu ld does not handle R_LARCH_CALL36 (pcaddu18+jirl) relocations correctly.

    0000000000000a40 <main>:                           
       a40:   02ffc063    addi.d          $sp, $sp, -16  
       a44:   29c02061    st.d            $ra, $sp, 8    
       a48:   001500a6    move            $a2, $a1       
       a4c:   02800085    addi.w          $a1, $a0, 0    
       a50:   1a000024    pcalau12i       $a0, 1         
       a54:   02e88084    addi.d          $a0, $a0, -1504
       a58:   03800c07    li.w            $a3, 0x3       
    >  a5c:   1e000001    pcaddu18i       $ra, 0         # loop
    >  a60:   4c000021    jirl            $ra, $ra, 0    
       a64:   28c02061    ld.d            $ra, $sp, 8    
       a68:   02c04063    addi.d          $sp, $sp, 16   
       a6c:   4c000020    ret                            
    
  8. heiher commented on Feb 19, 2024

    @heiher
    ContributorAuthor

    There is no version of crosstool-ng that supports R_LARCH_CALL36, I'll revert the medium code model until the issue is resolved.

  9. xry111 commented on Feb 19, 2024

    @xry111
    Contributor

    Oooops. Is this communicated with crosstool-ng maintainers?

  10. xry111 commented on Feb 19, 2024

    @xry111
    Contributor

    But maybe crosstool-ng maintainers can't act as well due to the incompatibility between GCC 13.2 and Binutils 2.42 (loongson-community/discussions#41) :(. I'm not sure how to fix such an incompatibility...

  11. heiher commented on Feb 19, 2024

    @heiher
    ContributorAuthor

    Oooops. Is this communicated with crosstool-ng maintainers?

    Not yet. binutils 2.42 in progress: crosstool-ng/crosstool-ng#2095

  12. 1 remaining item

  13. added 2 commits that reference this issue on Feb 20, 2024
    71ed0b9
    5540d81
  14. added a commit that references this issue on Feb 20, 2024
    6db8721
  15. added a commit that references this issue on Aug 13, 2024
  16. added a commit that references this issue on Aug 14, 2024
  17. added a commit that references this issue on Aug 19, 2024
  18. added a commit that references this issue on Aug 19, 2024
  19. xen0n commented on Sep 6, 2024

    @xen0n
    Contributor

    #129048 is merged recently that bumped the LoongArch binutils to 2.42, so can we try #120661 again?

  20. heiher commented on Sep 6, 2024

    @heiher
    ContributorAuthor

    #129048 is merged recently that bumped the LoongArch binutils to 2.42, so can we try #120661 again?

    Yes, with #129048 merged, we can retry #120661.

  21. added a commit that references this issue on Sep 13, 2024
  22. added a commit that references this issue on Sep 13, 2024
  23. xen0n commented on Sep 14, 2024

    @xen0n
    Contributor

    Today's nightly is built off of #130312, which contains #130266 and does work:

    $ rustc -Vv
    rustc 1.83.0-nightly (0609062a9 2024-09-13)
    binary: rustc
    commit-hash: 0609062a91c8f445c3e9a0de57e402f9b1b8b0a7
    commit-date: 2024-09-13
    host: loongarch64-unknown-linux-gnu
    release: 1.83.0-nightly
    LLVM version: 19.1.0
    

    And the medium code model is indeed in use:

    $ readelf -r ~/.rustup/toolchains/nightly-loongarch64-unknown-linux-gnu/lib/rustlib/loongarch64-unknown-linux-gnu/lib/libcore-c292f7f95e655c4c.rlib | grep 'R_LARCH_CALL36' | wc -l
    769
    

    So this issue is finally resolved. Thanks for everyone involved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.O-loongarchTarget: LoongArch (LA32R, LA32S, LA64)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions