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

loongarch: use medium code model for zig loongarch64 binary #21153

Merged
merged 4 commits into from
Sep 1, 2024

Conversation

yxd-ym
Copy link
Contributor

@yxd-ym yxd-ym commented Aug 21, 2024

See: https://elixir.bootlin.com/llvm/llvmorg-18.1.8/source/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp#L74

LLVM 18 only supports

  • small
  • medium
  • large

code model on loongarch64.

And it seems to remain the same in LLVM 19.
See: https://elixir.bootlin.com/llvm/llvmorg-19.1.0-rc3/source/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp#L83

I have tried different values, but medium seems to be the only one supported for both loongarch64-linux-gnu and loongarch64-linux-musl to have a debuggable loongarch64 zig built.

Also see: ziglang/zig-bootstrap#164 (comment)

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where the default code model is selected by the compiler frontend:

zig/src/Package/Module.zig

Lines 222 to 226 in 16d7480

const code_model = b: {
if (options.inherited.code_model) |x| break :b x;
if (options.parent) |p| break :b p.code_model;
break :b .default;
};

Here, you can observe that the selected backend is the LLVM backend and default to medium.

@yxd-ym
Copy link
Contributor Author

yxd-ym commented Aug 23, 2024

I see. So setting it explicitly is not needed? Then I will close this.

@andrewrk
Copy link
Member

What I mean is that your patch should edit these lines instead of build.zig.

@alexrp
Copy link
Member

alexrp commented Aug 23, 2024

Has an upstream LLVM issue been filed for whatever it is that's causing this to be necessary?

@yxd-ym
Copy link
Contributor Author

yxd-ym commented Aug 23, 2024

llvm/llvm-project#72514

llvm/llvm-project#72514 (comment)

So my guesses are

  • If we don't explicitly set -mcmodel, llvm will use small by default.
  • However, for zig, we need to explicitly set it to medium like chromium's case to avoid relocation overflow problem.

I'm not sure whether this is correct.

@alexrp
Copy link
Member

alexrp commented Aug 23, 2024

Can you go into detail regarding the R_LARCH_B26 problem you mentioned? Just trying to understand why the default code model is not sufficient for Zig. Is it just that the Zig binary is so big that the relocations in the default code model don't have enough range?

@yxd-ym
Copy link
Contributor Author

yxd-ym commented Aug 24, 2024

Here are the final piece of output of the command

CMAKE_GENERATOR=Ninja ./build loongarch64-linux-musl loongarch64

with the patch

diff --git a/build b/build
index d860a0496..fbc1c7b5b 100755
--- a/build
+++ b/build
@@ -195,8 +195,7 @@ $ZIG build \
   --search-prefix "$ROOTDIR/out/$TARGET-$MCPU" \
   -Dflat \
   -Dstatic-llvm \
-  -Doptimize=ReleaseFast \
-  -Dstrip \
+  -Doptimize=Debug \
   -Dtarget="$TARGET" \
   -Dcpu="$MCPU" \
   -Dversion-string="$ZIG_VERSION"
diff --git a/zig/lib/libc/glibc/sysdeps/loongarch/start.S b/zig/lib/libc/glibc/sysdeps/loongarch/start.S
index de7f9645c..976dd9217 100644
--- a/zig/lib/libc/glibc/sysdeps/loongarch/start.S
+++ b/zig/lib/libc/glibc/sysdeps/loongarch/start.S
@@ -56,7 +56,7 @@ ENTRY (ENTRY_POINT)
 
 /* Terminate call stack by noting ra is undefined.  Use a dummy
    .cfi_label to force starting the FDE.  */
-	.cfi_label .Ldummy
+	/* .cfi_label .Ldummy */
 	cfi_undefined (1)
 	or		a5, a0, zero /* rtld_fini */
 
diff --git a/zig/src/codegen/llvm.zig b/zig/src/codegen/llvm.zig
index 233cf7e3e..80e37c1ad 100644
--- a/zig/src/codegen/llvm.zig
+++ b/zig/src/codegen/llvm.zig
@@ -11799,6 +11799,7 @@ fn backendSupportsF16(target: std.Target) bool {
         .mips64,
         .mips64el,
         .s390x,
+        .loongarch64,
         => false,
         .aarch64,
         .aarch64_be,

on latest master (6bcacb49) of zig-bootstrap repository.

error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionPrinterPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&): .text._ZN4llvm26ScalarEvolutionPrinterPass3runERNS_8FunctionERNS_15AnalysisManagerIS1_JEEE+0x100): relocation R_LARCH_B26 out of range: 137495040 is not in [-134217728, 134217727]; references 'memcpy'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/fcd935fc76d674a1658962562aa74802/memcpy.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::initializeScalarEvolutionWrapperPassPass(llvm::PassRegistry&): .text._ZN4llvm40initializeScalarEvolutionWrapperPassPassERNS_12PassRegistryE+0x54): relocation R_LARCH_B26 out of range: 136959436 is not in [-134217728, 134217727]; references 'std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*))'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/f7fc0689b597a1fa8aed46ac0567074b/libc++.a(/Users/yxd/.cache/zig/o/f4d71cce49800e8e4296dbafe4c283f6/call_once.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function initializeScalarEvolutionWrapperPassPassOnce(llvm::PassRegistry&): .text._ZL44initializeScalarEvolutionWrapperPassPassOnceRN4llvm12PassRegistryE+0x34): relocation R_LARCH_B26 out of range: 137662380 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::ScalarEvolutionWrapperPass(): .text._ZN4llvm26ScalarEvolutionWrapperPassC2Ev+0x84): relocation R_LARCH_B26 out of range: 136959068 is not in [-134217728, 134217727]; references 'std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*))'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/f7fc0689b597a1fa8aed46ac0567074b/libc++.a(/Users/yxd/.cache/zig/o/f4d71cce49800e8e4296dbafe4c283f6/call_once.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::runOnFunction(llvm::Function&): .text._ZN4llvm26ScalarEvolutionWrapperPass13runOnFunctionERNS_8FunctionE+0x2c): relocation R_LARCH_B26 out of range: 137662036 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::runOnFunction(llvm::Function&): .text._ZN4llvm26ScalarEvolutionWrapperPass13runOnFunctionERNS_8FunctionE+0x1d8): relocation R_LARCH_B26 out of range: 136894760 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::TargetLibraryInfoWrapperPass::getTLI(llvm::Function const&): .text._ZN4llvm28TargetLibraryInfoWrapperPass6getTLIERKNS_8FunctionE+0x70): relocation R_LARCH_B26 out of range: 137379376 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::TargetLibraryInfoWrapperPass::getTLI(llvm::Function const&): .text._ZN4llvm28TargetLibraryInfoWrapperPass6getTLIERKNS_8FunctionE+0x104): relocation R_LARCH_B26 out of range: 136894428 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::releaseMemory(): .text._ZN4llvm26ScalarEvolutionWrapperPass13releaseMemoryEv+0x30): relocation R_LARCH_B26 out of range: 136894128 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolution::getComparePredicate(llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*): .text._ZN4llvm15ScalarEvolution19getComparePredicateENS_7CmpInst9PredicateEPKNS_4SCEVES5_+0x9c): relocation R_LARCH_B26 out of range: 137378500 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::PredicatedScalarEvolution(llvm::ScalarEvolution&, llvm::Loop&): .text._ZN4llvm25PredicatedScalarEvolutionC2ERNS_15ScalarEvolutionERNS_4LoopE+0xd0): relocation R_LARCH_B26 out of range: 137657520 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::PredicatedScalarEvolution(llvm::ScalarEvolution&, llvm::Loop&): .text._ZN4llvm25PredicatedScalarEvolutionC2ERNS_15ScalarEvolutionERNS_4LoopE+0xfc): relocation R_LARCH_B26 out of range: 137375428 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::PredicatedScalarEvolution(llvm::ScalarEvolution&, llvm::Loop&): .text._ZN4llvm25PredicatedScalarEvolutionC2ERNS_15ScalarEvolutionERNS_4LoopE+0x104): relocation R_LARCH_B26 out of range: 136890620 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::PredicatedScalarEvolution(llvm::ScalarEvolution&, llvm::Loop&): .text._ZN4llvm25PredicatedScalarEvolutionC2ERNS_15ScalarEvolutionERNS_4LoopE+0x110): relocation R_LARCH_B26 out of range: 137375408 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::getBackedgeTakenCount(): .text._ZN4llvm25PredicatedScalarEvolution21getBackedgeTakenCountEv+0x94): relocation R_LARCH_B26 out of range: 137374892 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::addPredicate(llvm::SCEVPredicate const&): .text._ZN4llvm25PredicatedScalarEvolution12addPredicateERKNS_13SCEVPredicateE+0x94): relocation R_LARCH_B26 out of range: 137489004 is not in [-134217728, 134217727]; references 'memcpy'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/fcd935fc76d674a1658962562aa74802/memcpy.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::addPredicate(llvm::SCEVPredicate const&): .text._ZN4llvm25PredicatedScalarEvolution12addPredicateERKNS_13SCEVPredicateE+0xd0): relocation R_LARCH_B26 out of range: 137656688 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::addPredicate(llvm::SCEVPredicate const&): .text._ZN4llvm25PredicatedScalarEvolution12addPredicateERKNS_13SCEVPredicateE+0xfc): relocation R_LARCH_B26 out of range: 137374596 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::addPredicate(llvm::SCEVPredicate const&): .text._ZN4llvm25PredicatedScalarEvolution12addPredicateERKNS_13SCEVPredicateE+0x104): relocation R_LARCH_B26 out of range: 136889788 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::addPredicate(llvm::SCEVPredicate const&): .text._ZN4llvm25PredicatedScalarEvolution12addPredicateERKNS_13SCEVPredicateE+0x118): relocation R_LARCH_B26 out of range: 137374568 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::getAsAddRec(llvm::Value*): .text._ZN4llvm25PredicatedScalarEvolution11getAsAddRecEPNS_5ValueE+0x158): relocation R_LARCH_B26 out of range: 137372456 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::PredicatedScalarEvolution::PredicatedScalarEvolution(llvm::PredicatedScalarEvolution const&): .text._ZN4llvm25PredicatedScalarEvolutionC2ERKS0_+0xcc): relocation R_LARCH_B26 out of range: 137654228 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::~ScalarEvolutionWrapperPass(): .text._ZN4llvm26ScalarEvolutionWrapperPassD2Ev+0x3c): relocation R_LARCH_B26 out of range: 136885892 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::~ScalarEvolutionWrapperPass(): .text._ZN4llvm26ScalarEvolutionWrapperPassD0Ev+0x3c): relocation R_LARCH_B26 out of range: 136885796 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::ScalarEvolutionWrapperPass::~ScalarEvolutionWrapperPass(): .text._ZN4llvm26ScalarEvolutionWrapperPassD0Ev+0x5c): relocation R_LARCH_B26 out of range: 136885764 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVRewriteVisitor<llvm::ScalarEvolution::getLosslessPtrToIntExpr(llvm::SCEV const*, unsigned int)::SCEVPtrToIntSinkingRewriter>::visit(llvm::SCEV const*): .text._ZN4llvm18SCEVRewriteVisitorIZNS_15ScalarEvolution23getLosslessPtrToIntExprEPKNS_4SCEVEjE27SCEVPtrToIntSinkingRewriterE5visitES4_+0x878): relocation R_LARCH_B26 out of range: 137368328 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::DenseMapBase<llvm::DenseMap<llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>>>, llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>>>::moveFromOldBuckets(llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>>*, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::SmallVector<llvm::ScalarEvolution::FoldID, 2u>>*): .text._ZN4llvm12DenseMapBaseINS_8DenseMapIPKNS_4SCEVENS_11SmallVectorINS_15ScalarEvolution6FoldIDELj2EEENS_12DenseMapInfoIS4_vEENS_6detail12DenseMapPairIS4_S8_EEEES4_S8_SA_SD_E18moveFromOldBucketsEPSD_SG_+0x104): relocation R_LARCH_B26 out of range: 137360636 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>::operator=(llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>&&): .text._ZN4llvm15SmallVectorImplINS_15ScalarEvolution6FoldIDEEaSEOS3_+0x44): relocation R_LARCH_B26 out of range: 137360412 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>::operator=(llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>&&): .text._ZN4llvm15SmallVectorImplINS_15ScalarEvolution6FoldIDEEaSEOS3_+0xd8): relocation R_LARCH_B26 out of range: 137475624 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>::operator=(llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>&&): .text._ZN4llvm15SmallVectorImplINS_15ScalarEvolution6FoldIDEEaSEOS3_+0x10c): relocation R_LARCH_B26 out of range: 137475572 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>::operator=(llvm::SmallVectorImpl<llvm::ScalarEvolution::FoldID>&&): .text._ZN4llvm15SmallVectorImplINS_15ScalarEvolution6FoldIDEEaSEOS3_+0x154): relocation R_LARCH_B26 out of range: 137474444 is not in [-134217728, 134217727]; references 'memcpy'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/fcd935fc76d674a1658962562aa74802/memcpy.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::unionSets(llvm::SCEV const* const&, llvm::SCEV const* const&): .text._ZN4llvm18EquivalenceClassesIPKNS_4SCEVENSt3__14lessIS3_EEE9unionSetsERKS3_S9_+0x7c): relocation R_LARCH_B26 out of range: 137639716 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::unionSets(llvm::SCEV const* const&, llvm::SCEV const* const&): .text._ZN4llvm18EquivalenceClassesIPKNS_4SCEVENSt3__14lessIS3_EEE9unionSetsERKS3_S9_+0x12c): relocation R_LARCH_B26 out of range: 137639540 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::StringRef::compare(llvm::StringRef) const: .text._ZNK4llvm9StringRef7compareES0_+0x30): relocation R_LARCH_B26 out of range: 137471344 is not in [-134217728, 134217727]; references 'memcmp'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3478914effcb1e2cc01948c3d54d3766/memcmp.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::unionSets(llvm::Value const* const&, llvm::Value const* const&): .text._ZN4llvm18EquivalenceClassesIPKNS_5ValueENSt3__14lessIS3_EEE9unionSetsERKS3_S9_+0x7c): relocation R_LARCH_B26 out of range: 137638948 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::unionSets(llvm::Value const* const&, llvm::Value const* const&): .text._ZN4llvm18EquivalenceClassesIPKNS_5ValueENSt3__14lessIS3_EEE9unionSetsERKS3_S9_+0x12c): relocation R_LARCH_B26 out of range: 137638772 is not in [-134217728, 134217727]; references 'operator new(unsigned long)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function void std::__1::__inplace_merge<std::__1::_ClassicAlgPolicy, GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::$_0&, llvm::SCEV const**>(llvm::SCEV const**, llvm::SCEV const**, llvm::SCEV const**, GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::$_0&, std::__1::iterator_traits<llvm::SCEV const**>::difference_type, std::__1::iterator_traits<llvm::SCEV const**>::difference_type, std::__1::iterator_traits<llvm::SCEV const**>::value_type*, long): .text._ZNSt3__115__inplace_mergeINS_17_ClassicAlgPolicyERZL17GroupByComplexityRN4llvm15SmallVectorImplIPKNS2_4SCEVEEEPNS2_8LoopInfoERNS2_13DominatorTreeEE3$_0PS6_EEvT1_SG_SG_OT0_NS_15iterator_traitsISG_E15difference_typeESL_PNSK_10value_typeEl+0x51c): relocation R_LARCH_B26 out of range: 137468740 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function std::__1::pair<llvm::SCEV const**, llvm::SCEV const**> std::__1::__rotate[abi:nn180100]<std::__1::_ClassicAlgPolicy, llvm::SCEV const**, llvm::SCEV const**>(llvm::SCEV const**, llvm::SCEV const**, llvm::SCEV const**): .text._ZNSt3__18__rotateB8nn180100INS_17_ClassicAlgPolicyEPPKN4llvm4SCEVES6_EENS_4pairIT0_S8_EES8_S8_T1_+0xa0): relocation R_LARCH_B26 out of range: 137468576 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function std::__1::pair<llvm::SCEV const**, llvm::SCEV const**> std::__1::__rotate[abi:nn180100]<std::__1::_ClassicAlgPolicy, llvm::SCEV const**, llvm::SCEV const**>(llvm::SCEV const**, llvm::SCEV const**, llvm::SCEV const**): .text._ZNSt3__18__rotateB8nn180100INS_17_ClassicAlgPolicyEPPKN4llvm4SCEVES6_EENS_4pairIT0_S8_EES8_S8_T1_+0xd0): relocation R_LARCH_B26 out of range: 137468528 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function std::__1::__tree<llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::ECValue, llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::ECValueComparator, std::__1::allocator<llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::ECValue>>::destroy(std::__1::__tree_node<llvm::EquivalenceClasses<llvm::Value const*, std::__1::less<llvm::Value const*>>::ECValue, void*>*): .text._ZNSt3__16__treeIN4llvm18EquivalenceClassesIPKNS1_5ValueENS_4lessIS5_EEE7ECValueENS8_17ECValueComparatorENS_9allocatorIS9_EEE7destroyEPNS_11__tree_nodeIS9_PvEE+0x48): relocation R_LARCH_B26 out of range: 136868088 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function std::__1::__tree<llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::ECValue, llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::ECValueComparator, std::__1::allocator<llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::ECValue>>::destroy(std::__1::__tree_node<llvm::EquivalenceClasses<llvm::SCEV const*, std::__1::less<llvm::SCEV const*>>::ECValue, void*>*): .text._ZNSt3__16__treeIN4llvm18EquivalenceClassesIPKNS1_4SCEVENS_4lessIS5_EEE7ECValueENS8_17ECValueComparatorENS_9allocatorIS9_EEE7destroyEPNS_11__tree_nodeIS9_PvEE+0x48): relocation R_LARCH_B26 out of range: 136867992 is not in [-134217728, 134217727]; references 'operator delete(void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVNAryExpr::SCEVNAryExpr(llvm::FoldingSetNodeIDRef, llvm::SCEVTypes, llvm::SCEV const* const*, unsigned long): .text._ZN4llvm12SCEVNAryExprC2ENS_19FoldingSetNodeIDRefENS_9SCEVTypesEPKPKNS_4SCEVEm+0xbc): relocation R_LARCH_B26 out of range: 136867876 is not in [-134217728, 134217727]; references 'operator delete[](void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVNAryExpr::SCEVNAryExpr(llvm::FoldingSetNodeIDRef, llvm::SCEVTypes, llvm::SCEV const* const*, unsigned long): .text._ZN4llvm12SCEVNAryExprC2ENS_19FoldingSetNodeIDRefENS_9SCEVTypesEPKPKNS_4SCEVEm+0xe4): relocation R_LARCH_B26 out of range: 136867836 is not in [-134217728, 134217727]; references 'operator delete[](void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVNAryExpr::SCEVNAryExpr(llvm::FoldingSetNodeIDRef, llvm::SCEVTypes, llvm::SCEV const* const*, unsigned long): .text._ZN4llvm12SCEVNAryExprC2ENS_19FoldingSetNodeIDRefENS_9SCEVTypesEPKPKNS_4SCEVEm+0x114): relocation R_LARCH_B26 out of range: 136867788 is not in [-134217728, 134217727]; references 'operator delete[](void*)'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/2e6614e20788627b0423a751d85c1967/libc++abi.a(/Users/yxd/.cache/zig/o/cfd2c8cfb2553000176bf62d6282e054/stdlib_new_delete.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEV const*>::operator=(llvm::SmallVectorImpl<llvm::SCEV const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_4SCEVEEaSEOS4_+0x44): relocation R_LARCH_B26 out of range: 137351996 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEV const*>::operator=(llvm::SmallVectorImpl<llvm::SCEV const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_4SCEVEEaSEOS4_+0xd0): relocation R_LARCH_B26 out of range: 137467216 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEV const*>::operator=(llvm::SmallVectorImpl<llvm::SCEV const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_4SCEVEEaSEOS4_+0xfc): relocation R_LARCH_B26 out of range: 137467172 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEV const*>::operator=(llvm::SmallVectorImpl<llvm::SCEV const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_4SCEVEEaSEOS4_+0x138): relocation R_LARCH_B26 out of range: 137466056 is not in [-134217728, 134217727]; references 'memcpy'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/fcd935fc76d674a1658962562aa74802/memcpy.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function (anonymous namespace)::SCEVSequentialMinMaxDeduplicatingVisitor::visitAnyMinMaxExpr(llvm::SCEV const*): .text._ZN12_GLOBAL__N_140SCEVSequentialMinMaxDeduplicatingVisitor18visitAnyMinMaxExprEPKN4llvm4SCEVE+0xb8): relocation R_LARCH_B26 out of range: 137351496 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEVPredicate const*>::operator=(llvm::SmallVectorImpl<llvm::SCEVPredicate const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_13SCEVPredicateEEaSEOS4_+0x44): relocation R_LARCH_B26 out of range: 137351196 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEVPredicate const*>::operator=(llvm::SmallVectorImpl<llvm::SCEVPredicate const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_13SCEVPredicateEEaSEOS4_+0xd0): relocation R_LARCH_B26 out of range: 137466416 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEVPredicate const*>::operator=(llvm::SmallVectorImpl<llvm::SCEVPredicate const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_13SCEVPredicateEEaSEOS4_+0xfc): relocation R_LARCH_B26 out of range: 137466372 is not in [-134217728, 134217727]; references 'memmove'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/90686cfe11de810cb79968b91a5344af/memmove.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SmallVectorImpl<llvm::SCEVPredicate const*>::operator=(llvm::SmallVectorImpl<llvm::SCEVPredicate const*>&&): .text._ZN4llvm15SmallVectorImplIPKNS_13SCEVPredicateEEaSEOS4_+0x138): relocation R_LARCH_B26 out of range: 137465256 is not in [-134217728, 134217727]; references 'memcpy'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/fcd935fc76d674a1658962562aa74802/memcpy.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVRewriteVisitor<(anonymous namespace)::SCEVBackedgeConditionFolder>::visit(llvm::SCEV const*): .text._ZN4llvm18SCEVRewriteVisitorIN12_GLOBAL__N_127SCEVBackedgeConditionFolderEE5visitEPKNS_4SCEVE+0x9b8): relocation R_LARCH_B26 out of range: 137348040 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVRewriteVisitor<(anonymous namespace)::SCEVShiftRewriter>::visit(llvm::SCEV const*): .text._ZN4llvm18SCEVRewriteVisitorIN12_GLOBAL__N_117SCEVShiftRewriterEE5visitEPKNS_4SCEVE+0x910): relocation R_LARCH_B26 out of range: 137345200 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: ld.lld: /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib/libLLVMAnalysis.a(ScalarEvolution.cpp.o):(function llvm::SCEVRewriteVisitor<(anonymous namespace)::SCEVInitRewriter>::visit(llvm::SCEV const*): .text._ZN4llvm18SCEVRewriteVisitorIN12_GLOBAL__N_116SCEVInitRewriterEE5visitEPKNS_4SCEVE+0x8d8): relocation R_LARCH_B26 out of range: 137342824 is not in [-134217728, 134217727]; references 'free'
    note: referenced by ScalarEvolution.cpp
    note: defined in /Users/yxd/.cache/zig/o/287f85cbc52fa6f2f100ca397380bc71/libc.a(/Users/yxd/.cache/zig/o/3fbf503061bdda3ca9a2c0cd7d52239a/free.o)
error: the following command failed with 21335 compilation errors:
/Users/yxd/playspace/zig-bootstrap/out/host/bin/zig build-exe --stack 33554432 -cflags -std=c++17 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -DNDEBUG=1 -- /Users/yxd/playspace/zig-bootstrap/zig/src/zig_llvm.cpp /Users/yxd/playspace/zig-bootstrap/zig/src/zig_clang.cpp /Users/yxd/playspace/zig-bootstrap/zig/src/zig_llvm-ar.cpp /Users/yxd/playspace/zig-bootstrap/zig/src/zig_clang_driver.cpp /Users/yxd/playspace/zig-bootstrap/zig/src/zig_clang_cc1_main.cpp /Users/yxd/playspace/zig-bootstrap/zig/src/zig_clang_cc1as_main.cpp -lclangFrontendTool -lclangCodeGen -lclangFrontend -lclangDriver -lclangSerialization -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangASTMatchers -lclangAST -lclangParse -lclangAPINotes -lclangBasic -lclangEdit -lclangLex -lclangARCMigrate -lclangRewriteFrontend -lclangRewrite -lclangCrossTU -lclangIndex -lclangToolingCore -lclangExtractAPI -lclangSupport -llldMinGW -llldELF -llldCOFF -llldWasm -llldMachO -llldCommon -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMTextAPIBinaryReader -lLLVMCoverage -lLLVMLineEditor -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86TargetMCA -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyUtils -lLLVMWebAssemblyDesc -lLLVMWebAssemblyInfo -lLLVMVEDisassembler -lLLVMVEAsmParser -lLLVMVECodeGen -lLLVMVEDesc -lLLVMVEInfo -lLLVMSystemZDisassembler -lLLVMSystemZAsmParser -lLLVMSystemZCodeGen -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcAsmParser -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVTargetMCA -lLLVMRISCVDisassembler -lLLVMRISCVAsmParser -lLLVMRISCVCodeGen -lLLVMRISCVDesc -lLLVMRISCVInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCAsmParser -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430AsmParser -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsAsmParser -lLLVMMipsCodeGen -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLoongArchDisassembler -lLLVMLoongArchAsmParser -lLLVMLoongArchCodeGen -lLLVMLoongArchDesc -lLLVMLoongArchInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFAsmParser -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMAVRDisassembler -lLLVMAVRAsmParser -lLLVMAVRCodeGen -lLLVMAVRDesc -lLLVMAVRInfo -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUTargetMCA -lLLVMAMDGPUDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAArch64Disassembler -lLLVMAArch64AsmParser -lLLVMAArch64CodeGen -lLLVMAArch64Desc -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMOrcDebugging -lLLVMOrcJIT -lLLVMWindowsDriver -lLLVMMCJIT -lLLVMJITLink -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMOrcTargetProcess -lLLVMOrcShared -lLLVMDWP -lLLVMDebugInfoLogicalView -lLLVMDebugInfoGSYM -lLLVMOption -lLLVMObjectYAML -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMHipStdPar -lLLVMCFGuard -lLLVMCoroutines -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMInstrumentation -lLLVMFrontendOpenMP -lLLVMFrontendOffloading -lLLVMFrontendOpenACC -lLLVMFrontendHLSL -lLLVMFrontendDriver -lLLVMExtensions -lLLVMDWARFLinkerParallel -lLLVMDWARFLinkerClassic -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLLVMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMTarget -lLLVMObjCARCOpts -lLLVMCodeGenTypes -lLLVMIRPrinter -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoBTF -lLLVMDebugInfoPDB -lLLVMDebugInfoMSF -lLLVMDebugInfoDWARF -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMIRReader -lLLVMAsmParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMSupport -lLLVMDemangle -lz -lzstd -fno-sanitize-thread -ODebug -target loongarch64-linux-musl -mcpu loongarch64 --dep aro --dep aro_translate_c --dep build_options -Mroot=/Users/yxd/playspace/zig-bootstrap/zig/src/main.zig -Maro=/Users/yxd/playspace/zig-bootstrap/zig/lib/compiler/aro/aro.zig --dep aro -Maro_translate_c=/Users/yxd/playspace/zig-bootstrap/zig/lib/compiler/aro_translate_c.zig -Mbuild_options=/Users/yxd/playspace/zig-bootstrap/zig/.zig-cache/c/37227e6700df4386fb439425755f2bbc/options.zig -lc++ -lc --cache-dir /Users/yxd/playspace/zig-bootstrap/zig/.zig-cache --global-cache-dir /Users/yxd/.cache/zig --name zig -L /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/lib -I /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64/include --zig-lib-dir /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/ --listen=-
Build Summary: 285/288 steps succeeded; 1 failed
install transitive failure
└─ install zig transitive failure
   └─ zig build-exe zig Debug loongarch64-linux-musl 21335 errors
error: the following build command failed with exit code 1:
/Users/yxd/playspace/zig-bootstrap/zig/.zig-cache/o/21171db1288a534e03a4f0f80fc478eb/build /Users/yxd/playspace/zig-bootstrap/out/host/bin/zig /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig /Users/yxd/playspace/zig-bootstrap/zig /Users/yxd/playspace/zig-bootstrap/zig/.zig-cache /Users/yxd/.cache/zig --seed 0xba6e061 -Zea65d983022a4876 --prefix /Users/yxd/playspace/zig-bootstrap/out/zig-loongarch64-linux-musl-loongarch64 --search-prefix /Users/yxd/playspace/zig-bootstrap/out/loongarch64-linux-musl-loongarch64 -Dflat -Dstatic-llvm -Doptimize=Debug -Dtarget=loongarch64-linux-musl -Dcpu=loongarch64 -Dversion-string=0.14.0-dev.1294+df6907f60

@yxd-ym yxd-ym changed the title loongarch: use medium code model loongarch: use medium code model for zig binary Aug 24, 2024
@yxd-ym
Copy link
Contributor Author

yxd-ym commented Aug 24, 2024

Is it just that the Zig binary is so big that the relocations in the default code model don't have enough range?

I think this is the reason of the above error.

@yxd-ym yxd-ym changed the title loongarch: use medium code model for zig binary loongarch: use medium code model for zig loongarch64 binary Aug 24, 2024
@alexrp
Copy link
Member

alexrp commented Aug 24, 2024

Ok, so it's an issue specific to building the zig binary because it's so big. Then editing build.zig seems to be the right call to me; editing src/Package/Module.zig would, AFAICT, mean we're imposing a larger-than-necessary default code model on all binaries. What do you think @andrewrk?

build.zig Outdated Show resolved Hide resolved
@rohlem
Copy link
Contributor

rohlem commented Aug 25, 2024

It seems like any project could hit this limitation if its code grows beyond a certain threshold.
Would it be possible to add some kind of detection, so that Zig could inform the user "the resulting binary is too large for the selected code model, use -mcmodel=(medium|large)"?

@alexrp
Copy link
Member

alexrp commented Aug 25, 2024

It seems like any project could hit this limitation if its code grows beyond a certain threshold.

Yes, but that's true of code models on all architectures, not just on LoongArch. It's a trade-off between code size & performance vs upper limit on binary size. Each target has a different default code model - LoongArch just happens to have a relatively small one.

Would it be possible to add some kind of detection

You can't know that you've hit the binary size limit until link time. That said, a linker could probably suggest trying a larger code model when running into relocation range issues.

Copy link
Member

@alexrp alexrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; as I noted here, I don't think this is something that requires backend changes - it's just that the zig binary in particular is very large.

@andrewrk
Copy link
Member

andrewrk commented Sep 1, 2024

Thank you all

@andrewrk andrewrk merged commit c34cfe4 into ziglang:master Sep 1, 2024
10 checks passed
@yxd-ym yxd-ym deleted the use-medium-code-model branch September 1, 2024 06:47
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

Successfully merging this pull request may close these issues.

4 participants