authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-02 14:36:21+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-12 17:08:22+02:00
log9d8adb38a18169a16707acac2812dd6850de99be
treed7d545b25e4993d9c5358f3e111a9aeaacfa1a63
parentaa7c6dcac1c87d892156daf210620f999d9838f3
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Build: Make no_builtin a property of Module instead of Step.Compile.

This reflects how the compiler actually treats it. Closes #23424.

4 files changed, 6 insertions(+), 8 deletions(-)

lib/std/Build/Module.zig+4
......@@ -33,6 +33,7 @@ omit_frame_pointer: ?bool,
3333error_tracing: ?bool,
3434link_libc: ?bool,
3535link_libcpp: ?bool,
36no_builtin: ?bool,
3637
3738/// Symbols to be exported when compiling to WebAssembly.
3839export_symbol_names: []const []const u8 = &.{},
......@@ -268,6 +269,7 @@ pub const CreateOptions = struct {
268269 /// more difficult to obtain stack traces. Has target-dependent effects.
269270 omit_frame_pointer: ?bool = null,
270271 error_tracing: ?bool = null,
272 no_builtin: ?bool = null,
271273};
272274
273275pub const Import = struct {
......@@ -314,6 +316,7 @@ pub fn init(
314316 .omit_frame_pointer = options.omit_frame_pointer,
315317 .error_tracing = options.error_tracing,
316318 .export_symbol_names = &.{},
319 .no_builtin = options.no_builtin,
317320 };
318321
319322 m.import_table.ensureUnusedCapacity(allocator, options.imports.len) catch @panic("OOM");
......@@ -564,6 +567,7 @@ pub fn appendZigProcessFlags(
564567 try addFlag(zig_args, m.valgrind, "-fvalgrind", "-fno-valgrind");
565568 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
566569 try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
570 try addFlag(zig_args, m.no_builtin, "-fno-builtin", "-fbuiltin");
567571
568572 if (m.sanitize_c) |sc| switch (sc) {
569573 .off => try zig_args.append("-fno-sanitize-c"),
lib/std/Build/Step/Compile.zig-6
......@@ -229,8 +229,6 @@ is_linking_libc: bool = false,
229229/// Computed during make().
230230is_linking_libcpp: bool = false,
231231
232no_builtin: ?bool = null,
233
234232/// Populated during the make phase when there is a long-lived compiler process.
235233/// Managed by the build runner, not user build script.
236234zig_process: ?*Step.ZigProcess,
......@@ -1646,10 +1644,6 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
16461644 }
16471645 }
16481646
1649 if (compile.no_builtin) |enabled| {
1650 try zig_args.append(if (enabled) "-fbuiltin" else "-fno-builtin");
1651 }
1652
16531647 if (b.sysroot) |sysroot| {
16541648 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
16551649 }
test/src/LlvmIr.zig+1-1
......@@ -107,9 +107,9 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {
107107
108108 obj.dll_export_fns = case.params.dll_export_fns;
109109 obj.pie = case.params.pie;
110 obj.no_builtin = case.params.no_builtin;
111110
112111 obj.root_module.dwarf_format = case.params.dwarf_format;
112 obj.root_module.no_builtin = case.params.no_builtin;
113113 obj.root_module.red_zone = case.params.red_zone;
114114 obj.root_module.stack_check = case.params.stack_check;
115115 obj.root_module.stack_protector = case.params.stack_protector;
test/tests.zig+1-1
......@@ -1827,7 +1827,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
18271827 .zig_lib_dir = b.path("lib"),
18281828 });
18291829 these_tests.linkage = test_target.linkage;
1830 if (options.no_builtin) these_tests.no_builtin = true;
1830 if (options.no_builtin) these_tests.root_module.no_builtin = false;
18311831 if (options.build_options) |build_options| {
18321832 these_tests.root_module.addOptions("build_options", build_options);
18331833 }