| ... | @@ -99,6 +99,7 @@ pub fn build(b: *Build) void { | ... | @@ -99,6 +99,7 @@ pub fn build(b: *Build) void { |
| 99 | elf_step.dependOn(testTlsOffsetAlignment(b, .{ .target = glibc_target })); | 99 | elf_step.dependOn(testTlsOffsetAlignment(b, .{ .target = glibc_target })); |
| 100 | elf_step.dependOn(testTlsPic(b, .{ .target = glibc_target })); | 100 | elf_step.dependOn(testTlsPic(b, .{ .target = glibc_target })); |
| 101 | elf_step.dependOn(testTlsSmallAlignment(b, .{ .target = glibc_target })); | 101 | elf_step.dependOn(testTlsSmallAlignment(b, .{ .target = glibc_target })); |
| | 102 | elf_step.dependOn(testUnresolved(b, .{ .target = glibc_target })); |
| 102 | elf_step.dependOn(testWeakExports(b, .{ .target = glibc_target })); | 103 | elf_step.dependOn(testWeakExports(b, .{ .target = glibc_target })); |
| 103 | elf_step.dependOn(testWeakUndefsDso(b, .{ .target = glibc_target })); | 104 | elf_step.dependOn(testWeakUndefsDso(b, .{ .target = glibc_target })); |
| 104 | elf_step.dependOn(testZNow(b, .{ .target = glibc_target })); | 105 | elf_step.dependOn(testZNow(b, .{ .target = glibc_target })); |
| ... | @@ -2783,6 +2784,44 @@ fn testTlsStatic(b: *Build, opts: Options) *Step { | ... | @@ -2783,6 +2784,44 @@ fn testTlsStatic(b: *Build, opts: Options) *Step { |
| 2783 | return test_step; | 2784 | return test_step; |
| 2784 | } | 2785 | } |
| 2785 | | 2786 | |
| | 2787 | fn testUnresolved(b: *Build, opts: Options) *Step { |
| | 2788 | const test_step = addTestStep(b, "unresolved", opts); |
| | 2789 | |
| | 2790 | const obj1 = addObject(b, "a", opts); |
| | 2791 | addCSourceBytes(obj1, |
| | 2792 | \\#include <stdio.h> |
| | 2793 | \\int foo(); |
| | 2794 | \\int bar() { |
| | 2795 | \\ return foo() + 1; |
| | 2796 | \\} |
| | 2797 | , &.{"-ffunction-sections"}); |
| | 2798 | obj1.linkLibC(); |
| | 2799 | |
| | 2800 | const obj2 = addObject(b, "b", opts); |
| | 2801 | addCSourceBytes(obj2, |
| | 2802 | \\#include <stdio.h> |
| | 2803 | \\int foo(); |
| | 2804 | \\int bar(); |
| | 2805 | \\int main() { |
| | 2806 | \\ return foo() + bar(); |
| | 2807 | \\} |
| | 2808 | , &.{"-ffunction-sections"}); |
| | 2809 | obj2.linkLibC(); |
| | 2810 | |
| | 2811 | const exe = addExecutable(b, "main", opts); |
| | 2812 | exe.addObject(obj1); |
| | 2813 | exe.addObject(obj2); |
| | 2814 | exe.linkLibC(); |
| | 2815 | |
| | 2816 | expectLinkErrors(exe, test_step, &.{ |
| | 2817 | "error: undefined symbol: foo", |
| | 2818 | "note: referenced by /?/a.o:.text.bar", |
| | 2819 | "note: referenced by /?/b.o:.text.main", |
| | 2820 | }); |
| | 2821 | |
| | 2822 | return test_step; |
| | 2823 | } |
| | 2824 | |
| 2786 | fn testWeakExports(b: *Build, opts: Options) *Step { | 2825 | fn testWeakExports(b: *Build, opts: Options) *Step { |
| 2787 | const test_step = addTestStep(b, "weak-exports", opts); | 2826 | const test_step = addTestStep(b, "weak-exports", opts); |
| 2788 | | 2827 | |
| ... | @@ -3081,6 +3120,12 @@ fn addAsmSourceBytes(comp: *Compile, bytes: []const u8) void { | ... | @@ -3081,6 +3120,12 @@ fn addAsmSourceBytes(comp: *Compile, bytes: []const u8) void { |
| 3081 | comp.addAssemblyFile(file); | 3120 | comp.addAssemblyFile(file); |
| 3082 | } | 3121 | } |
| 3083 | | 3122 | |
| | 3123 | fn expectLinkErrors(comp: *Compile, test_step: *Step, expected_errors: []const []const u8) void { |
| | 3124 | comp.expect_errors = expected_errors; |
| | 3125 | const bin_file = comp.getEmittedBin(); |
| | 3126 | bin_file.addStepDependencies(test_step); |
| | 3127 | } |
| | 3128 | |
| 3084 | const std = @import("std"); | 3129 | const std = @import("std"); |
| 3085 | | 3130 | |
| 3086 | const Build = std.Build; | 3131 | const Build = std.Build; |