Skip to content

Commit

Permalink
Merge pull request #21263 from alexrp/thumb-fixes
Browse files Browse the repository at this point in the history
Some fixes for `thumb-linux-*` support
  • Loading branch information
andrewrk committed Sep 6, 2024
2 parents 96fcc8d + 0ecc633 commit f29bdd6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/std/start.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
16 changes: 8 additions & 8 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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=";
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 => {},
Expand Down
5 changes: 5 additions & 0 deletions src/musl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ fn addCcArgs(
try args.appendSlice(&[_][]const u8{
"-std=c99",
"-ffreestanding",
"-fno-builtin",
"-fexcess-precision=standard",
"-frounding-math",
"-fno-strict-aliasing",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f29bdd6

Please sign in to comment.