| author | |
| committer | |
| log | 16f09127b5796b21f960b836d715ba2cc84ae07e |
| tree | 850c6f78b1a93ada946ea56267a090b4ddbfcecb |
| parent | d6e095de2c7b2c625a09e50b11e546191dc6e7bd |
5 files changed, 120 insertions(+), 0 deletions(-)
test/link.zig+4| ... | @@ -96,6 +96,10 @@ pub const cases = [_]Case{ | ... | @@ -96,6 +96,10 @@ pub const cases = [_]Case{ |
| 96 | .build_root = "test/link/macho/bugs/16308", | 96 | .build_root = "test/link/macho/bugs/16308", |
| 97 | .import = @import("link/macho/bugs/16308/build.zig"), | 97 | .import = @import("link/macho/bugs/16308/build.zig"), |
| 98 | }, | 98 | }, |
| 99 | .{ | ||
| 100 | .build_root = "test/link/macho/bugs/16628", | ||
| 101 | .import = @import("link/macho/bugs/16628/build.zig"), | ||
| 102 | }, | ||
| 99 | .{ | 103 | .{ |
| 100 | .build_root = "test/link/macho/dead_strip", | 104 | .build_root = "test/link/macho/dead_strip", |
| 101 | .import = @import("link/macho/dead_strip/build.zig"), | 105 | .import = @import("link/macho/dead_strip/build.zig"), |
test/link/macho/bugs/16628/a_arm64.s created+37| ... | @@ -0,0 +1,37 @@ | ||
| 1 | .globl _foo | ||
| 2 | .align 4 | ||
| 3 | _foo: | ||
| 4 | .cfi_startproc | ||
| 5 | stp x29, x30, [sp, #-32]! | ||
| 6 | .cfi_def_cfa_offset 32 | ||
| 7 | .cfi_offset w30, -24 | ||
| 8 | .cfi_offset w29, -32 | ||
| 9 | mov x29, sp | ||
| 10 | .cfi_def_cfa w29, 32 | ||
| 11 | bl _bar | ||
| 12 | ldp x29, x30, [sp], #32 | ||
| 13 | .cfi_restore w29 | ||
| 14 | .cfi_restore w30 | ||
| 15 | .cfi_def_cfa_offset 0 | ||
| 16 | ret | ||
| 17 | .cfi_endproc | ||
| 18 | |||
| 19 | .globl _bar | ||
| 20 | .align 4 | ||
| 21 | _bar: | ||
| 22 | .cfi_startproc | ||
| 23 | sub sp, sp, #32 | ||
| 24 | .cfi_def_cfa_offset -32 | ||
| 25 | stp x29, x30, [sp, #16] | ||
| 26 | .cfi_offset w30, -24 | ||
| 27 | .cfi_offset w29, -32 | ||
| 28 | mov x29, sp | ||
| 29 | .cfi_def_cfa w29, 32 | ||
| 30 | mov w0, #4 | ||
| 31 | ldp x29, x30, [sp, #16] | ||
| 32 | .cfi_restore w29 | ||
| 33 | .cfi_restore w30 | ||
| 34 | add sp, sp, #32 | ||
| 35 | .cfi_def_cfa_offset 0 | ||
| 36 | ret | ||
| 37 | .cfi_endproc | ||
test/link/macho/bugs/16628/a_x64.s created+29| ... | @@ -0,0 +1,29 @@ | ||
| 1 | .globl _foo | ||
| 2 | _foo: | ||
| 3 | .cfi_startproc | ||
| 4 | push %rbp | ||
| 5 | .cfi_def_cfa_offset 8 | ||
| 6 | .cfi_offset %rbp, -8 | ||
| 7 | mov %rsp, %rbp | ||
| 8 | .cfi_def_cfa_register %rbp | ||
| 9 | call _bar | ||
| 10 | pop %rbp | ||
| 11 | .cfi_restore %rbp | ||
| 12 | .cfi_def_cfa_offset 0 | ||
| 13 | ret | ||
| 14 | .cfi_endproc | ||
| 15 | |||
| 16 | .globl _bar | ||
| 17 | _bar: | ||
| 18 | .cfi_startproc | ||
| 19 | push %rbp | ||
| 20 | .cfi_def_cfa_offset 8 | ||
| 21 | .cfi_offset %rbp, -8 | ||
| 22 | mov %rsp, %rbp | ||
| 23 | .cfi_def_cfa_register %rbp | ||
| 24 | mov $4, %rax | ||
| 25 | pop %rbp | ||
| 26 | .cfi_restore %rbp | ||
| 27 | .cfi_def_cfa_offset 0 | ||
| 28 | ret | ||
| 29 | .cfi_endproc | ||
test/link/macho/bugs/16628/build.zig created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | pub const requires_symlinks = true; | ||
| 5 | pub const requires_macos_sdk = false; | ||
| 6 | |||
| 7 | pub fn build(b: *std.Build) void { | ||
| 8 | const test_step = b.step("test", "Test it"); | ||
| 9 | b.default_step = test_step; | ||
| 10 | |||
| 11 | add(b, test_step, .Debug); | ||
| 12 | add(b, test_step, .ReleaseFast); | ||
| 13 | add(b, test_step, .ReleaseSmall); | ||
| 14 | add(b, test_step, .ReleaseSafe); | ||
| 15 | } | ||
| 16 | |||
| 17 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 18 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 19 | |||
| 20 | const exe = b.addExecutable(.{ | ||
| 21 | .name = "test", | ||
| 22 | .optimize = optimize, | ||
| 23 | .target = target, | ||
| 24 | }); | ||
| 25 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} }); | ||
| 26 | switch (builtin.cpu.arch) { | ||
| 27 | .aarch64 => { | ||
| 28 | exe.addCSourceFile(.{ .file = .{ .path = "a_arm64.s" }, .flags = &[0][]const u8{} }); | ||
| 29 | }, | ||
| 30 | .x86_64 => { | ||
| 31 | exe.addCSourceFile(.{ .file = .{ .path = "a_x64.s" }, .flags = &[0][]const u8{} }); | ||
| 32 | }, | ||
| 33 | else => unreachable, | ||
| 34 | } | ||
| 35 | exe.linkLibC(); | ||
| 36 | |||
| 37 | const run = b.addRunArtifact(exe); | ||
| 38 | run.skip_foreign_checks = true; | ||
| 39 | run.expectStdOutEqual("4\n"); | ||
| 40 | |||
| 41 | test_step.dependOn(&run.step); | ||
| 42 | } | ||
test/link/macho/bugs/16628/main.c created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | int foo(); | ||
| 4 | |||
| 5 | int main() { | ||
| 6 | printf("%d\n", foo()); | ||
| 7 | return 0; | ||
| 8 | } | ||