authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-27 02:53:40-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-27 10:31:52-04:00
log8b9627f01d44b94fad744f6d515dc32438130628
treef6e84217af1abced5e910ea3a6d83e4f06ad68b7
parent78449b6d980fc78d418f9b44d815781eda7587f7

test: add a test that verifies no debug handlers get pulled into compiler_rt

build: fix CheckObject checkNotPresent only checking a single line of the haystack

4 files changed, 42 insertions(+), 2 deletions(-)

lib/std/Build/Step/CheckObject.zig+1-2
...@@ -478,8 +478,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -478,8 +478,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
478 },478 },
479 .not_present => {479 .not_present => {
480 while (it.next()) |line| {480 while (it.next()) |line| {
481 if (act.notPresent(b, step, line)) break;481 if (act.notPresent(b, step, line)) continue;
482 } else {
483 return step.fail(482 return step.fail(
484 \\483 \\
485 \\========= expected not to find: ===================484 \\========= expected not to find: ===================
test/standalone.zig+4
...@@ -241,6 +241,10 @@ pub const build_cases = [_]BuildCase{...@@ -241,6 +241,10 @@ pub const build_cases = [_]BuildCase{
241 .build_root = "test/standalone/coff_dwarf",241 .build_root = "test/standalone/coff_dwarf",
242 .import = @import("standalone/coff_dwarf/build.zig"),242 .import = @import("standalone/coff_dwarf/build.zig"),
243 },243 },
244 .{
245 .build_root = "test/standalone/compiler_rt_panic",
246 .import = @import("standalone/compiler_rt_panic/build.zig"),
247 },
244};248};
245249
246const std = @import("std");250const std = @import("std");
test/standalone/compiler_rt_panic/build.zig created+26
...@@ -0,0 +1,26 @@
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const test_step = b.step("test", "Test it");
5 b.default_step = test_step;
6
7 const target = b.standardTargetOptions(.{});
8 const optimize = b.standardOptimizeOption(.{});
9
10 if (target.getObjectFormat() != .elf) return;
11
12 const exe = b.addExecutable(.{
13 .name = "main",
14 .optimize = optimize,
15 .target = target,
16 });
17 exe.addCSourceFile("main.c", &.{});
18 exe.link_gc_sections = false;
19 exe.bundle_compiler_rt = true;
20
21 // Verify compiler_rt hasn't pulled in any debug handlers
22 const check_exe = exe.checkObject();
23 check_exe.checkInSymtab();
24 check_exe.checkNotPresent("debug.readElfDebugInfo");
25 test_step.dependOn(&check_exe.step);
26}
test/standalone/compiler_rt_panic/main.c created+11
...@@ -0,0 +1,11 @@
1#include <stddef.h>
2
3void* __memset(void* dest, char c, size_t n, size_t dest_n);
4
5char foo[128];
6
7int main() {
8 __memset(&foo[0], 0xff, 128, 128);
9 return foo[64];
10}
11