| ... | @@ -94,6 +94,8 @@ pub fn testAll(b: *Build) *Step { | ... | @@ -94,6 +94,8 @@ pub fn testAll(b: *Build) *Step { |
| 94 | elf_step.dependOn(testLinkOrder(b, .{ .target = glibc_target })); | 94 | elf_step.dependOn(testLinkOrder(b, .{ .target = glibc_target })); |
| 95 | elf_step.dependOn(testLdScript(b, .{ .target = glibc_target })); | 95 | elf_step.dependOn(testLdScript(b, .{ .target = glibc_target })); |
| 96 | elf_step.dependOn(testLdScriptPathError(b, .{ .target = glibc_target })); | 96 | elf_step.dependOn(testLdScriptPathError(b, .{ .target = glibc_target })); |
| | 97 | elf_step.dependOn(testLdScriptAllowUndefinedVersion(b, .{ .target = glibc_target, .use_lld = true })); |
| | 98 | elf_step.dependOn(testLdScriptDisallowUndefinedVersion(b, .{ .target = glibc_target, .use_lld = true })); |
| 97 | elf_step.dependOn(testMismatchedCpuArchitectureError(b, .{ .target = glibc_target })); | 99 | elf_step.dependOn(testMismatchedCpuArchitectureError(b, .{ .target = glibc_target })); |
| 98 | // https://github.com/ziglang/zig/issues/17451 | 100 | // https://github.com/ziglang/zig/issues/17451 |
| 99 | // elf_step.dependOn(testNoEhFrameHdr(b, .{ .target = glibc_target })); | 101 | // elf_step.dependOn(testNoEhFrameHdr(b, .{ .target = glibc_target })); |
| ... | @@ -2008,6 +2010,67 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step { | ... | @@ -2008,6 +2010,67 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step { |
| 2008 | return test_step; | 2010 | return test_step; |
| 2009 | } | 2011 | } |
| 2010 | | 2012 | |
| | 2013 | fn testLdScriptAllowUndefinedVersion(b: *Build, opts: Options) *Step { |
| | 2014 | const test_step = addTestStep(b, "ld-script-allow-undefined-version", opts); |
| | 2015 | |
| | 2016 | const so = addSharedLibrary(b, opts, .{ |
| | 2017 | .name = "add", |
| | 2018 | .zig_source_bytes = |
| | 2019 | \\export fn add(a: i32, b: i32) i32 { |
| | 2020 | \\ return a + b; |
| | 2021 | \\} |
| | 2022 | , |
| | 2023 | }); |
| | 2024 | const ld = b.addWriteFiles().add("add.ld", "VERSION { ADD_1.0 { global: add; sub; local: *; }; }"); |
| | 2025 | so.setLinkerScript(ld); |
| | 2026 | so.linker_allow_undefined_version = true; |
| | 2027 | |
| | 2028 | const exe = addExecutable(b, opts, .{ |
| | 2029 | .name = "main", |
| | 2030 | .zig_source_bytes = |
| | 2031 | \\const std = @import("std"); |
| | 2032 | \\extern fn add(a: i32, b: i32) i32; |
| | 2033 | \\pub fn main() void { |
| | 2034 | \\ std.debug.print("{d}\n", .{add(1, 2)}); |
| | 2035 | \\} |
| | 2036 | , |
| | 2037 | }); |
| | 2038 | exe.linkLibrary(so); |
| | 2039 | exe.linkLibC(); |
| | 2040 | |
| | 2041 | const run = addRunArtifact(exe); |
| | 2042 | run.expectStdErrEqual("3\n"); |
| | 2043 | test_step.dependOn(&run.step); |
| | 2044 | |
| | 2045 | return test_step; |
| | 2046 | } |
| | 2047 | |
| | 2048 | fn testLdScriptDisallowUndefinedVersion(b: *Build, opts: Options) *Step { |
| | 2049 | const test_step = addTestStep(b, "ld-script-disallow-undefined-version", opts); |
| | 2050 | |
| | 2051 | const so = addSharedLibrary(b, opts, .{ |
| | 2052 | .name = "add", |
| | 2053 | .zig_source_bytes = |
| | 2054 | \\export fn add(a: i32, b: i32) i32 { |
| | 2055 | \\ return a + b; |
| | 2056 | \\} |
| | 2057 | , |
| | 2058 | }); |
| | 2059 | const ld = b.addWriteFiles().add("add.ld", "VERSION { ADD_1.0 { global: add; sub; local: *; }; }"); |
| | 2060 | so.setLinkerScript(ld); |
| | 2061 | so.linker_allow_undefined_version = false; |
| | 2062 | |
| | 2063 | expectLinkErrors( |
| | 2064 | so, |
| | 2065 | test_step, |
| | 2066 | .{ |
| | 2067 | .contains = "error: ld.lld: version script assignment of 'ADD_1.0' to symbol 'sub' failed: symbol not defined", |
| | 2068 | }, |
| | 2069 | ); |
| | 2070 | |
| | 2071 | return test_step; |
| | 2072 | } |
| | 2073 | |
| 2011 | fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step { | 2074 | fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step { |
| 2012 | const test_step = addTestStep(b, "mismatched-cpu-architecture-error", opts); | 2075 | const test_step = addTestStep(b, "mismatched-cpu-architecture-error", opts); |
| 2013 | | 2076 | |