| ... | @@ -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; |