zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f29bdd6746691d0a547140e435056a000419480f (tree)
parent 96fcc8d63bf8391e5cf2246e9427e9ab56399d86
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Fri,  6 Sep 2024 10:55:45 -0700

Merge pull request #21263 from alexrp/thumb-fixes

Some fixes for `thumb-linux-*` support
Diffstat:
Mlib/std/start.zig | 4+++-
Msrc/Compilation.zig | 16++++++++--------
Msrc/musl.zig | 5+++++
3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/std/start.zig b/lib/std/start.zig @@ -283,7 +283,9 @@ fn _start() callconv(.Naked) noreturn { \\ mov fp, #0 \\ mov lr, #0 \\ mov a1, sp - \\ and sp, #-16 + \\ mov ip, sp + \\ and ip, ip, #-16 + \\ mov sp, ip \\ b %[posixCallMainAndExit] , .csky => diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -5536,10 +5536,6 @@ pub fn addCCArgs( else => {}, } - if (target.cpu.arch.isThumb()) { - try argv.append("-mthumb"); - } - { var san_arg: std.ArrayListUnmanaged(u8) = .{}; const prefix = "-fsanitize="; @@ -5636,10 +5632,6 @@ pub fn addCCArgs( try argv.append("-Werror=date-time"); } - if (target_util.supports_fpic(target) and mod.pic) { - try argv.append("-fPIC"); - } - if (mod.unwind_tables) { try argv.append("-funwind-tables"); } else { @@ -5730,6 +5722,14 @@ pub fn addCCArgs( }, } + if (target.cpu.arch.isThumb()) { + try argv.append("-mthumb"); + } + + if (target_util.supports_fpic(target) and mod.pic) { + try argv.append("-fPIC"); + } + try argv.ensureUnusedCapacity(2); switch (comp.config.debug_format) { .strip => {}, diff --git a/src/musl.zig b/src/musl.zig @@ -384,6 +384,7 @@ fn addCcArgs( try args.appendSlice(&[_][]const u8{ "-std=c99", "-ffreestanding", + "-fno-builtin", "-fexcess-precision=standard", "-frounding-math", "-fno-strict-aliasing", @@ -422,6 +423,10 @@ fn addCcArgs( "-Qunused-arguments", "-w", // disable all warnings }); + + if (target.cpu.arch.isThumb()) { + try args.append("-mimplicit-it=always"); + } } fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {