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 {...@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
454 optimize: std.builtin.Mode = .Debug,454 optimize: std.builtin.Mode = .Debug,
455 linkage: ?CompileStep.Linkage = null,455 linkage: ?CompileStep.Linkage = null,
456 max_rss: usize = 0,456 max_rss: usize = 0,
457 link_libc: ?bool = null,
458 single_threaded: ?bool = null,
459 use_llvm: ?bool = null,
460 use_lld: ?bool = null,
457};461};
458462
459pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {463pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
...@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {...@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
466 .kind = .exe,470 .kind = .exe,
467 .linkage = options.linkage,471 .linkage = options.linkage,
468 .max_rss = options.max_rss,472 .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,
469 });477 });
470}478}
471479
...@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {...@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
475 target: CrossTarget,483 target: CrossTarget,
476 optimize: std.builtin.Mode,484 optimize: std.builtin.Mode,
477 max_rss: usize = 0,485 max_rss: usize = 0,
486 link_libc: ?bool = null,
487 single_threaded: ?bool = null,
488 use_llvm: ?bool = null,
489 use_lld: ?bool = null,
478};490};
479491
480pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {492pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
...@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {...@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
485 .optimize = options.optimize,497 .optimize = options.optimize,
486 .kind = .obj,498 .kind = .obj,
487 .max_rss = options.max_rss,499 .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,
488 });504 });
489}505}
490506
...@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {...@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
495 target: CrossTarget,511 target: CrossTarget,
496 optimize: std.builtin.Mode,512 optimize: std.builtin.Mode,
497 max_rss: usize = 0,513 max_rss: usize = 0,
514 link_libc: ?bool = null,
515 single_threaded: ?bool = null,
516 use_llvm: ?bool = null,
517 use_lld: ?bool = null,
498};518};
499519
500pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {520pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
...@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {...@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
507 .target = options.target,527 .target = options.target,
508 .optimize = options.optimize,528 .optimize = options.optimize,
509 .max_rss = options.max_rss,529 .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,
510 });534 });
511}535}
512536
...@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {...@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
517 optimize: std.builtin.Mode,541 optimize: std.builtin.Mode,
518 version: ?std.builtin.Version = null,542 version: ?std.builtin.Version = null,
519 max_rss: usize = 0,543 max_rss: usize = 0,
544 link_libc: ?bool = null,
545 single_threaded: ?bool = null,
546 use_llvm: ?bool = null,
547 use_lld: ?bool = null,
520};548};
521549
522pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {550pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
...@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {...@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
529 .target = options.target,557 .target = options.target,
530 .optimize = options.optimize,558 .optimize = options.optimize,
531 .max_rss = options.max_rss,559 .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,
532 });564 });
533}565}
534566
...@@ -541,6 +573,10 @@ pub const TestOptions = struct {...@@ -541,6 +573,10 @@ pub const TestOptions = struct {
541 max_rss: usize = 0,573 max_rss: usize = 0,
542 filter: ?[]const u8 = null,574 filter: ?[]const u8 = null,
543 test_runner: ?[]const u8 = null,575 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,
544};580};
545581
546pub fn addTest(b: *Build, options: TestOptions) *CompileStep {582pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
...@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {...@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
553 .max_rss = options.max_rss,589 .max_rss = options.max_rss,
554 .filter = options.filter,590 .filter = options.filter,
555 .test_runner = options.test_runner,591 .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,
556 });596 });
557}597}
558598
lib/std/Build/CompileStep.zig+15-5
...@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,...@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
63// so it is not an EmitOption for now.63// so it is not an EmitOption for now.
64emit_h: bool = false,64emit_h: bool = false,
65bundle_compiler_rt: ?bool = null,65bundle_compiler_rt: ?bool = null,
66single_threaded: ?bool = null,66single_threaded: ?bool,
67stack_protector: ?bool = null,67stack_protector: ?bool = null,
68disable_stack_probing: bool,68disable_stack_probing: bool,
69disable_sanitize_c: bool,69disable_sanitize_c: bool,
...@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),...@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
101include_dirs: ArrayList(IncludeDir),101include_dirs: ArrayList(IncludeDir),
102c_macros: ArrayList([]const u8),102c_macros: ArrayList([]const u8),
103installed_headers: ArrayList(*Step),103installed_headers: ArrayList(*Step),
104is_linking_libc: bool = false,104is_linking_libc: bool,
105is_linking_libcpp: bool = false,105is_linking_libcpp: bool,
106vcpkg_bin_path: ?[]const u8 = null,106vcpkg_bin_path: ?[]const u8 = null,
107107
108/// This may be set in order to override the default install directory108/// This may be set in order to override the default install directory
...@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),...@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
207stack_size: ?u64 = null,207stack_size: ?u64 = null,
208208
209want_lto: ?bool = null,209want_lto: ?bool = null,
210use_llvm: ?bool = null,210use_llvm: ?bool,
211use_lld: ?bool = null,211use_lld: ?bool,
212212
213/// This is an advanced setting that can change the intent of this CompileStep.213/// This is an advanced setting that can change the intent of this CompileStep.
214/// If this slice has nonzero length, it means that this CompileStep exists to214/// If this slice has nonzero length, it means that this CompileStep exists to
...@@ -287,6 +287,10 @@ pub const Options = struct {...@@ -287,6 +287,10 @@ pub const Options = struct {
287 max_rss: usize = 0,287 max_rss: usize = 0,
288 filter: ?[]const u8 = null,288 filter: ?[]const u8 = null,
289 test_runner: ?[]const u8 = null,289 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,
290};294};
291295
292pub const Kind = enum {296pub const Kind = enum {
...@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {...@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
412 .output_dirname_source = GeneratedFile{ .step = &self.step },416 .output_dirname_source = GeneratedFile{ .step = &self.step },
413417
414 .target_info = target_info,418 .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,
415 };425 };
416426
417 if (self.kind == .lib) {427 if (self.kind == .lib) {