Repository navigation
Stuck when compiling RISC-V #81440
Copy link
Copy link
Closed
Labels
hangCompiler hang (infinite loop)Compiler hang (infinite loop)incompleteIssue not complete (e.g. missing a reproducer, build arguments, etc.)Issue not complete (e.g. missing a reproducer, build arguments, etc.)llvm:mcMachine (object) codeMachine (object) code
Description
Found in Zig ziglang/zig#18872 with LLVM 17.
LLVM gets stuck in AttemptToFoldSymbolOffsetDifference for forever. The longest I've ran a build for is 14 hours on an Apple M1 Pro generating for riscv64-linux baseline.
#0 AttemptToFoldSymbolOffsetDifference (Asm=0x1fd10c10, Layout=0x7ffffffe3570, Addrs=0x0, InSet=true, A=@0x7ffffffe2d88: 0xff381058, B=@0x7ffffffe2d80: 0x0, Addend=@0x7ffffffe2d78: 0) at /home/ross/zig-bootstrap/llvm/lib/MC/MCExpr.cpp:596
#1 0x000000000c3a2bb8 in EvaluateSymbolicAdd (Asm=0x1fd10c10, Layout=0x7ffffffe3570, Addrs=0x0, InSet=true, LHS=..., RHS_A=0x0, RHS_B=0xff381070, RHS_Cst=0, Res=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCExpr.cpp:775
#2 0x000000000c3a399f in llvm::MCExpr::evaluateAsRelocatableImpl (this=0xff381088, Res=..., Asm=0x1fd10c10, Layout=0x7ffffffe3570, Fixup=0x0, Addrs=0x0, InSet=true) at /home/ross/zig-bootstrap/llvm/lib/MC/MCExpr.cpp:965
#3 0x000000000c3a2164 in llvm::MCExpr::evaluateAsAbsolute (this=0xff381088, Res=@0x7ffffffe3178: 4298713344, Asm=0x1fd10c10, Layout=0x7ffffffe3570, Addrs=0x0, InSet=true) at /home/ross/zig-bootstrap/llvm/lib/MC/MCExpr.cpp:583
#4 0x000000000c3a20c1 in llvm::MCExpr::evaluateKnownAbsolute (this=0xff381088, Res=@0x7ffffffe3178: 4298713344, Layout=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCExpr.cpp:567
#5 0x000000000c350d27 in llvm::MCAssembler::relaxDwarfLineAddr (this=0x1fd10c10, Layout=..., DF=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:1099
#6 0x000000000c3512a1 in llvm::MCAssembler::relaxFragment (this=0x1fd10c10, Layout=..., F=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:1178
#7 0x000000000c3513f3 in llvm::MCAssembler::layoutSectionOnce (this=0x1fd10c10, Layout=..., Sec=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:1205
#8 0x000000000c3514d0 in llvm::MCAssembler::layoutOnce (this=0x1fd10c10, Layout=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:1221
#9 0x000000000c34fc07 in llvm::MCAssembler::layout (this=0x1fd10c10, Layout=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:843
#10 0x000000000c3504a8 in llvm::MCAssembler::Finish (this=0x1fd10c10) at /home/ross/zig-bootstrap/llvm/lib/MC/MCAssembler.cpp:944
#11 0x000000000c3c495e in llvm::MCObjectStreamer::finishImpl (this=0x176d3240) at /home/ross/zig-bootstrap/llvm/lib/MC/MCObjectStreamer.cpp:932
#12 0x000000000c397dba in llvm::MCELFStreamer::finishImpl (this=0x176d3240) at /home/ross/zig-bootstrap/llvm/lib/MC/MCELFStreamer.cpp:721
#13 0x000000000c3e9dee in llvm::MCStreamer::finish (this=0x176d3240, EndLoc=...) at /home/ross/zig-bootstrap/llvm/lib/MC/MCStreamer.cpp:1021
#14 0x000000000a60ce05 in llvm::AsmPrinter::doFinalization (this=0x1740d7b0, M=...) at /home/ross/zig-bootstrap/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2396
#15 0x000000000c76afad in llvm::FPPassManager::doFinalization (this=0x389ef1f0, M=...) at /home/ross/zig-bootstrap/llvm/lib/IR/LegacyPassManager.cpp:1499
#16 0x000000000c76b552 in (anonymous namespace)::MPPassManager::runOnModule (this=0x9326ed40, M=...) at /home/ross/zig-bootstrap/llvm/lib/IR/LegacyPassManager.cpp:1586
#17 0x000000000c766518 in llvm::legacy::PassManagerImpl::run (this=0x742575c0, M=...) at /home/ross/zig-bootstrap/llvm/lib/IR/LegacyPassManager.cpp:535
#18 0x000000000c76baed in llvm::legacy::PassManager::run (this=0x7ffffffe4160, M=...) at /home/ross/zig-bootstrap/llvm/lib/IR/LegacyPassManager.cpp:1677
#19 0x000000000292a368 in ZigLLVMTargetMachineEmitToFile (targ_machine_ref=0x17058820, module_ref=0x17050ee0, error_message=0x7ffffffe5da8, is_debug=true, is_small=false, time_report=false, tsan=false, lto=false, asm_filename=0x0, bin_filename=0x9348ace3 "zig.o", llvm_ir_filename=0x0, bitcode_filename=0x0)
at /home/ross/zig-bootstrap/zig/src/zig_llvm.cpp:357
#20 0x00000000004a10bf in codegen_llvm_Object_emit__13929 (a0=0x7fffeb9994e8, a1=...) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:368532
#21 0x00000000004a1a7d in Compilation_emitLlvmObject__5131 (a0=0x7fffeb997ce0, a1=..., a2=..., a3=..., a4=0x7fffeb9994e8, a5=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:368669
#22 0x0000000000bdeed2 in link_File_emitLlvmObject__4801 (a0=..., a1=..., a2=0x7fffeb9994e8, a3=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:987633
#23 0x0000000000c71e80 in link_Elf_flushModule__4835 (a0=0x7fffeb998da8, a1=..., a2=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:1030814
#24 0x00000000008b7015 in link_Elf_linkWithLLD__4855 (a0=0x7fffeb998da8, a1=..., a2=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:703231
#25 0x00000000008d0f00 in link_Elf_flush__4834 (a0=0x7fffeb998da8, a1=..., a2=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:707770
#26 0x000000000064eb70 in link_File_flush__4777 (a0=0x7fffeb998da8, a1=..., a2=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:494132
#27 0x00000000004a1ba5 in Compilation_flush__5123 (a0=0x7fffeb997ce0, a1=..., a2=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:368732
#28 0x00000000004a7ab3 in Compilation_update__5122 (a0=0x7fffeb997ce0, a1=0x7ffffffebfe0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:370261
#29 0x00000000004d3e4d in main_updateModule__216 (a0=0x7fffeb997ce0, a1=0 '\000') at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:379451
#30 0x0000000000502897 in main_buildOutputType__206 (a0=..., a1=..., a2=..., a3=...) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:390743
#31 0x000000000050e6db in main_mainArgs__194 (a0=..., a1=..., a2=...) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:394280
#32 0x00000000004257a9 in main_main__192 () at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:330827
#33 0x00000000004242aa in main (a0=318, a1=0x7fffffff46f8, a2=0x7fffffff50f0) at /home/ross/zig-bootstrap/out/build-zig-host/zig2.c:330446
Reacted by Theo Paris and Suraj
Metadata
Metadata
Assignees
Labels
hangCompiler hang (infinite loop)Compiler hang (infinite loop)incompleteIssue not complete (e.g. missing a reproducer, build arguments, etc.)Issue not complete (e.g. missing a reproducer, build arguments, etc.)llvm:mcMachine (object) codeMachine (object) code
Activity
EugeneZelenko commentedon Feb 12, 2024
Could you please try 18 or
mainbranch?RossComputerGuy commentedon Feb 12, 2024
Will have to do the LLVM upgrade process unless you know of any easy way to reproduce this outside of Zig.
dtcxzyw commentedon Feb 12, 2024
@RossComputerGuy Could you please provide the LLVM IR?
RossComputerGuy commentedon Feb 15, 2024
I'm having trouble sending the IR since it's 608MB.
RossComputerGuy commentedon Feb 15, 2024
https://termbin.com/2oij ok, i think this should do.
alexrp commentedon Aug 24, 2024
I believe b06e736 fixed this.
psilva261 commentedon Jan 29, 2026
Yeah this matches also my observation. At some point I got a profile, pointing me to this thread in the first place:
But with LLVM 19 and later I don't see this issue anymore
EugeneZelenko commentedon Jan 29, 2026
Could you please try 22 release candidate or
mainbranch? Only most recent release is maintained.psilva261 commentedon Feb 6, 2026
Yeah I now tried with release/22.x and it seems okay as well