authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-06 10:55:45-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-09-06 10:55:45-07:00
logf29bdd6746691d0a547140e435056a000419480f
tree0ca346e932f845c4dc710dc00484c3c3b64c20e4
parent96fcc8d63bf8391e5cf2246e9427e9ab56399d86
parent0ecc6332b4eb1ced547ffa38f57471134aaa4d13
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21263 from alexrp/thumb-fixes

Some fixes for `thumb-linux-*` support

3 files changed, 16 insertions(+), 9 deletions(-)

lib/std/start.zig+3-1
...@@ -283,7 +283,9 @@ fn _start() callconv(.Naked) noreturn {...@@ -283,7 +283,9 @@ fn _start() callconv(.Naked) noreturn {
283 \\ mov fp, #0283 \\ mov fp, #0
284 \\ mov lr, #0284 \\ mov lr, #0
285 \\ mov a1, sp285 \\ mov a1, sp
286 \\ and sp, #-16286 \\ mov ip, sp
287 \\ and ip, ip, #-16
288 \\ mov sp, ip
287 \\ b %[posixCallMainAndExit]289 \\ b %[posixCallMainAndExit]
288 ,290 ,
289 .csky =>291 .csky =>
src/Compilation.zig+8-8
...@@ -5536,10 +5536,6 @@ pub fn addCCArgs(...@@ -5536,10 +5536,6 @@ pub fn addCCArgs(
5536 else => {},5536 else => {},
5537 }5537 }
55385538
5539 if (target.cpu.arch.isThumb()) {
5540 try argv.append("-mthumb");
5541 }
5542
5543 {5539 {
5544 var san_arg: std.ArrayListUnmanaged(u8) = .{};5540 var san_arg: std.ArrayListUnmanaged(u8) = .{};
5545 const prefix = "-fsanitize=";5541 const prefix = "-fsanitize=";
...@@ -5636,10 +5632,6 @@ pub fn addCCArgs(...@@ -5636,10 +5632,6 @@ pub fn addCCArgs(
5636 try argv.append("-Werror=date-time");5632 try argv.append("-Werror=date-time");
5637 }5633 }
56385634
5639 if (target_util.supports_fpic(target) and mod.pic) {
5640 try argv.append("-fPIC");
5641 }
5642
5643 if (mod.unwind_tables) {5635 if (mod.unwind_tables) {
5644 try argv.append("-funwind-tables");5636 try argv.append("-funwind-tables");
5645 } else {5637 } else {
...@@ -5730,6 +5722,14 @@ pub fn addCCArgs(...@@ -5730,6 +5722,14 @@ pub fn addCCArgs(
5730 },5722 },
5731 }5723 }
57325724
5725 if (target.cpu.arch.isThumb()) {
5726 try argv.append("-mthumb");
5727 }
5728
5729 if (target_util.supports_fpic(target) and mod.pic) {
5730 try argv.append("-fPIC");
5731 }
5732
5733 try argv.ensureUnusedCapacity(2);5733 try argv.ensureUnusedCapacity(2);
5734 switch (comp.config.debug_format) {5734 switch (comp.config.debug_format) {
5735 .strip => {},5735 .strip => {},
src/musl.zig+5
...@@ -384,6 +384,7 @@ fn addCcArgs(...@@ -384,6 +384,7 @@ fn addCcArgs(
384 try args.appendSlice(&[_][]const u8{384 try args.appendSlice(&[_][]const u8{
385 "-std=c99",385 "-std=c99",
386 "-ffreestanding",386 "-ffreestanding",
387 "-fno-builtin",
387 "-fexcess-precision=standard",388 "-fexcess-precision=standard",
388 "-frounding-math",389 "-frounding-math",
389 "-fno-strict-aliasing",390 "-fno-strict-aliasing",
...@@ -422,6 +423,10 @@ fn addCcArgs(...@@ -422,6 +423,10 @@ fn addCcArgs(
422 "-Qunused-arguments",423 "-Qunused-arguments",
423 "-w", // disable all warnings424 "-w", // disable all warnings
424 });425 });
426
427 if (target.cpu.arch.isThumb()) {
428 try args.append("-mimplicit-it=always");
429 }
425}430}
426431
427fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {432fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {