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
This commit is contained in:
kcbanner 2023-07-27 02:53:40 -04:00
parent 78449b6d98
commit 8b9627f01d
4 changed files with 42 additions and 2 deletions

View file

@ -478,8 +478,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
}, },
.not_present => { .not_present => {
while (it.next()) |line| { while (it.next()) |line| {
if (act.notPresent(b, step, line)) break; if (act.notPresent(b, step, line)) continue;
} else {
return step.fail( return step.fail(
\\ \\
\\========= expected not to find: =================== \\========= expected not to find: ===================

View file

@ -241,6 +241,10 @@ pub const build_cases = [_]BuildCase{
.build_root = "test/standalone/coff_dwarf", .build_root = "test/standalone/coff_dwarf",
.import = @import("standalone/coff_dwarf/build.zig"), .import = @import("standalone/coff_dwarf/build.zig"),
}, },
.{
.build_root = "test/standalone/compiler_rt_panic",
.import = @import("standalone/compiler_rt_panic/build.zig"),
},
}; };
const std = @import("std"); const std = @import("std");

View file

@ -0,0 +1,26 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
if (target.getObjectFormat() != .elf) return;
const exe = b.addExecutable(.{
.name = "main",
.optimize = optimize,
.target = target,
});
exe.addCSourceFile("main.c", &.{});
exe.link_gc_sections = false;
exe.bundle_compiler_rt = true;
// Verify compiler_rt hasn't pulled in any debug handlers
const check_exe = exe.checkObject();
check_exe.checkInSymtab();
check_exe.checkNotPresent("debug.readElfDebugInfo");
test_step.dependOn(&check_exe.step);
}

View file

@ -0,0 +1,11 @@
#include <stddef.h>
void* __memset(void* dest, char c, size_t n, size_t dest_n);
char foo[128];
int main() {
__memset(&foo[0], 0xff, 128, 128);
return foo[64];
}