authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-13 16:44:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-15 10:33:08-07:00
logadc9b77d5fc4d1520905f1b1f4b3c80d6d424da6
treea48195774bfe83cbb297b428b001b3dcf44a0a9e
parent23ac4dd87b740012ba33e8ab2ea6fb25c04b6268

std.Build: add some more init options to CompileStep


2 files changed, 55 insertions(+), 5 deletions(-)

lib/std/Build.zig+40
......@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
454454 optimize: std.builtin.Mode = .Debug,
455455 linkage: ?CompileStep.Linkage = null,
456456 max_rss: usize = 0,
457 link_libc: ?bool = null,
458 single_threaded: ?bool = null,
459 use_llvm: ?bool = null,
460 use_lld: ?bool = null,
457461};
458462
459463pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
......@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
466470 .kind = .exe,
467471 .linkage = options.linkage,
468472 .max_rss = options.max_rss,
473 .link_libc = options.link_libc,
474 .single_threaded = options.single_threaded,
475 .use_llvm = options.use_llvm,
476 .use_lld = options.use_lld,
469477 });
470478}
471479
......@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
475483 target: CrossTarget,
476484 optimize: std.builtin.Mode,
477485 max_rss: usize = 0,
486 link_libc: ?bool = null,
487 single_threaded: ?bool = null,
488 use_llvm: ?bool = null,
489 use_lld: ?bool = null,
478490};
479491
480492pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
......@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
485497 .optimize = options.optimize,
486498 .kind = .obj,
487499 .max_rss = options.max_rss,
500 .link_libc = options.link_libc,
501 .single_threaded = options.single_threaded,
502 .use_llvm = options.use_llvm,
503 .use_lld = options.use_lld,
488504 });
489505}
490506
......@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
495511 target: CrossTarget,
496512 optimize: std.builtin.Mode,
497513 max_rss: usize = 0,
514 link_libc: ?bool = null,
515 single_threaded: ?bool = null,
516 use_llvm: ?bool = null,
517 use_lld: ?bool = null,
498518};
499519
500520pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
......@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
507527 .target = options.target,
508528 .optimize = options.optimize,
509529 .max_rss = options.max_rss,
530 .link_libc = options.link_libc,
531 .single_threaded = options.single_threaded,
532 .use_llvm = options.use_llvm,
533 .use_lld = options.use_lld,
510534 });
511535}
512536
......@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
517541 optimize: std.builtin.Mode,
518542 version: ?std.builtin.Version = null,
519543 max_rss: usize = 0,
544 link_libc: ?bool = null,
545 single_threaded: ?bool = null,
546 use_llvm: ?bool = null,
547 use_lld: ?bool = null,
520548};
521549
522550pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
......@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
529557 .target = options.target,
530558 .optimize = options.optimize,
531559 .max_rss = options.max_rss,
560 .link_libc = options.link_libc,
561 .single_threaded = options.single_threaded,
562 .use_llvm = options.use_llvm,
563 .use_lld = options.use_lld,
532564 });
533565}
534566
......@@ -541,6 +573,10 @@ pub const TestOptions = struct {
541573 max_rss: usize = 0,
542574 filter: ?[]const u8 = null,
543575 test_runner: ?[]const u8 = null,
576 link_libc: ?bool = null,
577 single_threaded: ?bool = null,
578 use_llvm: ?bool = null,
579 use_lld: ?bool = null,
544580};
545581
546582pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
......@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
553589 .max_rss = options.max_rss,
554590 .filter = options.filter,
555591 .test_runner = options.test_runner,
592 .link_libc = options.link_libc,
593 .single_threaded = options.single_threaded,
594 .use_llvm = options.use_llvm,
595 .use_lld = options.use_lld,
556596 });
557597}
558598
lib/std/Build/CompileStep.zig+15-5
......@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
6363// so it is not an EmitOption for now.
6464emit_h: bool = false,
6565bundle_compiler_rt: ?bool = null,
66single_threaded: ?bool = null,
66single_threaded: ?bool,
6767stack_protector: ?bool = null,
6868disable_stack_probing: bool,
6969disable_sanitize_c: bool,
......@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
101101include_dirs: ArrayList(IncludeDir),
102102c_macros: ArrayList([]const u8),
103103installed_headers: ArrayList(*Step),
104is_linking_libc: bool = false,
105is_linking_libcpp: bool = false,
104is_linking_libc: bool,
105is_linking_libcpp: bool,
106106vcpkg_bin_path: ?[]const u8 = null,
107107
108108/// This may be set in order to override the default install directory
......@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
207207stack_size: ?u64 = null,
208208
209209want_lto: ?bool = null,
210use_llvm: ?bool = null,
211use_lld: ?bool = null,
210use_llvm: ?bool,
211use_lld: ?bool,
212212
213213/// This is an advanced setting that can change the intent of this CompileStep.
214214/// If this slice has nonzero length, it means that this CompileStep exists to
......@@ -287,6 +287,10 @@ pub const Options = struct {
287287 max_rss: usize = 0,
288288 filter: ?[]const u8 = null,
289289 test_runner: ?[]const u8 = null,
290 link_libc: ?bool = null,
291 single_threaded: ?bool = null,
292 use_llvm: ?bool = null,
293 use_lld: ?bool = null,
290294};
291295
292296pub const Kind = enum {
......@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
412416 .output_dirname_source = GeneratedFile{ .step = &self.step },
413417
414418 .target_info = target_info,
419
420 .is_linking_libc = options.link_libc orelse false,
421 .is_linking_libcpp = false,
422 .single_threaded = options.single_threaded,
423 .use_llvm = options.use_llvm,
424 .use_lld = options.use_lld,
415425 };
416426
417427 if (self.kind == .lib) {