From c78b6564df18be568a869d7effeb0eb1c5b1bde6 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sat, 6 Jan 2024 18:30:15 -0800 Subject: [PATCH 1/2] Compilation: pass code model in buildOutputFromZig --- src/Compilation.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compilation.zig b/src/Compilation.zig index 9347644381..602cd645a0 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6334,6 +6334,7 @@ fn buildOutputFromZig( .pic = comp.root_mod.pic, .optimize_mode = optimize_mode, .structured_cfg = comp.root_mod.structured_cfg, + .code_model = comp.root_mod.code_model, }, .global = config, .cc_argv = &.{}, From 22598ef35f3e39444c1406927532e76f42f01324 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sat, 6 Jan 2024 18:30:38 -0800 Subject: [PATCH 2/2] std.Build: pass code model in various compile steps --- lib/std/Build.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 449bee1e2a..ec36bb33c6 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -608,6 +608,7 @@ pub const ExecutableOptions = struct { root_source_file: ?LazyPath = null, version: ?std.SemanticVersion = null, optimize: std.builtin.OptimizeMode = .Debug, + code_model: std.builtin.CodeModel = .default, linkage: ?Step.Compile.Linkage = null, max_rss: usize = 0, link_libc: ?bool = null, @@ -644,6 +645,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile { .omit_frame_pointer = options.omit_frame_pointer, .sanitize_thread = options.sanitize_thread, .error_tracing = options.error_tracing, + .code_model = options.code_model, }, .version = options.version, .kind = .exe, @@ -662,6 +664,7 @@ pub const ObjectOptions = struct { /// To choose the same computer as the one building the package, pass the /// `host` field of the package's `Build` instance. target: ResolvedTarget, + code_model: std.builtin.CodeModel = .default, optimize: std.builtin.OptimizeMode, max_rss: usize = 0, link_libc: ?bool = null, @@ -692,6 +695,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile { .omit_frame_pointer = options.omit_frame_pointer, .sanitize_thread = options.sanitize_thread, .error_tracing = options.error_tracing, + .code_model = options.code_model, }, .kind = .obj, .max_rss = options.max_rss, @@ -707,6 +711,7 @@ pub const SharedLibraryOptions = struct { /// `host` field of the package's `Build` instance. target: ResolvedTarget, optimize: std.builtin.OptimizeMode, + code_model: std.builtin.CodeModel = .default, root_source_file: ?LazyPath = null, version: ?std.SemanticVersion = null, max_rss: usize = 0, @@ -744,6 +749,7 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *Step.Compile .omit_frame_pointer = options.omit_frame_pointer, .sanitize_thread = options.sanitize_thread, .error_tracing = options.error_tracing, + .code_model = options.code_model, }, .kind = .lib, .linkage = .dynamic, @@ -763,6 +769,7 @@ pub const StaticLibraryOptions = struct { /// `host` field of the package's `Build` instance. target: ResolvedTarget, optimize: std.builtin.OptimizeMode, + code_model: std.builtin.CodeModel = .default, version: ?std.SemanticVersion = null, max_rss: usize = 0, link_libc: ?bool = null, @@ -793,6 +800,7 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *Step.Compile .omit_frame_pointer = options.omit_frame_pointer, .sanitize_thread = options.sanitize_thread, .error_tracing = options.error_tracing, + .code_model = options.code_model, }, .kind = .lib, .linkage = .static,