aboutsummaryrefslogtreecommitdiff
path: root/src/Package/Module.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-11-05 14:29:44 +0100
committerAlex Rønne Petersen <alex@alexrp.com>2024-11-05 14:43:02 +0100
commitb57819118ddf287a135b4c2fb7182615b402fbc2 (patch)
tree6b55bd9b957750e542bec14373e3ba27aef94b5a /src/Package/Module.zig
parent56b416662aa89196d5b974632dcd927d26b5d12c (diff)
downloadzig-b57819118ddf287a135b4c2fb7182615b402fbc2.tar.gz
zig-b57819118ddf287a135b4c2fb7182615b402fbc2.zip
Compilation: Move no_builtin to Package.Module.
This option, by its very nature, needs to be attached to a module. If it isn't, the code in a module could break at random when compiled into an application that doesn't have this option set. After this change, skip_linker_dependencies no longer implies no_builtin in the LLVM backend.
Diffstat (limited to 'src/Package/Module.zig')
-rw-r--r--src/Package/Module.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Package/Module.zig b/src/Package/Module.zig
index 0a3d754e7a..0e777145d9 100644
--- a/src/Package/Module.zig
+++ b/src/Package/Module.zig
@@ -31,6 +31,7 @@ unwind_tables: bool,
cc_argv: []const []const u8,
/// (SPIR-V) whether to generate a structured control flow graph or not
structured_cfg: bool,
+no_builtin: bool,
/// If the module is an `@import("builtin")` module, this is the `File` that
/// is preallocated for it. Otherwise this field is null.
@@ -95,6 +96,7 @@ pub const CreateOptions = struct {
sanitize_thread: ?bool = null,
fuzz: ?bool = null,
structured_cfg: ?bool = null,
+ no_builtin: ?bool = null,
};
};
@@ -298,6 +300,13 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
};
};
+ const no_builtin = b: {
+ if (options.inherited.no_builtin) |x| break :b x;
+ if (options.parent) |p| break :b p.no_builtin;
+
+ break :b target.cpu.arch.isBpf();
+ };
+
const llvm_cpu_features: ?[*:0]const u8 = b: {
if (resolved_target.llvm_cpu_features) |x| break :b x;
if (!options.global.use_llvm) break :b null;
@@ -350,6 +359,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
.unwind_tables = unwind_tables,
.cc_argv = options.cc_argv,
.structured_cfg = structured_cfg,
+ .no_builtin = no_builtin,
.builtin_file = null,
};
@@ -442,6 +452,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
.unwind_tables = unwind_tables,
.cc_argv = &.{},
.structured_cfg = structured_cfg,
+ .no_builtin = no_builtin,
.builtin_file = new_file,
};
new_file.* = .{
@@ -502,6 +513,7 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P
.unwind_tables = undefined,
.cc_argv = undefined,
.structured_cfg = undefined,
+ .no_builtin = undefined,
.builtin_file = null,
};
return mod;