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,...@@ -33,6 +33,7 @@ omit_frame_pointer: ?bool,
33error_tracing: ?bool,33error_tracing: ?bool,
34link_libc: ?bool,34link_libc: ?bool,
35link_libcpp: ?bool,35link_libcpp: ?bool,
36no_builtin: ?bool,
3637
37/// Symbols to be exported when compiling to WebAssembly.38/// Symbols to be exported when compiling to WebAssembly.
38export_symbol_names: []const []const u8 = &.{},39export_symbol_names: []const []const u8 = &.{},
...@@ -268,6 +269,7 @@ pub const CreateOptions = struct {...@@ -268,6 +269,7 @@ pub const CreateOptions = struct {
268 /// more difficult to obtain stack traces. Has target-dependent effects.269 /// more difficult to obtain stack traces. Has target-dependent effects.
269 omit_frame_pointer: ?bool = null,270 omit_frame_pointer: ?bool = null,
270 error_tracing: ?bool = null,271 error_tracing: ?bool = null,
272 no_builtin: ?bool = null,
271};273};
272274
273pub const Import = struct {275pub const Import = struct {
...@@ -314,6 +316,7 @@ pub fn init(...@@ -314,6 +316,7 @@ pub fn init(
314 .omit_frame_pointer = options.omit_frame_pointer,316 .omit_frame_pointer = options.omit_frame_pointer,
315 .error_tracing = options.error_tracing,317 .error_tracing = options.error_tracing,
316 .export_symbol_names = &.{},318 .export_symbol_names = &.{},
319 .no_builtin = options.no_builtin,
317 };320 };
318321
319 m.import_table.ensureUnusedCapacity(allocator, options.imports.len) catch @panic("OOM");322 m.import_table.ensureUnusedCapacity(allocator, options.imports.len) catch @panic("OOM");
...@@ -564,6 +567,7 @@ pub fn appendZigProcessFlags(...@@ -564,6 +567,7 @@ pub fn appendZigProcessFlags(
564 try addFlag(zig_args, m.valgrind, "-fvalgrind", "-fno-valgrind");567 try addFlag(zig_args, m.valgrind, "-fvalgrind", "-fno-valgrind");
565 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");568 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
566 try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");569 try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
570 try addFlag(zig_args, m.no_builtin, "-fno-builtin", "-fbuiltin");
567571
568 if (m.sanitize_c) |sc| switch (sc) {572 if (m.sanitize_c) |sc| switch (sc) {
569 .off => try zig_args.append("-fno-sanitize-c"),573 .off => try zig_args.append("-fno-sanitize-c"),
lib/std/Build/Step/Compile.zig-6
...@@ -229,8 +229,6 @@ is_linking_libc: bool = false,...@@ -229,8 +229,6 @@ is_linking_libc: bool = false,
229/// Computed during make().229/// Computed during make().
230is_linking_libcpp: bool = false,230is_linking_libcpp: bool = false,
231231
232no_builtin: ?bool = null,
233
234/// Populated during the make phase when there is a long-lived compiler process.232/// Populated during the make phase when there is a long-lived compiler process.
235/// Managed by the build runner, not user build script.233/// Managed by the build runner, not user build script.
236zig_process: ?*Step.ZigProcess,234zig_process: ?*Step.ZigProcess,
...@@ -1646,10 +1644,6 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {...@@ -1646,10 +1644,6 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1646 }1644 }
1647 }1645 }
16481646
1649 if (compile.no_builtin) |enabled| {
1650 try zig_args.append(if (enabled) "-fbuiltin" else "-fno-builtin");
1651 }
1652
1653 if (b.sysroot) |sysroot| {1647 if (b.sysroot) |sysroot| {
1654 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });1648 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
1655 }1649 }
test/src/LlvmIr.zig+1-1
...@@ -107,9 +107,9 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {...@@ -107,9 +107,9 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {
107107
108 obj.dll_export_fns = case.params.dll_export_fns;108 obj.dll_export_fns = case.params.dll_export_fns;
109 obj.pie = case.params.pie;109 obj.pie = case.params.pie;
110 obj.no_builtin = case.params.no_builtin;
111110
112 obj.root_module.dwarf_format = case.params.dwarf_format;111 obj.root_module.dwarf_format = case.params.dwarf_format;
112 obj.root_module.no_builtin = case.params.no_builtin;
113 obj.root_module.red_zone = case.params.red_zone;113 obj.root_module.red_zone = case.params.red_zone;
114 obj.root_module.stack_check = case.params.stack_check;114 obj.root_module.stack_check = case.params.stack_check;
115 obj.root_module.stack_protector = case.params.stack_protector;115 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 {...@@ -1827,7 +1827,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1827 .zig_lib_dir = b.path("lib"),1827 .zig_lib_dir = b.path("lib"),
1828 });1828 });
1829 these_tests.linkage = test_target.linkage;1829 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;
1831 if (options.build_options) |build_options| {1831 if (options.build_options) |build_options| {
1832 these_tests.root_module.addOptions("build_options", build_options);1832 these_tests.root_module.addOptions("build_options", build_options);
1833 }1833 }