authorgravatar for yangxudong@ymatrix.cnYANG Xudong <yangxudong@ymatrix.cn> 2024-09-01 11:59:24+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-31 20:59:24-07:00
logc34cfe486d70ac5e92f101a47fc70a1336077e7e
tree5f7bbcec3259be63127801a93b5deeebeffb739a
parent96daca7b3b6f02033e68ac91776bf6e8d2b67409
signaturebadge-check Signed by PGP key B5690EEEBB952194

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


1 files changed, 18 insertions(+), 0 deletions(-)

build.zig+18
...@@ -647,6 +647,24 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St...@@ -647,6 +647,24 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
647 .strip = options.strip,647 .strip = options.strip,
648 .sanitize_thread = options.sanitize_thread,648 .sanitize_thread = options.sanitize_thread,
649 .single_threaded = options.single_threaded,649 .single_threaded = options.single_threaded,
650 .code_model = switch (options.target.result.cpu.arch) {
651 // NB:
652 // For loongarch, LLVM supports only small, medium and large
653 // code model. If we don't explicitly specify the code model,
654 // the default value `small' will be used.
655 //
656 // Since zig binary itself is relatively large, using a `small'
657 // code model will cause
658 //
659 // relocation R_LARCH_B26 out of range
660 //
661 // error when linking a loongarch64 zig binary.
662 //
663 // Here we explicitly set code model to `medium' to avoid this
664 // error.
665 .loongarch64 => .medium,
666 else => .default,
667 },
650 });668 });
651 exe.root_module.valgrind = options.valgrind;669 exe.root_module.valgrind = options.valgrind;
652 exe.stack_size = stack_size;670 exe.stack_size = stack_size;