Repository navigation
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.
Milestone
Description
zig version: 0.11.0-dev.2653+2568da2f4
const std = @import("std");
pub fn panic(msg: []const u8, st: ?*std.builtin.StackTrace, start: ?usize) noreturn {
_ = .{ msg, st, start };
unreachable;
}
export fn entry() void {}Look at all this garbage:
$ zig build-obj test.zig
$ readelf -s test.o | grep FUNC
2: 0000000000000000 162 FUNC LOCAL DEFAULT 1 target.Target.Cp[...]
3: 00000000000000b0 220 FUNC LOCAL DEFAULT 1 target.Target.Cp[...]
5: 0000000000000190 54 FUNC LOCAL DEFAULT 1 test2.panic
6: 00000000000001d0 53 FUNC LOCAL DEFAULT 1 builtin.panicOut[...]
8: 0000000000000220 555 FUNC LOCAL DEFAULT 1 debug.panicExtra[...]
10: 0000000000000450 53 FUNC LOCAL DEFAULT 1 builtin.panicSta[...]
11: 0000000000000490 308 FUNC LOCAL DEFAULT 1 fmt.bufPrint__an[...]
13: 00000000000005d0 300 FUNC LOCAL DEFAULT 1 mem.copy__anon_1469
14: 0000000000000700 555 FUNC LOCAL DEFAULT 1 debug.panicExtra[...]
15: 0000000000000d90 40 FUNC LOCAL DEFAULT 1 io.fixed_buffer_[...]
16: 0000000000000dc0 21 FUNC LOCAL DEFAULT 1 io.fixed_buffer_[...]
17: 0000000000000930 360 FUNC LOCAL DEFAULT 1 fmt.format__anon_1595
18: 0000000000000c50 215 FUNC LOCAL DEFAULT 1 builtin.returnError
19: 0000000000000de0 139 FUNC LOCAL DEFAULT 1 io.fixed_buffer_[...]
21: 0000000000000e70 308 FUNC LOCAL DEFAULT 1 fmt.bufPrint__an[...]
23: 0000000000000aa0 425 FUNC LOCAL DEFAULT 1 io.writer.Writer[...]
24: 0000000000000d30 81 FUNC LOCAL DEFAULT 1 fmt.formatType__[...]
25: 0000000000001430 115 FUNC LOCAL DEFAULT 1 io.writer.Writer[...]
28: 0000000000002050 61 FUNC LOCAL DEFAULT 1 fmt.formatValue_[...]
29: 0000000000003d00 360 FUNC LOCAL DEFAULT 1 fmt.format__anon_1830
30: 0000000000000fb0 1141 FUNC LOCAL DEFAULT 1 io.fixed_buffer_[...]
34: 00000000000014b0 69 FUNC LOCAL DEFAULT 1 debug.assert
35: 0000000000001500 459 FUNC LOCAL DEFAULT 1 fmt.Parser.specifier
36: 00000000000016d0 238 FUNC LOCAL DEFAULT 1 fmt.Parser.maybe
37: 00000000000017c0 445 FUNC LOCAL DEFAULT 1 fmt.Parser.until
39: 0000000000001980 769 FUNC LOCAL DEFAULT 1 fmt.Parser.number
43: 0000000000001c90 261 FUNC LOCAL DEFAULT 1 fmt.Parser.char
44: 0000000000001da0 283 FUNC LOCAL DEFAULT 1 fmt.Parser.peek
45: 0000000000001ec0 393 FUNC LOCAL DEFAULT 1 fmt.ArgState.nextArg
47: 0000000000002090 78 FUNC LOCAL DEFAULT 1 fmt.formatIntVal[...]
48: 00000000000020e0 2085 FUNC LOCAL DEFAULT 1 fmt.formatInt__a[...]
49: 0000000000002910 18 FUNC LOCAL DEFAULT 1 math.absCast__an[...]
50: 0000000000002930 20 FUNC LOCAL DEFAULT 1 fmt.isComptime
51: 0000000000002950 374 FUNC LOCAL DEFAULT 1 fmt.digits2
53: 0000000000002ad0 331 FUNC LOCAL DEFAULT 1 fmt.digitToChar
54: 0000000000002c20 1393 FUNC LOCAL DEFAULT 1 fmt.formatBuf__a[...]
56: 0000000000003290 1701 FUNC LOCAL DEFAULT 1 unicode.utf8Coun[...]
57: 0000000000003aa0 567 FUNC LOCAL DEFAULT 1 io.writer.Writer[...]
58: 00000000000031a0 232 FUNC LOCAL DEFAULT 1 unicode.utf8Byte[...]
59: 0000000000003940 18 FUNC LOCAL DEFAULT 1 mem.readIntNativ[...]
61: 0000000000003960 306 FUNC LOCAL DEFAULT 1 unicode.utf8Decode
62: 0000000000003e70 489 FUNC LOCAL DEFAULT 1 unicode.utf8Decode2
63: 0000000000004060 828 FUNC LOCAL DEFAULT 1 unicode.utf8Decode3
64: 00000000000043a0 1023 FUNC LOCAL DEFAULT 1 unicode.utf8Decode4
65: 00000000000047a0 111 FUNC LOCAL DEFAULT 1 mem.set__anon_1862
66: 0000000000004810 49 FUNC LOCAL DEFAULT 1 math.min__anon_1863
67: 0000000000003ce0 30 FUNC LOCAL DEFAULT 1 fmt.ArgState.has[...]
112: 0000000000000210 6 FUNC GLOBAL DEFAULT 1 entry
I expect to see only the entry symbol, even in debug builds. This should be true even if I delete the panic handler override, since the entry function contains no panics.
Reacted by Alan Wu
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.
Activity
mlugg commentedon Apr 18, 2023
I may be wrong, but I suspect this is highly related to #6256 - I imagine some comptime evaluation in
stdis hitting e.g. formatting code and causing it to be analyzed and included in the binary.kubkon commentedon Apr 20, 2023
This actually took me by surprise on Windows today when suddenly the symtab is enormous for a very simple Zig source
pub fn main() void {}. Oh, and I am talking about our self-hosted x86 backend and Coff linker.Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime
Prevent analysis of functions only referenced at comptime