Skip to content

Commit 8b9627f

Browse files
committed
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
1 parent 78449b6 commit 8b9627f

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

lib/std/Build/Step/CheckObject.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
478478
},
479479
.not_present => {
480480
while (it.next()) |line| {
481-
if (act.notPresent(b, step, line)) break;
482-
} else {
481+
if (act.notPresent(b, step, line)) continue;
483482
return step.fail(
484483
\\
485484
\\========= expected not to find: ===================

test/standalone.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ pub const build_cases = [_]BuildCase{
241241
.build_root = "test/standalone/coff_dwarf",
242242
.import = @import("standalone/coff_dwarf/build.zig"),
243243
},
244+
.{
245+
.build_root = "test/standalone/compiler_rt_panic",
246+
.import = @import("standalone/compiler_rt_panic/build.zig"),
247+
},
244248
};
245249

246250
const std = @import("std");
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const std = @import("std");
2+
3+
pub 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+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stddef.h>
2+
3+
void* __memset(void* dest, char c, size_t n, size_t dest_n);
4+
5+
char foo[128];
6+
7+
int main() {
8+
__memset(&foo[0], 0xff, 128, 128);
9+
return foo[64];
10+
}
11+

0 commit comments

Comments
 (0)