Skip to content

Commit 9d8adb3

Browse files
committed
std.Build: Make no_builtin a property of Module instead of Step.Compile.
This reflects how the compiler actually treats it. Closes #23424.
1 parent aa7c6dc commit 9d8adb3

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

lib/std/Build/Module.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ omit_frame_pointer: ?bool,
3333
error_tracing: ?bool,
3434
link_libc: ?bool,
3535
link_libcpp: ?bool,
36+
no_builtin: ?bool,
3637

3738
/// Symbols to be exported when compiling to WebAssembly.
3839
export_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

273275
pub 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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ is_linking_libc: bool = false,
229229
/// Computed during make().
230230
is_linking_libcpp: bool = false,
231231

232-
no_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.
236234
zig_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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)