Commit adc9b77d5f

Andrew Kelley <andrew@ziglang.org>
2023-04-14 01:44:28
std.Build: add some more init options to CompileStep
1 parent 23ac4dd
Changed files (2)
lib/std/Build/CompileStep.zig
@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
 // so it is not an EmitOption for now.
 emit_h: bool = false,
 bundle_compiler_rt: ?bool = null,
-single_threaded: ?bool = null,
+single_threaded: ?bool,
 stack_protector: ?bool = null,
 disable_stack_probing: bool,
 disable_sanitize_c: bool,
@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
 include_dirs: ArrayList(IncludeDir),
 c_macros: ArrayList([]const u8),
 installed_headers: ArrayList(*Step),
-is_linking_libc: bool = false,
-is_linking_libcpp: bool = false,
+is_linking_libc: bool,
+is_linking_libcpp: bool,
 vcpkg_bin_path: ?[]const u8 = null,
 
 /// This may be set in order to override the default install directory
@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
 stack_size: ?u64 = null,
 
 want_lto: ?bool = null,
-use_llvm: ?bool = null,
-use_lld: ?bool = null,
+use_llvm: ?bool,
+use_lld: ?bool,
 
 /// This is an advanced setting that can change the intent of this CompileStep.
 /// If this slice has nonzero length, it means that this CompileStep exists to
@@ -287,6 +287,10 @@ pub const Options = struct {
     max_rss: usize = 0,
     filter: ?[]const u8 = null,
     test_runner: ?[]const u8 = null,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub const Kind = enum {
@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
         .output_dirname_source = GeneratedFile{ .step = &self.step },
 
         .target_info = target_info,
+
+        .is_linking_libc = options.link_libc orelse false,
+        .is_linking_libcpp = false,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     };
 
     if (self.kind == .lib) {
lib/std/Build.zig
@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
     optimize: std.builtin.Mode = .Debug,
     linkage: ?CompileStep.Linkage = null,
     max_rss: usize = 0,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
         .kind = .exe,
         .linkage = options.linkage,
         .max_rss = options.max_rss,
+        .link_libc = options.link_libc,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     });
 }
 
@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
     target: CrossTarget,
     optimize: std.builtin.Mode,
     max_rss: usize = 0,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
         .optimize = options.optimize,
         .kind = .obj,
         .max_rss = options.max_rss,
+        .link_libc = options.link_libc,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     });
 }
 
@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
     target: CrossTarget,
     optimize: std.builtin.Mode,
     max_rss: usize = 0,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
         .target = options.target,
         .optimize = options.optimize,
         .max_rss = options.max_rss,
+        .link_libc = options.link_libc,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     });
 }
 
@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
     optimize: std.builtin.Mode,
     version: ?std.builtin.Version = null,
     max_rss: usize = 0,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
         .target = options.target,
         .optimize = options.optimize,
         .max_rss = options.max_rss,
+        .link_libc = options.link_libc,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     });
 }
 
@@ -541,6 +573,10 @@ pub const TestOptions = struct {
     max_rss: usize = 0,
     filter: ?[]const u8 = null,
     test_runner: ?[]const u8 = null,
+    link_libc: ?bool = null,
+    single_threaded: ?bool = null,
+    use_llvm: ?bool = null,
+    use_lld: ?bool = null,
 };
 
 pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
         .max_rss = options.max_rss,
         .filter = options.filter,
         .test_runner = options.test_runner,
+        .link_libc = options.link_libc,
+        .single_threaded = options.single_threaded,
+        .use_llvm = options.use_llvm,
+        .use_lld = options.use_lld,
     });
 }