aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-05-13 10:42:05 +0200
committerGitHub <noreply@github.com>2025-05-13 10:42:05 +0200
commit5b606d435d139487c23d6fd30e8061dbad741ada (patch)
tree7c1cb233429d26ea85249b21f7cb7f80e8527476 /lib/std/Build
parenta365971a337116dd23df2b1bc86468d54885b4b2 (diff)
parent9d8adb38a18169a16707acac2812dd6850de99be (diff)
downloadzig-5b606d435d139487c23d6fd30e8061dbad741ada.tar.gz
zig-5b606d435d139487c23d6fd30e8061dbad741ada.zip
Merge pull request #21882 from alexrp/compiler-fixes
compiler: Fix some real and theoretical miscompilations with `allowzero` and `volatile`
Diffstat (limited to 'lib/std/Build')
-rw-r--r--lib/std/Build/Module.zig4
-rw-r--r--lib/std/Build/Step/Compile.zig6
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig
index d95da55efa..757f51f933 100644
--- a/lib/std/Build/Module.zig
+++ b/lib/std/Build/Module.zig
@@ -33,6 +33,7 @@ omit_frame_pointer: ?bool,
error_tracing: ?bool,
link_libc: ?bool,
link_libcpp: ?bool,
+no_builtin: ?bool,
/// Symbols to be exported when compiling to WebAssembly.
export_symbol_names: []const []const u8 = &.{},
@@ -268,6 +269,7 @@ pub const CreateOptions = struct {
/// more difficult to obtain stack traces. Has target-dependent effects.
omit_frame_pointer: ?bool = null,
error_tracing: ?bool = null,
+ no_builtin: ?bool = null,
};
pub const Import = struct {
@@ -314,6 +316,7 @@ pub fn init(
.omit_frame_pointer = options.omit_frame_pointer,
.error_tracing = options.error_tracing,
.export_symbol_names = &.{},
+ .no_builtin = options.no_builtin,
};
m.import_table.ensureUnusedCapacity(allocator, options.imports.len) catch @panic("OOM");
@@ -564,6 +567,7 @@ pub fn appendZigProcessFlags(
try addFlag(zig_args, m.valgrind, "-fvalgrind", "-fno-valgrind");
try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
+ try addFlag(zig_args, m.no_builtin, "-fno-builtin", "-fbuiltin");
if (m.sanitize_c) |sc| switch (sc) {
.off => try zig_args.append("-fno-sanitize-c"),
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index e436865108..066167905d 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -229,8 +229,6 @@ is_linking_libc: bool = false,
/// Computed during make().
is_linking_libcpp: bool = false,
-no_builtin: bool = false,
-
/// Populated during the make phase when there is a long-lived compiler process.
/// Managed by the build runner, not user build script.
zig_process: ?*Step.ZigProcess,
@@ -1646,10 +1644,6 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
}
}
- if (compile.no_builtin) {
- try zig_args.append("-fno-builtin");
- }
-
if (b.sysroot) |sysroot| {
try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
}