authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-07-26 18:03:33+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-07-26 18:03:33+01:00
loga51cdf3b24c25959ee55a38428dc0da42a8be81c
tree592ebc057ca3ffb5fd80f2c669f34ecba26fb718
parentc9ce1debe7cb59b63c00f56bb0d233eafc04dfd9
parent154bd2fd0597b23b4e4c95ad86d2b8c5274161e2
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #22587 from castholm/deprecate-compile-apis

std.Build: Deprecate `Step.Compile` APIs that mutate the root module

15 files changed, 569 insertions(+), 521 deletions(-)

doc/langref/build.zig+4-2
......@@ -4,8 +4,10 @@ pub fn build(b: *std.Build) void {
44 const optimize = b.standardOptimizeOption(.{});
55 const exe = b.addExecutable(.{
66 .name = "example",
7 .root_source_file = b.path("example.zig"),
8 .optimize = optimize,
7 .root_module = b.createModule(.{
8 .root_source_file = b.path("example.zig"),
9 .optimize = optimize,
10 }),
911 });
1012 b.default_step.dependOn(&exe.step);
1113}
doc/langref/build_c.zig+8-4
......@@ -4,15 +4,19 @@ pub fn build(b: *std.Build) void {
44 const lib = b.addLibrary(.{
55 .linkage = .dynamic,
66 .name = "mathtest",
7 .root_source_file = b.path("mathtest.zig"),
7 .root_module = b.createModule(.{
8 .root_source_file = b.path("mathtest.zig"),
9 }),
810 .version = .{ .major = 1, .minor = 0, .patch = 0 },
911 });
1012 const exe = b.addExecutable(.{
1113 .name = "test",
14 .root_module = b.createModule(.{
15 .link_libc = true,
16 }),
1217 });
13 exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
14 exe.linkLibrary(lib);
15 exe.linkSystemLibrary("c");
18 exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
19 exe.root_module.linkLibrary(lib);
1620
1721 b.default_step.dependOn(&exe.step);
1822
doc/langref/build_object.zig+8-4
......@@ -3,15 +3,19 @@ const std = @import("std");
33pub fn build(b: *std.Build) void {
44 const obj = b.addObject(.{
55 .name = "base64",
6 .root_source_file = b.path("base64.zig"),
6 .root_module = b.createModule(.{
7 .root_source_file = b.path("base64.zig"),
8 }),
79 });
810
911 const exe = b.addExecutable(.{
1012 .name = "test",
13 .root_module = b.createModule(.{
14 .link_libc = true,
15 }),
1116 });
12 exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
13 exe.addObject(obj);
14 exe.linkSystemLibrary("c");
17 exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
18 exe.root_module.addObject(obj);
1519 b.installArtifact(exe);
1620}
1721
lib/std/Build/Step/Compile.zig+42-4
......@@ -681,10 +681,14 @@ pub fn producesImplib(compile: *Compile) bool {
681681 return compile.isDll();
682682}
683683
684/// Deprecated; use `compile.root_module.link_libc = true` instead.
685/// To be removed after 0.15.0 is tagged.
684686pub fn linkLibC(compile: *Compile) void {
685687 compile.root_module.link_libc = true;
686688}
687689
690/// Deprecated; use `compile.root_module.link_libcpp = true` instead.
691/// To be removed after 0.15.0 is tagged.
688692pub fn linkLibCpp(compile: *Compile) void {
689693 compile.root_module.link_libcpp = true;
690694}
......@@ -802,10 +806,14 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
802806 };
803807}
804808
809/// Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead.
810/// To be removed after 0.15.0 is tagged.
805811pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void {
806812 return compile.root_module.linkSystemLibrary(name, .{});
807813}
808814
815/// Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead.
816/// To be removed after 0.15.0 is tagged.
809817pub fn linkSystemLibrary2(
810818 compile: *Compile,
811819 name: []const u8,
......@@ -814,22 +822,26 @@ pub fn linkSystemLibrary2(
814822 return compile.root_module.linkSystemLibrary(name, options);
815823}
816824
825/// Deprecated; use `c.root_module.linkFramework(name, .{})` instead.
826/// To be removed after 0.15.0 is tagged.
817827pub fn linkFramework(c: *Compile, name: []const u8) void {
818828 c.root_module.linkFramework(name, .{});
819829}
820830
821/// Handy when you have many C/C++ source files and want them all to have the same flags.
831/// Deprecated; use `compile.root_module.addCSourceFiles(options)` instead.
832/// To be removed after 0.15.0 is tagged.
822833pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
823834 compile.root_module.addCSourceFiles(options);
824835}
825836
837/// Deprecated; use `compile.root_module.addCSourceFile(source)` instead.
838/// To be removed after 0.15.0 is tagged.
826839pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void {
827840 compile.root_module.addCSourceFile(source);
828841}
829842
830/// Resource files must have the extension `.rc`.
831/// Can be called regardless of target. The .rc file will be ignored
832/// if the target object format does not support embedded resources.
843/// Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead.
844/// To be removed after 0.15.0 is tagged.
833845pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void {
834846 compile.root_module.addWin32ResourceFile(source);
835847}
......@@ -915,54 +927,80 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
915927 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
916928}
917929
930/// Deprecated; use `compile.root_module.addAssemblyFile(source)` instead.
931/// To be removed after 0.15.0 is tagged.
918932pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void {
919933 compile.root_module.addAssemblyFile(source);
920934}
921935
936/// Deprecated; use `compile.root_module.addObjectFile(source)` instead.
937/// To be removed after 0.15.0 is tagged.
922938pub fn addObjectFile(compile: *Compile, source: LazyPath) void {
923939 compile.root_module.addObjectFile(source);
924940}
925941
942/// Deprecated; use `compile.root_module.addObject(object)` instead.
943/// To be removed after 0.15.0 is tagged.
926944pub fn addObject(compile: *Compile, object: *Compile) void {
927945 compile.root_module.addObject(object);
928946}
929947
948/// Deprecated; use `compile.root_module.linkLibrary(library)` instead.
949/// To be removed after 0.15.0 is tagged.
930950pub fn linkLibrary(compile: *Compile, library: *Compile) void {
931951 compile.root_module.linkLibrary(library);
932952}
933953
954/// Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead.
955/// To be removed after 0.15.0 is tagged.
934956pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void {
935957 compile.root_module.addAfterIncludePath(lazy_path);
936958}
937959
960/// Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead.
961/// To be removed after 0.15.0 is tagged.
938962pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void {
939963 compile.root_module.addSystemIncludePath(lazy_path);
940964}
941965
966/// Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead.
967/// To be removed after 0.15.0 is tagged.
942968pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void {
943969 compile.root_module.addIncludePath(lazy_path);
944970}
945971
972/// Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead.
973/// To be removed after 0.15.0 is tagged.
946974pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void {
947975 compile.root_module.addConfigHeader(config_header);
948976}
949977
978/// Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead.
979/// To be removed after 0.15.0 is tagged.
950980pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void {
951981 compile.root_module.addEmbedPath(lazy_path);
952982}
953983
984/// Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead.
985/// To be removed after 0.15.0 is tagged.
954986pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void {
955987 compile.root_module.addLibraryPath(directory_path);
956988}
957989
990/// Deprecated; use `compile.root_module.addRPath(directory_path)` instead.
991/// To be removed after 0.15.0 is tagged.
958992pub fn addRPath(compile: *Compile, directory_path: LazyPath) void {
959993 compile.root_module.addRPath(directory_path);
960994}
961995
996/// Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead.
997/// To be removed after 0.15.0 is tagged.
962998pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
963999 compile.root_module.addSystemFrameworkPath(directory_path);
9641000}
9651001
1002/// Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead.
1003/// To be removed after 0.15.0 is tagged.
9661004pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
9671005 compile.root_module.addFrameworkPath(directory_path);
9681006}
test/link/elf.zig+369-369
......@@ -210,8 +210,8 @@ fn testAbsSymbols(b: *Build, opts: Options) *Step {
210210 \\}
211211 ,
212212 });
213 exe.addObject(obj);
214 exe.linkLibC();
213 exe.root_module.addObject(obj);
214 exe.root_module.link_libc = true;
215215
216216 const run = addRunArtifact(exe);
217217 run.expectExitCode(0);
......@@ -235,7 +235,7 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
235235 \\
236236 ,
237237 });
238 main_o.linkLibC();
238 main_o.root_module.link_libc = true;
239239
240240 const libfoo = addSharedLibrary(b, opts, .{ .name = "foo" });
241241 addCSourceBytes(libfoo, "int foo() { return 42; }", &.{});
......@@ -253,17 +253,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
253253 const exe = addExecutable(b, opts, .{
254254 .name = "test",
255255 });
256 exe.addObject(main_o);
257 exe.linkSystemLibrary2("foo", .{ .needed = true });
258 exe.addLibraryPath(libfoo.getEmittedBinDirectory());
259 exe.addRPath(libfoo.getEmittedBinDirectory());
260 exe.linkSystemLibrary2("bar", .{ .needed = true });
261 exe.addLibraryPath(libbar.getEmittedBinDirectory());
262 exe.addRPath(libbar.getEmittedBinDirectory());
263 exe.linkSystemLibrary2("baz", .{ .needed = true });
264 exe.addLibraryPath(libbaz.getEmittedBinDirectory());
265 exe.addRPath(libbaz.getEmittedBinDirectory());
266 exe.linkLibC();
256 exe.root_module.addObject(main_o);
257 exe.root_module.linkSystemLibrary("foo", .{ .needed = true });
258 exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory());
259 exe.root_module.addRPath(libfoo.getEmittedBinDirectory());
260 exe.root_module.linkSystemLibrary("bar", .{ .needed = true });
261 exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory());
262 exe.root_module.addRPath(libbar.getEmittedBinDirectory());
263 exe.root_module.linkSystemLibrary("baz", .{ .needed = true });
264 exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory());
265 exe.root_module.addRPath(libbaz.getEmittedBinDirectory());
266 exe.root_module.link_libc = true;
267267
268268 const run = addRunArtifact(exe);
269269 run.expectStdOutEqual("42\n");
......@@ -281,17 +281,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
281281 const exe = addExecutable(b, opts, .{
282282 .name = "test",
283283 });
284 exe.addObject(main_o);
285 exe.linkSystemLibrary2("foo", .{ .needed = false });
286 exe.addLibraryPath(libfoo.getEmittedBinDirectory());
287 exe.addRPath(libfoo.getEmittedBinDirectory());
288 exe.linkSystemLibrary2("bar", .{ .needed = false });
289 exe.addLibraryPath(libbar.getEmittedBinDirectory());
290 exe.addRPath(libbar.getEmittedBinDirectory());
291 exe.linkSystemLibrary2("baz", .{ .needed = false });
292 exe.addLibraryPath(libbaz.getEmittedBinDirectory());
293 exe.addRPath(libbaz.getEmittedBinDirectory());
294 exe.linkLibC();
284 exe.root_module.addObject(main_o);
285 exe.root_module.linkSystemLibrary("foo", .{ .needed = false });
286 exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory());
287 exe.root_module.addRPath(libfoo.getEmittedBinDirectory());
288 exe.root_module.linkSystemLibrary("bar", .{ .needed = false });
289 exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory());
290 exe.root_module.addRPath(libbar.getEmittedBinDirectory());
291 exe.root_module.linkSystemLibrary("baz", .{ .needed = false });
292 exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory());
293 exe.root_module.addRPath(libbaz.getEmittedBinDirectory());
294 exe.root_module.link_libc = true;
295295
296296 const run = addRunArtifact(exe);
297297 run.expectStdOutEqual("42\n");
......@@ -351,15 +351,15 @@ fn testCanonicalPlt(b: *Build, opts: Options) *Step {
351351 ,
352352 .pic = false,
353353 });
354 main_o.linkLibC();
354 main_o.root_module.link_libc = true;
355355
356356 const exe = addExecutable(b, opts, .{
357357 .name = "main",
358358 });
359 exe.addObject(main_o);
360 exe.addObject(b_o);
361 exe.linkLibrary(dso);
362 exe.linkLibC();
359 exe.root_module.addObject(main_o);
360 exe.root_module.addObject(b_o);
361 exe.root_module.linkLibrary(dso);
362 exe.root_module.link_libc = true;
363363 exe.pie = false;
364364
365365 const run = addRunArtifact(exe);
......@@ -384,7 +384,7 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
384384 \\}
385385 ,
386386 });
387 a_o.linkLibCpp();
387 a_o.root_module.link_libcpp = true;
388388
389389 const main_o = addObject(b, opts, .{
390390 .name = "main",
......@@ -401,13 +401,13 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
401401 \\}
402402 ,
403403 });
404 main_o.linkLibCpp();
404 main_o.root_module.link_libcpp = true;
405405
406406 {
407407 const exe = addExecutable(b, opts, .{ .name = "main1" });
408 exe.addObject(a_o);
409 exe.addObject(main_o);
410 exe.linkLibCpp();
408 exe.root_module.addObject(a_o);
409 exe.root_module.addObject(main_o);
410 exe.root_module.link_libcpp = true;
411411
412412 const run = addRunArtifact(exe);
413413 run.expectStdOutEqual(
......@@ -420,9 +420,9 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
420420
421421 {
422422 const exe = addExecutable(b, opts, .{ .name = "main2" });
423 exe.addObject(main_o);
424 exe.addObject(a_o);
425 exe.linkLibCpp();
423 exe.root_module.addObject(main_o);
424 exe.root_module.addObject(a_o);
425 exe.root_module.link_libcpp = true;
426426
427427 const run = addRunArtifact(exe);
428428 run.expectStdOutEqual(
......@@ -435,12 +435,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
435435
436436 {
437437 const c_o = addObject(b, opts, .{ .name = "c" });
438 c_o.addObject(main_o);
439 c_o.addObject(a_o);
438 c_o.root_module.addObject(main_o);
439 c_o.root_module.addObject(a_o);
440440
441441 const exe = addExecutable(b, opts, .{ .name = "main3" });
442 exe.addObject(c_o);
443 exe.linkLibCpp();
442 exe.root_module.addObject(c_o);
443 exe.root_module.link_libcpp = true;
444444
445445 const run = addRunArtifact(exe);
446446 run.expectStdOutEqual(
......@@ -453,12 +453,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
453453
454454 {
455455 const d_o = addObject(b, opts, .{ .name = "d" });
456 d_o.addObject(a_o);
457 d_o.addObject(main_o);
456 d_o.root_module.addObject(a_o);
457 d_o.root_module.addObject(main_o);
458458
459459 const exe = addExecutable(b, opts, .{ .name = "main4" });
460 exe.addObject(d_o);
461 exe.linkLibCpp();
460 exe.root_module.addObject(d_o);
461 exe.root_module.link_libcpp = true;
462462
463463 const run = addRunArtifact(exe);
464464 run.expectStdOutEqual(
......@@ -522,7 +522,7 @@ fn testCommonSymbols(b: *Build, opts: Options) *Step {
522522 \\ printf("%d %d %d\n", foo, bar, baz);
523523 \\}
524524 , &.{"-fcommon"});
525 exe.linkLibC();
525 exe.root_module.link_libc = true;
526526
527527 const run = addRunArtifact(exe);
528528 run.expectStdOutEqual("0 5 42\n");
......@@ -549,7 +549,7 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
549549 ,
550550 .c_source_flags = &.{"-fcommon"},
551551 });
552 a_o.linkLibC();
552 a_o.root_module.link_libc = true;
553553
554554 const b_o = addObject(b, opts, .{
555555 .name = "b",
......@@ -575,16 +575,16 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
575575 });
576576
577577 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
578 lib.addObject(b_o);
579 lib.addObject(c_o);
580 lib.addObject(d_o);
578 lib.root_module.addObject(b_o);
579 lib.root_module.addObject(c_o);
580 lib.root_module.addObject(d_o);
581581
582582 const exe = addExecutable(b, opts, .{
583583 .name = "test",
584584 });
585 exe.addObject(a_o);
586 exe.linkLibrary(lib);
587 exe.linkLibC();
585 exe.root_module.addObject(a_o);
586 exe.root_module.linkLibrary(lib);
587 exe.root_module.link_libc = true;
588588
589589 const run = addRunArtifact(exe);
590590 run.expectStdOutEqual("5 0 0 -1\n");
......@@ -603,15 +603,15 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
603603 });
604604
605605 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
606 lib.addObject(b_o);
607 lib.addObject(e_o);
606 lib.root_module.addObject(b_o);
607 lib.root_module.addObject(e_o);
608608
609609 const exe = addExecutable(b, opts, .{
610610 .name = "test",
611611 });
612 exe.addObject(a_o);
613 exe.linkLibrary(lib);
614 exe.linkLibC();
612 exe.root_module.addObject(a_o);
613 exe.root_module.linkLibrary(lib);
614 exe.root_module.link_libc = true;
615615
616616 const run = addRunArtifact(exe);
617617 run.expectStdOutEqual("5 0 7 2\n");
......@@ -641,8 +641,8 @@ fn testCopyrel(b: *Build, opts: Options) *Step {
641641 \\}
642642 ,
643643 });
644 exe.linkLibrary(dso);
645 exe.linkLibC();
644 exe.root_module.linkLibrary(dso);
645 exe.root_module.link_libc = true;
646646
647647 const run = addRunArtifact(exe);
648648 run.expectStdOutEqual("3 5\n");
......@@ -679,8 +679,8 @@ fn testCopyrelAlias(b: *Build, opts: Options) *Step {
679679 \\extern int bar;
680680 \\int *get_bar() { return &bar; }
681681 , &.{});
682 exe.linkLibrary(dso);
683 exe.linkLibC();
682 exe.root_module.linkLibrary(dso);
683 exe.root_module.link_libc = true;
684684 exe.pie = false;
685685
686686 const run = addRunArtifact(exe);
......@@ -712,15 +712,15 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
712712 ,
713713 .pic = false,
714714 });
715 obj.linkLibC();
715 obj.root_module.link_libc = true;
716716
717717 const exp_stdout = "5\n";
718718
719719 {
720720 const exe = addExecutable(b, opts, .{ .name = "main" });
721 exe.addObject(obj);
722 exe.linkLibrary(a_so);
723 exe.linkLibC();
721 exe.root_module.addObject(obj);
722 exe.root_module.linkLibrary(a_so);
723 exe.root_module.link_libc = true;
724724 exe.pie = false;
725725
726726 const run = addRunArtifact(exe);
......@@ -737,9 +737,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
737737
738738 {
739739 const exe = addExecutable(b, opts, .{ .name = "main" });
740 exe.addObject(obj);
741 exe.linkLibrary(b_so);
742 exe.linkLibC();
740 exe.root_module.addObject(obj);
741 exe.root_module.linkLibrary(b_so);
742 exe.root_module.link_libc = true;
743743 exe.pie = false;
744744
745745 const run = addRunArtifact(exe);
......@@ -756,9 +756,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
756756
757757 {
758758 const exe = addExecutable(b, opts, .{ .name = "main" });
759 exe.addObject(obj);
760 exe.linkLibrary(c_so);
761 exe.linkLibC();
759 exe.root_module.addObject(obj);
760 exe.root_module.linkLibrary(c_so);
761 exe.root_module.link_libc = true;
762762 exe.pie = false;
763763
764764 const run = addRunArtifact(exe);
......@@ -793,7 +793,7 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {
793793 \\ real_hello();
794794 \\}
795795 , &.{});
796 dso.linkLibC();
796 dso.root_module.link_libc = true;
797797
798798 const exe = addExecutable(b, opts, .{ .name = "test" });
799799 addCSourceBytes(exe,
......@@ -806,8 +806,8 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {
806806 \\ hello();
807807 \\}
808808 , &.{});
809 exe.linkLibrary(dso);
810 exe.linkLibC();
809 exe.root_module.linkLibrary(dso);
810 exe.root_module.link_libc = true;
811811
812812 const run = addRunArtifact(exe);
813813 run.expectStdOutEqual("Hello WORLD\n");
......@@ -825,7 +825,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
825825 \\int bar = 5;
826826 \\int baz() { return foo; }
827827 , &.{});
828 dso.linkLibC();
828 dso.root_module.link_libc = true;
829829
830830 const obj = addObject(b, opts, .{
831831 .name = "obj",
......@@ -833,18 +833,18 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
833833 });
834834
835835 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
836 lib.addObject(obj);
836 lib.root_module.addObject(obj);
837837
838838 const exe = addExecutable(b, opts, .{ .name = "test" });
839 exe.linkLibrary(dso);
840 exe.linkLibrary(lib);
839 exe.root_module.linkLibrary(dso);
840 exe.root_module.linkLibrary(lib);
841841 addCSourceBytes(exe,
842842 \\extern int bar;
843843 \\int main() {
844844 \\ return bar - 5;
845845 \\}
846846 , &.{});
847 exe.linkLibC();
847 exe.root_module.link_libc = true;
848848
849849 const run = addRunArtifact(exe);
850850 run.expectExitCode(0);
......@@ -871,7 +871,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
871871 \\ std.debug.print("foo={d}\n", .{foo()});
872872 \\}
873873 });
874 a_o.linkLibC();
874 a_o.root_module.link_libc = true;
875875
876876 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
877877 \\#include <stdio.h>
......@@ -880,11 +880,11 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
880880 \\ fprintf(stderr, "bar=%d\n", bar);
881881 \\}
882882 });
883 b_o.linkLibC();
883 b_o.root_module.link_libc = true;
884884
885885 const c_o = addObject(b, opts, .{ .name = "c" });
886 c_o.addObject(a_o);
887 c_o.addObject(b_o);
886 c_o.root_module.addObject(a_o);
887 c_o.root_module.addObject(b_o);
888888
889889 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
890890 \\const std = @import("std");
......@@ -895,8 +895,8 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
895895 \\ printBar();
896896 \\}
897897 });
898 exe.addObject(c_o);
899 exe.linkLibC();
898 exe.root_module.addObject(c_o);
899 exe.root_module.link_libc = true;
900900
901901 const run = addRunArtifact(exe);
902902 run.expectStdErrEqual(
......@@ -944,9 +944,9 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {
944944 });
945945
946946 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
947 lib.addObject(obj1);
948 lib.addObject(obj2);
949 lib.addObject(obj3);
947 lib.root_module.addObject(obj1);
948 lib.root_module.addObject(obj2);
949 lib.root_module.addObject(obj3);
950950
951951 const check = lib.checkObject();
952952 check.checkInArchiveSymtab();
......@@ -996,7 +996,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {
996996 \\}
997997 ,
998998 });
999 lib.addObject(obj1);
999 lib.root_module.addObject(obj1);
10001000
10011001 const exe = addExecutable(b, opts, .{
10021002 .name = "test",
......@@ -1008,7 +1008,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {
10081008 \\}
10091009 ,
10101010 });
1011 exe.linkLibrary(lib);
1011 exe.root_module.linkLibrary(lib);
10121012
10131013 const run = addRunArtifact(exe);
10141014 run.expectStdErrEqual("44");
......@@ -1023,7 +1023,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
10231023 const exe = addExecutable(b, opts, .{ .name = "test" });
10241024 addCSourceBytes(exe, "int main() { return 0; }", &.{});
10251025 addCSourceBytes(exe, "", &.{});
1026 exe.linkLibC();
1026 exe.root_module.link_libc = true;
10271027
10281028 const run = addRunArtifact(exe);
10291029 run.expectExitCode(0);
......@@ -1052,8 +1052,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {
10521052
10531053 {
10541054 const exe = addExecutable(b, opts, .{ .name = "main" });
1055 exe.addObject(a_o);
1056 exe.addObject(b_o);
1055 exe.root_module.addObject(a_o);
1056 exe.root_module.addObject(b_o);
10571057 exe.entry = .{ .symbol_name = "foo" };
10581058
10591059 const check = exe.checkObject();
......@@ -1068,8 +1068,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {
10681068 // cause an artifact collision taking the cached executable from the above
10691069 // step instead of generating a new one.
10701070 const exe = addExecutable(b, opts, .{ .name = "other" });
1071 exe.addObject(a_o);
1072 exe.addObject(b_o);
1071 exe.root_module.addObject(a_o);
1072 exe.root_module.addObject(b_o);
10731073 exe.entry = .{ .symbol_name = "bar" };
10741074
10751075 const check = exe.checkObject();
......@@ -1113,8 +1113,8 @@ fn testExportDynamic(b: *Build, opts: Options) *Step {
11131113 \\ return baz;
11141114 \\}
11151115 , &.{});
1116 exe.addObject(obj);
1117 exe.linkLibrary(dso);
1116 exe.root_module.addObject(obj);
1117 exe.root_module.linkLibrary(dso);
11181118 exe.rdynamic = true;
11191119
11201120 const check = exe.checkObject();
......@@ -1152,8 +1152,8 @@ fn testExportSymbolsFromExe(b: *Build, opts: Options) *Step {
11521152 \\ foo();
11531153 \\}
11541154 , &.{});
1155 exe.linkLibrary(dso);
1156 exe.linkLibC();
1155 exe.root_module.linkLibrary(dso);
1156 exe.root_module.link_libc = true;
11571157
11581158 const check = exe.checkObject();
11591159 check.checkInDynamicSymtab();
......@@ -1181,7 +1181,7 @@ fn testFuncAddress(b: *Build, opts: Options) *Step {
11811181 \\ assert(fn == ptr);
11821182 \\}
11831183 , &.{});
1184 exe.linkLibrary(dso);
1184 exe.root_module.linkLibrary(dso);
11851185 exe.root_module.pic = false;
11861186 exe.pie = false;
11871187
......@@ -1216,15 +1216,15 @@ fn testGcSections(b: *Build, opts: Options) *Step {
12161216 });
12171217 obj.link_function_sections = true;
12181218 obj.link_data_sections = true;
1219 obj.linkLibC();
1220 obj.linkLibCpp();
1219 obj.root_module.link_libc = true;
1220 obj.root_module.link_libcpp = true;
12211221
12221222 {
12231223 const exe = addExecutable(b, opts, .{ .name = "test" });
1224 exe.addObject(obj);
1224 exe.root_module.addObject(obj);
12251225 exe.link_gc_sections = false;
1226 exe.linkLibC();
1227 exe.linkLibCpp();
1226 exe.root_module.link_libc = true;
1227 exe.root_module.link_libcpp = true;
12281228
12291229 const run = addRunArtifact(exe);
12301230 run.expectStdOutEqual("1 2\n");
......@@ -1252,10 +1252,10 @@ fn testGcSections(b: *Build, opts: Options) *Step {
12521252
12531253 {
12541254 const exe = addExecutable(b, opts, .{ .name = "test" });
1255 exe.addObject(obj);
1255 exe.root_module.addObject(obj);
12561256 exe.link_gc_sections = true;
1257 exe.linkLibC();
1258 exe.linkLibCpp();
1257 exe.root_module.link_libc = true;
1258 exe.root_module.link_libcpp = true;
12591259
12601260 const run = addRunArtifact(exe);
12611261 run.expectStdOutEqual("1 2\n");
......@@ -1321,7 +1321,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
13211321 \\}
13221322 ,
13231323 });
1324 exe.addObject(obj);
1324 exe.root_module.addObject(obj);
13251325 exe.link_gc_sections = false;
13261326
13271327 const run = addRunArtifact(exe);
......@@ -1363,7 +1363,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
13631363 \\}
13641364 ,
13651365 });
1366 exe.addObject(obj);
1366 exe.root_module.addObject(obj);
13671367 exe.link_gc_sections = true;
13681368
13691369 const run = addRunArtifact(exe);
......@@ -1427,7 +1427,7 @@ fn testIFuncAlias(b: *Build, opts: Options) *Step {
14271427 \\}
14281428 , &.{});
14291429 exe.root_module.pic = true;
1430 exe.linkLibC();
1430 exe.root_module.link_libc = true;
14311431
14321432 const run = addRunArtifact(exe);
14331433 run.expectExitCode(0);
......@@ -1467,9 +1467,9 @@ fn testIFuncDlopen(b: *Build, opts: Options) *Step {
14671467 \\ assert(foo == p);
14681468 \\}
14691469 , &.{});
1470 exe.linkLibrary(dso);
1471 exe.linkLibC();
1472 exe.linkSystemLibrary2("dl", .{});
1470 exe.root_module.linkLibrary(dso);
1471 exe.root_module.link_libc = true;
1472 exe.root_module.linkSystemLibrary("dl", .{});
14731473 exe.root_module.pic = false;
14741474 exe.pie = false;
14751475
......@@ -1498,7 +1498,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {
14981498 \\}
14991499 ,
15001500 });
1501 dso.linkLibC();
1501 dso.root_module.link_libc = true;
15021502
15031503 const exe = addExecutable(b, opts, .{
15041504 .name = "main",
......@@ -1509,7 +1509,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {
15091509 \\}
15101510 ,
15111511 });
1512 exe.linkLibrary(dso);
1512 exe.root_module.linkLibrary(dso);
15131513
15141514 const run = addRunArtifact(exe);
15151515 run.expectStdOutEqual("Hello world\n");
......@@ -1540,7 +1540,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {
15401540 {
15411541 const exe = addExecutable(b, opts, .{ .name = "main" });
15421542 addCSourceBytes(exe, main_c, &.{});
1543 exe.linkLibC();
1543 exe.root_module.link_libc = true;
15441544 exe.link_z_lazy = true;
15451545
15461546 const run = addRunArtifact(exe);
......@@ -1550,7 +1550,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {
15501550 {
15511551 const exe = addExecutable(b, opts, .{ .name = "other" });
15521552 addCSourceBytes(exe, main_c, &.{});
1553 exe.linkLibC();
1553 exe.root_module.link_libc = true;
15541554
15551555 const run = addRunArtifact(exe);
15561556 run.expectStdOutEqual("Hello world\n");
......@@ -1576,7 +1576,7 @@ fn testIFuncExport(b: *Build, opts: Options) *Step {
15761576 \\ return real_foobar;
15771577 \\}
15781578 , &.{});
1579 dso.linkLibC();
1579 dso.root_module.link_libc = true;
15801580
15811581 const check = dso.checkObject();
15821582 check.checkInDynamicSymtab();
......@@ -1613,7 +1613,7 @@ fn testIFuncFuncPtr(b: *Build, opts: Options) *Step {
16131613 \\}
16141614 , &.{});
16151615 exe.root_module.pic = true;
1616 exe.linkLibC();
1616 exe.root_module.link_libc = true;
16171617
16181618 const run = addRunArtifact(exe);
16191619 run.expectStdOutEqual("3\n");
......@@ -1642,7 +1642,7 @@ fn testIFuncNoPlt(b: *Build, opts: Options) *Step {
16421642 \\}
16431643 , &.{"-fno-plt"});
16441644 exe.root_module.pic = true;
1645 exe.linkLibC();
1645 exe.root_module.link_libc = true;
16461646
16471647 const run = addRunArtifact(exe);
16481648 run.expectStdOutEqual("Hello world\n");
......@@ -1669,7 +1669,7 @@ fn testIFuncStatic(b: *Build, opts: Options) *Step {
16691669 \\ return 0;
16701670 \\}
16711671 , &.{});
1672 exe.linkLibC();
1672 exe.root_module.link_libc = true;
16731673 exe.linkage = .static;
16741674
16751675 const run = addRunArtifact(exe);
......@@ -1700,7 +1700,7 @@ fn testIFuncStaticPie(b: *Build, opts: Options) *Step {
17001700 exe.linkage = .static;
17011701 exe.root_module.pic = true;
17021702 exe.pie = true;
1703 exe.linkLibC();
1703 exe.root_module.link_libc = true;
17041704
17051705 const run = addRunArtifact(exe);
17061706 run.expectStdOutEqual("Hello world\n");
......@@ -1733,7 +1733,7 @@ fn testImageBase(b: *Build, opts: Options) *Step {
17331733 \\ return 0;
17341734 \\}
17351735 , &.{});
1736 exe.linkLibC();
1736 exe.root_module.link_libc = true;
17371737 exe.image_base = 0x8000000;
17381738
17391739 const run = addRunArtifact(exe);
......@@ -1779,7 +1779,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
17791779 \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); }
17801780 ,
17811781 });
1782 dso.linkLibC();
1782 dso.root_module.link_libc = true;
17831783
17841784 const main = addExecutable(b, opts, .{
17851785 .name = "main",
......@@ -1798,7 +1798,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
17981798 .strip = true, // TODO temp hack
17991799 });
18001800 main.pie = true;
1801 main.linkLibrary(dso);
1801 main.root_module.linkLibrary(dso);
18021802
18031803 const run = addRunArtifact(main);
18041804 run.expectStdErrEqual(
......@@ -1832,7 +1832,7 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {
18321832 }, .{
18331833 .name = "a",
18341834 });
1835 lib.addObject(obj);
1835 lib.root_module.addObject(obj);
18361836
18371837 const main = addExecutable(b, opts, .{
18381838 .name = "main",
......@@ -1844,8 +1844,8 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {
18441844 ,
18451845 .strip = true, // TODO temp hack
18461846 });
1847 main.linkLibrary(lib);
1848 main.linkLibC();
1847 main.root_module.linkLibrary(lib);
1848 main.root_module.link_libc = true;
18491849
18501850 const run = addRunArtifact(main);
18511851 run.expectStdErrEqual("42\n");
......@@ -1864,7 +1864,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
18641864 \\__attribute__((constructor(10000))) void init4() { printf("1"); }
18651865 ,
18661866 });
1867 a_o.linkLibC();
1867 a_o.root_module.link_libc = true;
18681868
18691869 const b_o = addObject(b, opts, .{
18701870 .name = "b",
......@@ -1873,7 +1873,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
18731873 \\__attribute__((constructor(1000))) void init3() { printf("2"); }
18741874 ,
18751875 });
1876 b_o.linkLibC();
1876 b_o.root_module.link_libc = true;
18771877
18781878 const c_o = addObject(b, opts, .{
18791879 .name = "c",
......@@ -1882,7 +1882,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
18821882 \\__attribute__((constructor)) void init1() { printf("3"); }
18831883 ,
18841884 });
1885 c_o.linkLibC();
1885 c_o.root_module.link_libc = true;
18861886
18871887 const d_o = addObject(b, opts, .{
18881888 .name = "d",
......@@ -1891,7 +1891,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
18911891 \\__attribute__((constructor)) void init2() { printf("4"); }
18921892 ,
18931893 });
1894 d_o.linkLibC();
1894 d_o.root_module.link_libc = true;
18951895
18961896 const e_o = addObject(b, opts, .{
18971897 .name = "e",
......@@ -1900,7 +1900,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
19001900 \\__attribute__((destructor(10000))) void fini4() { printf("5"); }
19011901 ,
19021902 });
1903 e_o.linkLibC();
1903 e_o.root_module.link_libc = true;
19041904
19051905 const f_o = addObject(b, opts, .{
19061906 .name = "f",
......@@ -1909,7 +1909,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
19091909 \\__attribute__((destructor(1000))) void fini3() { printf("6"); }
19101910 ,
19111911 });
1912 f_o.linkLibC();
1912 f_o.root_module.link_libc = true;
19131913
19141914 const g_o = addObject(b, opts, .{
19151915 .name = "g",
......@@ -1918,24 +1918,24 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
19181918 \\__attribute__((destructor)) void fini1() { printf("7"); }
19191919 ,
19201920 });
1921 g_o.linkLibC();
1921 g_o.root_module.link_libc = true;
19221922
19231923 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
19241924 \\#include <stdio.h>
19251925 \\__attribute__((destructor)) void fini2() { printf("8"); }
19261926 });
1927 h_o.linkLibC();
1927 h_o.root_module.link_libc = true;
19281928
19291929 const exe = addExecutable(b, opts, .{ .name = "main" });
19301930 addCSourceBytes(exe, "int main() { return 0; }", &.{});
1931 exe.addObject(a_o);
1932 exe.addObject(b_o);
1933 exe.addObject(c_o);
1934 exe.addObject(d_o);
1935 exe.addObject(e_o);
1936 exe.addObject(f_o);
1937 exe.addObject(g_o);
1938 exe.addObject(h_o);
1931 exe.root_module.addObject(a_o);
1932 exe.root_module.addObject(b_o);
1933 exe.root_module.addObject(c_o);
1934 exe.root_module.addObject(d_o);
1935 exe.root_module.addObject(e_o);
1936 exe.root_module.addObject(f_o);
1937 exe.root_module.addObject(g_o);
1938 exe.root_module.addObject(h_o);
19391939
19401940 if (opts.target.result.isGnuLibC()) {
19411941 // TODO I think we need to clarify our use of `-fPIC -fPIE` flags for different targets
......@@ -1970,7 +1970,7 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step {
19701970 \\}
19711971 , &.{});
19721972 dso.link_function_sections = true;
1973 dso.linkLibC();
1973 dso.root_module.link_libc = true;
19741974
19751975 const check = dso.checkObject();
19761976 check.checkInSymtab();
......@@ -1986,8 +1986,8 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step {
19861986 \\void greet();
19871987 \\int main() { greet(); }
19881988 , &.{});
1989 exe.linkLibrary(dso);
1990 exe.linkLibC();
1989 exe.root_module.linkLibrary(dso);
1990 exe.root_module.link_libc = true;
19911991
19921992 const run = addRunArtifact(exe);
19931993 run.expectStdOutEqual("Hello world");
......@@ -2021,7 +2021,7 @@ fn testLargeAlignmentExe(b: *Build, opts: Options) *Step {
20212021 \\}
20222022 , &.{});
20232023 exe.link_function_sections = true;
2024 exe.linkLibC();
2024 exe.root_module.link_libc = true;
20252025
20262026 const check = exe.checkObject();
20272027 check.checkInSymtab();
......@@ -2049,7 +2049,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step {
20492049 \\ return arr[2000];
20502050 \\}
20512051 , &.{});
2052 exe.linkLibC();
2052 exe.root_module.link_libc = true;
20532053 // Disabled to work around the ELF linker crashing.
20542054 // Can be reproduced on a x86_64-linux host by commenting out the line below.
20552055 exe.root_module.sanitize_c = .off;
......@@ -2071,10 +2071,10 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
20712071 });
20722072
20732073 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
2074 dso.addObject(obj);
2074 dso.root_module.addObject(obj);
20752075
20762076 const lib = addStaticLibrary(b, opts, .{ .name = "b" });
2077 lib.addObject(obj);
2077 lib.root_module.addObject(obj);
20782078
20792079 const main_o = addObject(b, opts, .{
20802080 .name = "main",
......@@ -2089,14 +2089,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
20892089 // https://github.com/ziglang/zig/issues/17450
20902090 // {
20912091 // const exe = addExecutable(b, opts, .{ .name = "main1"});
2092 // exe.addObject(main_o);
2093 // exe.linkSystemLibrary2("a", .{});
2094 // exe.addLibraryPath(dso.getEmittedBinDirectory());
2095 // exe.addRPath(dso.getEmittedBinDirectory());
2096 // exe.linkSystemLibrary2("b", .{});
2097 // exe.addLibraryPath(lib.getEmittedBinDirectory());
2098 // exe.addRPath(lib.getEmittedBinDirectory());
2099 // exe.linkLibC();
2092 // exe.root_module.addObject(main_o);
2093 // exe.root_module.linkSystemLibrary("a", .{});
2094 // exe.root_module.addLibraryPath(dso.getEmittedBinDirectory());
2095 // exe.root_module.addRPath(dso.getEmittedBinDirectory());
2096 // exe.root_module.linkSystemLibrary("b", .{});
2097 // exe.root_module.addLibraryPath(lib.getEmittedBinDirectory());
2098 // exe.root_module.addRPath(lib.getEmittedBinDirectory());
2099 // exe.root_module.link_libc = true;
21002100
21012101 // const check = exe.checkObject();
21022102 // check.checkInDynamicSection();
......@@ -2106,14 +2106,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
21062106
21072107 {
21082108 const exe = addExecutable(b, opts, .{ .name = "main2" });
2109 exe.addObject(main_o);
2110 exe.linkSystemLibrary2("b", .{});
2111 exe.addLibraryPath(lib.getEmittedBinDirectory());
2112 exe.addRPath(lib.getEmittedBinDirectory());
2113 exe.linkSystemLibrary2("a", .{});
2114 exe.addLibraryPath(dso.getEmittedBinDirectory());
2115 exe.addRPath(dso.getEmittedBinDirectory());
2116 exe.linkLibC();
2109 exe.root_module.addObject(main_o);
2110 exe.root_module.linkSystemLibrary("b", .{});
2111 exe.root_module.addLibraryPath(lib.getEmittedBinDirectory());
2112 exe.root_module.addRPath(lib.getEmittedBinDirectory());
2113 exe.root_module.linkSystemLibrary("a", .{});
2114 exe.root_module.addLibraryPath(dso.getEmittedBinDirectory());
2115 exe.root_module.addRPath(dso.getEmittedBinDirectory());
2116 exe.root_module.link_libc = true;
21172117
21182118 const check = exe.checkObject();
21192119 check.checkInDynamicSection();
......@@ -2149,14 +2149,14 @@ fn testLdScript(b: *Build, opts: Options) *Step {
21492149 \\ return bar() - baz();
21502150 \\}
21512151 , &.{});
2152 exe.linkSystemLibrary2("a", .{});
2153 exe.addLibraryPath(scripts.getDirectory());
2154 exe.addLibraryPath(scripts2.getDirectory());
2155 exe.addLibraryPath(bar.getEmittedBinDirectory());
2156 exe.addLibraryPath(baz.getEmittedBinDirectory());
2157 exe.addRPath(bar.getEmittedBinDirectory());
2158 exe.addRPath(baz.getEmittedBinDirectory());
2159 exe.linkLibC();
2152 exe.root_module.linkSystemLibrary("a", .{});
2153 exe.root_module.addLibraryPath(scripts.getDirectory());
2154 exe.root_module.addLibraryPath(scripts2.getDirectory());
2155 exe.root_module.addLibraryPath(bar.getEmittedBinDirectory());
2156 exe.root_module.addLibraryPath(baz.getEmittedBinDirectory());
2157 exe.root_module.addRPath(bar.getEmittedBinDirectory());
2158 exe.root_module.addRPath(baz.getEmittedBinDirectory());
2159 exe.root_module.link_libc = true;
21602160 exe.allow_so_scripts = true;
21612161
21622162 const run = addRunArtifact(exe);
......@@ -2174,9 +2174,9 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step {
21742174
21752175 const exe = addExecutable(b, opts, .{ .name = "main" });
21762176 addCSourceBytes(exe, "int main() { return 0; }", &.{});
2177 exe.linkSystemLibrary2("a", .{});
2178 exe.addLibraryPath(scripts.getDirectory());
2179 exe.linkLibC();
2177 exe.root_module.linkSystemLibrary("a", .{});
2178 exe.root_module.addLibraryPath(scripts.getDirectory());
2179 exe.root_module.link_libc = true;
21802180 exe.allow_so_scripts = true;
21812181
21822182 // TODO: A future enhancement could make this error message also mention
......@@ -2213,8 +2213,8 @@ fn testLdScriptAllowUndefinedVersion(b: *Build, opts: Options) *Step {
22132213 \\}
22142214 ,
22152215 });
2216 exe.linkLibrary(so);
2217 exe.linkLibC();
2216 exe.root_module.linkLibrary(so);
2217 exe.root_module.link_libc = true;
22182218 exe.allow_so_scripts = true;
22192219
22202220 const run = addRunArtifact(exe);
......@@ -2269,8 +2269,8 @@ fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step {
22692269 \\ return foo;
22702270 \\}
22712271 , &.{});
2272 exe.addObject(obj);
2273 exe.linkLibC();
2272 exe.root_module.addObject(obj);
2273 exe.root_module.link_libc = true;
22742274
22752275 expectLinkErrors(exe, test_step, .{ .exact = &.{
22762276 "invalid ELF machine type: AARCH64",
......@@ -2291,7 +2291,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step {
22912291 \\ return 0;
22922292 \\}
22932293 , &.{});
2294 exe.linkLibC();
2294 exe.root_module.link_libc = true;
22952295
22962296 const run = addRunArtifact(exe);
22972297 run.expectStdOutEqual("Hello World!\n");
......@@ -2320,8 +2320,8 @@ fn testLinkingCpp(b: *Build, opts: Options) *Step {
23202320 \\ return 0;
23212321 \\}
23222322 , &.{});
2323 exe.linkLibC();
2324 exe.linkLibCpp();
2323 exe.root_module.link_libc = true;
2324 exe.root_module.link_libcpp = true;
23252325
23262326 const run = addRunArtifact(exe);
23272327 run.expectStdOutEqual("Hello World!\n");
......@@ -2364,7 +2364,7 @@ fn testLinkingObj(b: *Build, opts: Options) *Step {
23642364 \\}
23652365 ,
23662366 });
2367 exe.addObject(obj);
2367 exe.root_module.addObject(obj);
23682368
23692369 const run = addRunArtifact(exe);
23702370 run.expectStdErrEqual("84\n");
......@@ -2389,7 +2389,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
23892389 \\}
23902390 ,
23912391 });
2392 lib.addObject(obj);
2392 lib.root_module.addObject(obj);
23932393
23942394 const exe = addExecutable(b, opts, .{
23952395 .name = "testlib",
......@@ -2402,7 +2402,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
24022402 \\}
24032403 ,
24042404 });
2405 exe.linkLibrary(lib);
2405 exe.root_module.linkLibrary(lib);
24062406
24072407 const run = addRunArtifact(exe);
24082408 run.expectStdErrEqual("0\n");
......@@ -2452,7 +2452,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
24522452 \\char16_t *utf16_1 = u"foo";
24532453 \\char32_t *utf32_1 = U"foo";
24542454 , &.{"-O2"});
2455 obj1.linkLibC();
2455 obj1.root_module.link_libc = true;
24562456
24572457 const obj2 = addObject(b, opts, .{ .name = "b.o" });
24582458 addCSourceBytes(obj2,
......@@ -2481,12 +2481,12 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
24812481 \\ assert((void*)wide1 != (void*)utf16_1);
24822482 \\}
24832483 , &.{"-O2"});
2484 obj2.linkLibC();
2484 obj2.root_module.link_libc = true;
24852485
24862486 const exe = addExecutable(b, opts, .{ .name = "main" });
2487 exe.addObject(obj1);
2488 exe.addObject(obj2);
2489 exe.linkLibC();
2487 exe.root_module.addObject(obj1);
2488 exe.root_module.addObject(obj2);
2489 exe.root_module.link_libc = true;
24902490
24912491 const run = addRunArtifact(exe);
24922492 run.expectExitCode(0);
......@@ -2520,8 +2520,8 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
25202520
25212521 {
25222522 const exe = addExecutable(b, opts, .{ .name = "main1" });
2523 exe.addObject(obj1);
2524 exe.addObject(obj2);
2523 exe.root_module.addObject(obj1);
2524 exe.root_module.addObject(obj2);
25252525
25262526 const run = addRunArtifact(exe);
25272527 run.expectExitCode(0);
......@@ -2537,11 +2537,11 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
25372537
25382538 {
25392539 const obj3 = addObject(b, opts, .{ .name = "c" });
2540 obj3.addObject(obj1);
2541 obj3.addObject(obj2);
2540 obj3.root_module.addObject(obj1);
2541 obj3.root_module.addObject(obj2);
25422542
25432543 const exe = addExecutable(b, opts, .{ .name = "main2" });
2544 exe.addObject(obj3);
2544 exe.root_module.addObject(obj3);
25452545
25462546 const run = addRunArtifact(exe);
25472547 run.expectExitCode(0);
......@@ -2564,7 +2564,7 @@ fn testNoEhFrameHdr(b: *Build, opts: Options) *Step {
25642564 const exe = addExecutable(b, opts, .{ .name = "main" });
25652565 addCSourceBytes(exe, "int main() { return 0; }", &.{});
25662566 exe.link_eh_frame_hdr = false;
2567 exe.linkLibC();
2567 exe.root_module.link_libc = true;
25682568
25692569 const check = exe.checkObject();
25702570 check.checkInHeaders();
......@@ -2586,7 +2586,7 @@ fn testPie(b: *Build, opts: Options) *Step {
25862586 \\ return 0;
25872587 \\}
25882588 , &.{});
2589 exe.linkLibC();
2589 exe.root_module.link_libc = true;
25902590 exe.root_module.pic = true;
25912591 exe.pie = true;
25922592
......@@ -2617,7 +2617,7 @@ fn testPltGot(b: *Build, opts: Options) *Step {
26172617 \\ printf("Hello world\n");
26182618 \\}
26192619 , &.{});
2620 dso.linkLibC();
2620 dso.root_module.link_libc = true;
26212621
26222622 const exe = addExecutable(b, opts, .{ .name = "main" });
26232623 addCSourceBytes(exe,
......@@ -2626,9 +2626,9 @@ fn testPltGot(b: *Build, opts: Options) *Step {
26262626 \\void foo() { ignore(hello); }
26272627 \\int main() { hello(); }
26282628 , &.{});
2629 exe.linkLibrary(dso);
2629 exe.root_module.linkLibrary(dso);
26302630 exe.root_module.pic = true;
2631 exe.linkLibC();
2631 exe.root_module.link_libc = true;
26322632
26332633 const run = addRunArtifact(exe);
26342634 run.expectStdOutEqual("Hello world\n");
......@@ -2647,7 +2647,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
26472647 });
26482648
26492649 const exe = addExecutable(b, opts, .{ .name = "main1" });
2650 exe.addObject(obj);
2650 exe.root_module.addObject(obj);
26512651
26522652 const check = exe.checkObject();
26532653 check.checkInDynamicSection();
......@@ -2662,7 +2662,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
26622662 \\__attribute__((section(".preinit_array")))
26632663 \\void *preinit[] = { preinit_fn };
26642664 , &.{});
2665 exe.linkLibC();
2665 exe.root_module.link_libc = true;
26662666
26672667 const check = exe.checkObject();
26682668 check.checkInDynamicSection();
......@@ -2710,15 +2710,15 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {
27102710 });
27112711
27122712 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
2713 lib.addObject(obj1);
2714 lib.addObject(obj2);
2715 lib.addObject(obj3);
2713 lib.root_module.addObject(obj1);
2714 lib.root_module.addObject(obj2);
2715 lib.root_module.addObject(obj3);
27162716
27172717 const obj5 = addObject(b, opts, .{
27182718 .name = "obj5",
27192719 });
2720 obj5.addObject(obj4);
2721 obj5.linkLibrary(lib);
2720 obj5.root_module.addObject(obj4);
2721 obj5.root_module.linkLibrary(lib);
27222722
27232723 const check = obj5.checkObject();
27242724 check.checkInSymtab();
......@@ -2744,7 +2744,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27442744 \\}
27452745 ,
27462746 });
2747 obj1.linkLibCpp();
2747 obj1.root_module.link_libcpp = true;
27482748 const obj2 = addObject(b, opts, .{
27492749 .name = "obj2",
27502750 .cpp_source_bytes =
......@@ -2754,7 +2754,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27542754 \\}
27552755 ,
27562756 });
2757 obj2.linkLibCpp();
2757 obj2.root_module.link_libcpp = true;
27582758 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
27592759 \\#include <iostream>
27602760 \\#include <stdexcept>
......@@ -2768,18 +2768,18 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27682768 \\ return 0;
27692769 \\}
27702770 });
2771 obj3.linkLibCpp();
2771 obj3.root_module.link_libcpp = true;
27722772
27732773 {
27742774 const obj = addObject(b, opts, .{ .name = "obj" });
2775 obj.addObject(obj1);
2776 obj.addObject(obj2);
2777 obj.linkLibCpp();
2775 obj.root_module.addObject(obj1);
2776 obj.root_module.addObject(obj2);
2777 obj.root_module.link_libcpp = true;
27782778
27792779 const exe = addExecutable(b, opts, .{ .name = "test1" });
2780 exe.addObject(obj3);
2781 exe.addObject(obj);
2782 exe.linkLibCpp();
2780 exe.root_module.addObject(obj3);
2781 exe.root_module.addObject(obj);
2782 exe.root_module.link_libcpp = true;
27832783
27842784 const run = addRunArtifact(exe);
27852785 run.expectStdOutEqual("exception=Oh no!");
......@@ -2788,14 +2788,14 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27882788 {
27892789 // Flipping the order should not influence the end result.
27902790 const obj = addObject(b, opts, .{ .name = "obj" });
2791 obj.addObject(obj2);
2792 obj.addObject(obj1);
2793 obj.linkLibCpp();
2791 obj.root_module.addObject(obj2);
2792 obj.root_module.addObject(obj1);
2793 obj.root_module.link_libcpp = true;
27942794
27952795 const exe = addExecutable(b, opts, .{ .name = "test2" });
2796 exe.addObject(obj3);
2797 exe.addObject(obj);
2798 exe.linkLibCpp();
2796 exe.root_module.addObject(obj3);
2797 exe.root_module.addObject(obj);
2798 exe.root_module.link_libcpp = true;
27992799
28002800 const run = addRunArtifact(exe);
28012801 run.expectStdOutEqual("exception=Oh no!");
......@@ -2817,7 +2817,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
28172817 \\}
28182818 ,
28192819 });
2820 obj1.linkLibCpp();
2820 obj1.root_module.link_libcpp = true;
28212821 const obj2 = addObject(b, opts, .{
28222822 .name = "obj2",
28232823 .cpp_source_bytes =
......@@ -2827,7 +2827,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
28272827 \\}
28282828 ,
28292829 });
2830 obj2.linkLibCpp();
2830 obj2.root_module.link_libcpp = true;
28312831 const obj3 = addObject(b, opts, .{
28322832 .name = "obj3",
28332833 .cpp_source_bytes =
......@@ -2844,17 +2844,17 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
28442844 \\}
28452845 ,
28462846 });
2847 obj3.linkLibCpp();
2847 obj3.root_module.link_libcpp = true;
28482848
28492849 const obj = addObject(b, opts, .{ .name = "obj" });
2850 obj.addObject(obj1);
2851 obj.addObject(obj2);
2852 obj.addObject(obj3);
2853 obj.linkLibCpp();
2850 obj.root_module.addObject(obj1);
2851 obj.root_module.addObject(obj2);
2852 obj.root_module.addObject(obj3);
2853 obj.root_module.link_libcpp = true;
28542854
28552855 const exe = addExecutable(b, opts, .{ .name = "test2" });
2856 exe.addObject(obj);
2857 exe.linkLibCpp();
2856 exe.root_module.addObject(obj);
2857 exe.root_module.link_libcpp = true;
28582858
28592859 const run = addRunArtifact(exe);
28602860 run.expectStdOutEqual("exception=Oh no!");
......@@ -2880,7 +2880,7 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
28802880 });
28812881
28822882 const obj2 = addObject(b, opts, .{ .name = "b" });
2883 obj2.addObject(obj1);
2883 obj2.root_module.addObject(obj1);
28842884
28852885 const check = obj2.checkObject();
28862886 check.dumpSection(".rodata.str1.1");
......@@ -2905,7 +2905,7 @@ fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step {
29052905 const obj2 = addObject(b, opts, .{
29062906 .name = "obj2",
29072907 });
2908 obj2.addObject(obj1);
2908 obj2.root_module.addObject(obj1);
29092909
29102910 const check1 = obj1.checkObject();
29112911 check1.checkInHeaders();
......@@ -2940,12 +2940,12 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
29402940 ,
29412941 .pic = true,
29422942 });
2943 obj.linkLibC();
2943 obj.root_module.link_libc = true;
29442944
29452945 {
29462946 const exe = addExecutable(b, opts, .{ .name = "main1" });
2947 exe.addObject(obj);
2948 exe.linkLibrary(dso);
2947 exe.root_module.addObject(obj);
2948 exe.root_module.linkLibrary(dso);
29492949 exe.pie = true;
29502950
29512951 const run = addRunArtifact(exe);
......@@ -2965,8 +2965,8 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
29652965 // https://github.com/ziglang/zig/issues/17430
29662966 // {
29672967 // const exe = addExecutable(b, opts, .{ .name = "main2"});
2968 // exe.addObject(obj);
2969 // exe.linkLibrary(dso);
2968 // exe.root_module.addObject(obj);
2969 // exe.root_module.linkLibrary(dso);
29702970 // exe.pie = false;
29712971
29722972 // const run = addRunArtifact(exe);
......@@ -2999,13 +2999,13 @@ fn testStrip(b: *Build, opts: Options) *Step {
29992999 \\}
30003000 ,
30013001 });
3002 obj.linkLibC();
3002 obj.root_module.link_libc = true;
30033003
30043004 {
30053005 const exe = addExecutable(b, opts, .{ .name = "main1" });
3006 exe.addObject(obj);
3006 exe.root_module.addObject(obj);
30073007 exe.root_module.strip = false;
3008 exe.linkLibC();
3008 exe.root_module.link_libc = true;
30093009
30103010 const check = exe.checkObject();
30113011 check.checkInHeaders();
......@@ -3016,9 +3016,9 @@ fn testStrip(b: *Build, opts: Options) *Step {
30163016
30173017 {
30183018 const exe = addExecutable(b, opts, .{ .name = "main2" });
3019 exe.addObject(obj);
3019 exe.root_module.addObject(obj);
30203020 exe.root_module.strip = true;
3021 exe.linkLibC();
3021 exe.root_module.link_libc = true;
30223022
30233023 const check = exe.checkObject();
30243024 check.checkInHeaders();
......@@ -3074,7 +3074,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {
30743074
30753075 {
30763076 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3077 dso.addObject(obj);
3077 dso.root_module.addObject(obj);
30783078 // dso.link_relax = true;
30793079
30803080 const check = dso.checkObject();
......@@ -3086,7 +3086,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {
30863086 // TODO add -Wl,--no-relax
30873087 // {
30883088 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3089 // dso.addObject(obj);
3089 // dso.root_module.addObject(obj);
30903090 // dso.link_relax = false;
30913091
30923092 // const check = dso.checkObject();
......@@ -3128,8 +3128,8 @@ fn testTlsDso(b: *Build, opts: Options) *Step {
31283128 \\ return 0;
31293129 \\}
31303130 , &.{});
3131 exe.linkLibrary(dso);
3132 exe.linkLibC();
3131 exe.root_module.linkLibrary(dso);
3132 exe.root_module.link_libc = true;
31333133
31343134 const run = addRunArtifact(exe);
31353135 run.expectStdOutEqual("5 3 5 3 5 3\n");
......@@ -3159,7 +3159,7 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
31593159 ,
31603160 .pic = true,
31613161 });
3162 main_o.linkLibC();
3162 main_o.root_module.link_libc = true;
31633163
31643164 const a_o = addObject(b, opts, .{
31653165 .name = "a",
......@@ -3184,17 +3184,17 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
31843184 const exp_stdout = "1 2 3 4 5 6\n";
31853185
31863186 const dso1 = addSharedLibrary(b, opts, .{ .name = "a" });
3187 dso1.addObject(a_o);
3187 dso1.root_module.addObject(a_o);
31883188
31893189 const dso2 = addSharedLibrary(b, opts, .{ .name = "b" });
3190 dso2.addObject(b_o);
3190 dso2.root_module.addObject(b_o);
31913191 // dso2.link_relax = false; // TODO
31923192
31933193 {
31943194 const exe = addExecutable(b, opts, .{ .name = "main1" });
3195 exe.addObject(main_o);
3196 exe.linkLibrary(dso1);
3197 exe.linkLibrary(dso2);
3195 exe.root_module.addObject(main_o);
3196 exe.root_module.linkLibrary(dso1);
3197 exe.root_module.linkLibrary(dso2);
31983198
31993199 const run = addRunArtifact(exe);
32003200 run.expectStdOutEqual(exp_stdout);
......@@ -3203,10 +3203,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
32033203
32043204 {
32053205 const exe = addExecutable(b, opts, .{ .name = "main2" });
3206 exe.addObject(main_o);
3206 exe.root_module.addObject(main_o);
32073207 // exe.link_relax = false; // TODO
3208 exe.linkLibrary(dso1);
3209 exe.linkLibrary(dso2);
3208 exe.root_module.linkLibrary(dso1);
3209 exe.root_module.linkLibrary(dso2);
32103210
32113211 const run = addRunArtifact(exe);
32123212 run.expectStdOutEqual(exp_stdout);
......@@ -3216,9 +3216,9 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
32163216 // https://github.com/ziglang/zig/issues/17430 ??
32173217 // {
32183218 // const exe = addExecutable(b, opts, .{ .name = "main3"});
3219 // exe.addObject(main_o);
3220 // exe.linkLibrary(dso1);
3221 // exe.linkLibrary(dso2);
3219 // exe.root_module.addObject(main_o);
3220 // exe.root_module.linkLibrary(dso1);
3221 // exe.root_module.linkLibrary(dso2);
32223222 // exe.linkage = .static;
32233223
32243224 // const run = addRunArtifact(exe);
......@@ -3228,10 +3228,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
32283228
32293229 // {
32303230 // const exe = addExecutable(b, opts, .{ .name = "main4"});
3231 // exe.addObject(main_o);
3231 // exe.root_module.addObject(main_o);
32323232 // // exe.link_relax = false; // TODO
3233 // exe.linkLibrary(dso1);
3234 // exe.linkLibrary(dso2);
3233 // exe.root_module.linkLibrary(dso1);
3234 // exe.root_module.linkLibrary(dso2);
32353235 // exe.linkage = .static;
32363236
32373237 // const run = addRunArtifact(exe);
......@@ -3265,7 +3265,7 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
32653265 .c_source_flags = &.{"-fno-plt"},
32663266 .pic = true,
32673267 });
3268 obj.linkLibC();
3268 obj.root_module.link_libc = true;
32693269
32703270 const a_so = addSharedLibrary(b, opts, .{ .name = "a" });
32713271 addCSourceBytes(a_so,
......@@ -3284,10 +3284,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
32843284
32853285 {
32863286 const exe = addExecutable(b, opts, .{ .name = "main1" });
3287 exe.addObject(obj);
3288 exe.linkLibrary(a_so);
3289 exe.linkLibrary(b_so);
3290 exe.linkLibC();
3287 exe.root_module.addObject(obj);
3288 exe.root_module.linkLibrary(a_so);
3289 exe.root_module.linkLibrary(b_so);
3290 exe.root_module.link_libc = true;
32913291
32923292 const run = addRunArtifact(exe);
32933293 run.expectStdOutEqual("1 2 3 4 5 6\n");
......@@ -3296,10 +3296,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
32963296
32973297 {
32983298 const exe = addExecutable(b, opts, .{ .name = "main2" });
3299 exe.addObject(obj);
3300 exe.linkLibrary(a_so);
3301 exe.linkLibrary(b_so);
3302 exe.linkLibC();
3299 exe.root_module.addObject(obj);
3300 exe.root_module.linkLibrary(a_so);
3301 exe.root_module.linkLibrary(b_so);
3302 exe.root_module.link_libc = true;
33033303 // exe.link_relax = false; // TODO
33043304
33053305 const run = addRunArtifact(exe);
......@@ -3329,7 +3329,7 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33293329 ,
33303330 .pic = true,
33313331 });
3332 a_o.linkLibC();
3332 a_o.root_module.link_libc = true;
33333333
33343334 const b_o = addObject(b, opts, .{
33353335 .name = "b",
......@@ -3342,12 +3342,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33423342
33433343 {
33443344 const dso = addSharedLibrary(b, opts, .{ .name = "a1" });
3345 dso.addObject(a_o);
3345 dso.root_module.addObject(a_o);
33463346
33473347 const exe = addExecutable(b, opts, .{ .name = "main1" });
3348 exe.addObject(b_o);
3349 exe.linkLibrary(dso);
3350 exe.linkLibC();
3348 exe.root_module.addObject(b_o);
3349 exe.root_module.linkLibrary(dso);
3350 exe.root_module.link_libc = true;
33513351
33523352 const run = addRunArtifact(exe);
33533353 run.expectStdOutEqual("1 2 3\n");
......@@ -3356,13 +3356,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33563356
33573357 {
33583358 const dso = addSharedLibrary(b, opts, .{ .name = "a2" });
3359 dso.addObject(a_o);
3359 dso.root_module.addObject(a_o);
33603360 // dso.link_relax = false; // TODO
33613361
33623362 const exe = addExecutable(b, opts, .{ .name = "main2" });
3363 exe.addObject(b_o);
3364 exe.linkLibrary(dso);
3365 exe.linkLibC();
3363 exe.root_module.addObject(b_o);
3364 exe.root_module.linkLibrary(dso);
3365 exe.root_module.link_libc = true;
33663366
33673367 const run = addRunArtifact(exe);
33683368 run.expectStdOutEqual("1 2 3\n");
......@@ -3371,12 +3371,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33713371
33723372 // {
33733373 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3374 // dso.addObject(a_o);
3374 // dso.root_module.addObject(a_o);
33753375 // dso.link_z_nodlopen = true;
33763376
33773377 // const exe = addExecutable(b, opts, .{ .name = "main"});
3378 // exe.addObject(b_o);
3379 // exe.linkLibrary(dso);
3378 // exe.root_module.addObject(b_o);
3379 // exe.root_module.linkLibrary(dso);
33803380
33813381 // const run = addRunArtifact(exe);
33823382 // run.expectStdOutEqual("1 2 3\n");
......@@ -3385,13 +3385,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33853385
33863386 // {
33873387 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3388 // dso.addObject(a_o);
3388 // dso.root_module.addObject(a_o);
33893389 // dso.link_relax = false;
33903390 // dso.link_z_nodlopen = true;
33913391
33923392 // const exe = addExecutable(b, opts, .{ .name = "main"});
3393 // exe.addObject(b_o);
3394 // exe.linkLibrary(dso);
3393 // exe.root_module.addObject(b_o);
3394 // exe.root_module.linkLibrary(dso);
33953395
33963396 // const run = addRunArtifact(exe);
33973397 // run.expectStdOutEqual("1 2 3\n");
......@@ -3417,7 +3417,7 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
34173417 \\ printf("%d %d ", foo, bar);
34183418 \\}
34193419 , &.{});
3420 dso.linkLibC();
3420 dso.root_module.link_libc = true;
34213421
34223422 const main_o = addObject(b, opts, .{
34233423 .name = "main",
......@@ -3435,15 +3435,15 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
34353435 \\}
34363436 ,
34373437 });
3438 main_o.linkLibC();
3438 main_o.root_module.link_libc = true;
34393439
34403440 const exp_stdout = "0 0 3 5 7\n";
34413441
34423442 {
34433443 const exe = addExecutable(b, opts, .{ .name = "main1" });
3444 exe.addObject(main_o);
3445 exe.linkLibrary(dso);
3446 exe.linkLibC();
3444 exe.root_module.addObject(main_o);
3445 exe.root_module.linkLibrary(dso);
3446 exe.root_module.link_libc = true;
34473447
34483448 const run = addRunArtifact(exe);
34493449 run.expectStdOutEqual(exp_stdout);
......@@ -3452,9 +3452,9 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
34523452
34533453 {
34543454 const exe = addExecutable(b, opts, .{ .name = "main2" });
3455 exe.addObject(main_o);
3456 exe.linkLibrary(dso);
3457 exe.linkLibC();
3455 exe.root_module.addObject(main_o);
3456 exe.root_module.linkLibrary(dso);
3457 exe.root_module.link_libc = true;
34583458 // exe.link_relax = false; // TODO
34593459
34603460 const run = addRunArtifact(exe);
......@@ -3500,17 +3500,17 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {
35003500 ,
35013501 .pic = true,
35023502 });
3503 c_o.linkLibC();
3503 c_o.root_module.link_libc = true;
35043504
35053505 {
35063506 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3507 dso.addObject(a_o);
3508 dso.addObject(b_o);
3507 dso.root_module.addObject(a_o);
3508 dso.root_module.addObject(b_o);
35093509
35103510 const exe = addExecutable(b, opts, .{ .name = "main" });
3511 exe.addObject(c_o);
3512 exe.linkLibrary(dso);
3513 exe.linkLibC();
3511 exe.root_module.addObject(c_o);
3512 exe.root_module.linkLibrary(dso);
3513 exe.root_module.link_libc = true;
35143514
35153515 const run = addRunArtifact(exe);
35163516 run.expectStdOutEqual("42 1 2 3\n");
......@@ -3519,10 +3519,10 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {
35193519
35203520 {
35213521 const exe = addExecutable(b, opts, .{ .name = "main" });
3522 exe.addObject(a_o);
3523 exe.addObject(b_o);
3524 exe.addObject(c_o);
3525 exe.linkLibC();
3522 exe.root_module.addObject(a_o);
3523 exe.root_module.addObject(b_o);
3524 exe.root_module.addObject(c_o);
3525 exe.root_module.link_libc = true;
35263526
35273527 const run = addRunArtifact(exe);
35283528 run.expectStdOutEqual("42 1 2 3\n");
......@@ -3555,7 +3555,7 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
35553555 \\ printf("%d %d %d %d %d %d\n", x[0], x[1], x[1023], y[0], y[1], y[1023]);
35563556 \\}
35573557 , &.{});
3558 exe.linkLibC();
3558 exe.root_module.link_libc = true;
35593559 // Disabled to work around the ELF linker crashing.
35603560 // Can be reproduced on a x86_64-linux host by commenting out the line below.
35613561 exe.root_module.sanitize_c = .off;
......@@ -3580,7 +3580,7 @@ fn testTlsLargeStaticImage(b: *Build, opts: Options) *Step {
35803580 \\}
35813581 , &.{});
35823582 exe.root_module.pic = true;
3583 exe.linkLibC();
3583 exe.root_module.link_libc = true;
35843584
35853585 const run = addRunArtifact(exe);
35863586 run.expectStdOutEqual("1 2 3 0 5\n");
......@@ -3609,7 +3609,7 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
36093609 .c_source_flags = &.{"-ftls-model=local-dynamic"},
36103610 .pic = true,
36113611 });
3612 main_o.linkLibC();
3612 main_o.root_module.link_libc = true;
36133613
36143614 const a_o = addObject(b, opts, .{
36153615 .name = "a",
......@@ -3622,9 +3622,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
36223622
36233623 {
36243624 const exe = addExecutable(b, opts, .{ .name = "main1" });
3625 exe.addObject(main_o);
3626 exe.addObject(a_o);
3627 exe.linkLibC();
3625 exe.root_module.addObject(main_o);
3626 exe.root_module.addObject(a_o);
3627 exe.root_module.link_libc = true;
36283628
36293629 const run = addRunArtifact(exe);
36303630 run.expectStdOutEqual(exp_stdout);
......@@ -3633,9 +3633,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
36333633
36343634 {
36353635 const exe = addExecutable(b, opts, .{ .name = "main2" });
3636 exe.addObject(main_o);
3637 exe.addObject(a_o);
3638 exe.linkLibC();
3636 exe.root_module.addObject(main_o);
3637 exe.root_module.addObject(a_o);
3638 exe.root_module.link_libc = true;
36393639 // exe.link_relax = false; // TODO
36403640
36413641 const run = addRunArtifact(exe);
......@@ -3668,8 +3668,8 @@ fn testTlsLdDso(b: *Build, opts: Options) *Step {
36683668 \\ return 0;
36693669 \\}
36703670 , &.{});
3671 exe.linkLibrary(dso);
3672 exe.linkLibC();
3671 exe.root_module.linkLibrary(dso);
3672 exe.root_module.link_libc = true;
36733673
36743674 const run = addRunArtifact(exe);
36753675 run.expectStdOutEqual("1 2\n");
......@@ -3699,7 +3699,7 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
36993699 .c_source_flags = &.{ "-ftls-model=local-dynamic", "-fno-plt" },
37003700 .pic = true,
37013701 });
3702 a_o.linkLibC();
3702 a_o.root_module.link_libc = true;
37033703
37043704 const b_o = addObject(b, opts, .{
37053705 .name = "b",
......@@ -3710,9 +3710,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
37103710
37113711 {
37123712 const exe = addExecutable(b, opts, .{ .name = "main1" });
3713 exe.addObject(a_o);
3714 exe.addObject(b_o);
3715 exe.linkLibC();
3713 exe.root_module.addObject(a_o);
3714 exe.root_module.addObject(b_o);
3715 exe.root_module.link_libc = true;
37163716
37173717 const run = addRunArtifact(exe);
37183718 run.expectStdOutEqual("3 5 3 5\n");
......@@ -3721,9 +3721,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
37213721
37223722 {
37233723 const exe = addExecutable(b, opts, .{ .name = "main2" });
3724 exe.addObject(a_o);
3725 exe.addObject(b_o);
3726 exe.linkLibC();
3724 exe.root_module.addObject(a_o);
3725 exe.root_module.addObject(b_o);
3726 exe.root_module.link_libc = true;
37273727 // exe.link_relax = false; // TODO
37283728
37293729 const run = addRunArtifact(exe);
......@@ -3756,7 +3756,7 @@ fn testTlsNoPic(b: *Build, opts: Options) *Step {
37563756 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo;
37573757 , &.{});
37583758 exe.root_module.pic = false;
3759 exe.linkLibC();
3759 exe.root_module.link_libc = true;
37603760
37613761 const run = addRunArtifact(exe);
37623762 run.expectStdOutEqual("3 5 3 5\n");
......@@ -3784,7 +3784,7 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {
37843784 \\ return NULL;
37853785 \\}
37863786 , &.{});
3787 dso.linkLibC();
3787 dso.root_module.link_libc = true;
37883788
37893789 const exe = addExecutable(b, opts, .{ .name = "main" });
37903790 addCSourceBytes(exe,
......@@ -3811,8 +3811,8 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {
38113811 \\ pthread_join(thread, NULL);
38123812 \\}
38133813 , &.{});
3814 exe.addRPath(dso.getEmittedBinDirectory());
3815 exe.linkLibC();
3814 exe.root_module.addRPath(dso.getEmittedBinDirectory());
3815 exe.root_module.link_libc = true;
38163816 exe.root_module.pic = true;
38173817
38183818 const run = addRunArtifact(exe);
......@@ -3842,14 +3842,14 @@ fn testTlsPic(b: *Build, opts: Options) *Step {
38423842 ,
38433843 .pic = true,
38443844 });
3845 obj.linkLibC();
3845 obj.root_module.link_libc = true;
38463846
38473847 const exe = addExecutable(b, opts, .{ .name = "main" });
38483848 addCSourceBytes(exe,
38493849 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo = 3;
38503850 , &.{});
3851 exe.addObject(obj);
3852 exe.linkLibC();
3851 exe.root_module.addObject(obj);
3852 exe.root_module.link_libc = true;
38533853
38543854 const run = addRunArtifact(exe);
38553855 run.expectStdOutEqual("3 5 3 5\n");
......@@ -3889,14 +3889,14 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {
38893889 ,
38903890 .pic = true,
38913891 });
3892 c_o.linkLibC();
3892 c_o.root_module.link_libc = true;
38933893
38943894 {
38953895 const exe = addExecutable(b, opts, .{ .name = "main" });
3896 exe.addObject(a_o);
3897 exe.addObject(b_o);
3898 exe.addObject(c_o);
3899 exe.linkLibC();
3896 exe.root_module.addObject(a_o);
3897 exe.root_module.addObject(b_o);
3898 exe.root_module.addObject(c_o);
3899 exe.root_module.link_libc = true;
39003900
39013901 const run = addRunArtifact(exe);
39023902 run.expectStdOutEqual("42\n");
......@@ -3905,13 +3905,13 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {
39053905
39063906 {
39073907 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3908 dso.addObject(a_o);
3909 dso.addObject(b_o);
3908 dso.root_module.addObject(a_o);
3909 dso.root_module.addObject(b_o);
39103910
39113911 const exe = addExecutable(b, opts, .{ .name = "main" });
3912 exe.addObject(c_o);
3913 exe.linkLibrary(dso);
3914 exe.linkLibC();
3912 exe.root_module.addObject(c_o);
3913 exe.root_module.linkLibrary(dso);
3914 exe.root_module.link_libc = true;
39153915
39163916 const run = addRunArtifact(exe);
39173917 run.expectStdOutEqual("42\n");
......@@ -3939,7 +3939,7 @@ fn testTlsStatic(b: *Build, opts: Options) *Step {
39393939 \\ return 0;
39403940 \\}
39413941 , &.{});
3942 exe.linkLibC();
3942 exe.root_module.link_libc = true;
39433943
39443944 const run = addRunArtifact(exe);
39453945 run.expectStdOutEqual(
......@@ -3969,8 +3969,8 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step {
39693969 \\ return foo;
39703970 \\}
39713971 , &.{});
3972 exe.linkLibrary(dylib);
3973 exe.linkLibC();
3972 exe.root_module.linkLibrary(dylib);
3973 exe.root_module.link_libc = true;
39743974
39753975 expectLinkErrors(exe, test_step, .{
39763976 .contains = "error: failed to parse shared library: BadMagic",
......@@ -3993,7 +3993,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
39933993 ,
39943994 .c_source_flags = &.{"-ffunction-sections"},
39953995 });
3996 obj1.linkLibC();
3996 obj1.root_module.link_libc = true;
39973997
39983998 const obj2 = addObject(b, opts, .{
39993999 .name = "b",
......@@ -4007,12 +4007,12 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
40074007 ,
40084008 .c_source_flags = &.{"-ffunction-sections"},
40094009 });
4010 obj2.linkLibC();
4010 obj2.root_module.link_libc = true;
40114011
40124012 const exe = addExecutable(b, opts, .{ .name = "main" });
4013 exe.addObject(obj1);
4014 exe.addObject(obj2);
4015 exe.linkLibC();
4013 exe.root_module.addObject(obj1);
4014 exe.root_module.addObject(obj2);
4015 exe.root_module.link_libc = true;
40164016
40174017 expectLinkErrors(exe, test_step, .{ .exact = &.{
40184018 "error: undefined symbol: foo",
......@@ -4037,12 +4037,12 @@ fn testWeakExports(b: *Build, opts: Options) *Step {
40374037 ,
40384038 .pic = true,
40394039 });
4040 obj.linkLibC();
4040 obj.root_module.link_libc = true;
40414041
40424042 {
40434043 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4044 dso.addObject(obj);
4045 dso.linkLibC();
4044 dso.root_module.addObject(obj);
4045 dso.root_module.link_libc = true;
40464046
40474047 const check = dso.checkObject();
40484048 check.checkInDynamicSymtab();
......@@ -4052,8 +4052,8 @@ fn testWeakExports(b: *Build, opts: Options) *Step {
40524052
40534053 {
40544054 const exe = addExecutable(b, opts, .{ .name = "main" });
4055 exe.addObject(obj);
4056 exe.linkLibC();
4055 exe.root_module.addObject(obj);
4056 exe.root_module.link_libc = true;
40574057
40584058 const check = exe.checkObject();
40594059 check.checkInDynamicSymtab();
......@@ -4084,8 +4084,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {
40844084 \\int bar();
40854085 \\int main() { printf("bar=%d\n", bar()); }
40864086 , &.{});
4087 exe.linkLibrary(dso);
4088 exe.linkLibC();
4087 exe.root_module.linkLibrary(dso);
4088 exe.root_module.link_libc = true;
40894089
40904090 const run = addRunArtifact(exe);
40914091 run.expectStdOutEqual("bar=-1\n");
......@@ -4100,8 +4100,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {
41004100 \\int bar();
41014101 \\int main() { printf("bar=%d\n", bar()); }
41024102 , &.{});
4103 exe.linkLibrary(dso);
4104 exe.linkLibC();
4103 exe.root_module.linkLibrary(dso);
4104 exe.root_module.link_libc = true;
41054105
41064106 const run = addRunArtifact(exe);
41074107 run.expectStdOutEqual("bar=5\n");
......@@ -4122,7 +4122,7 @@ fn testZNow(b: *Build, opts: Options) *Step {
41224122
41234123 {
41244124 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4125 dso.addObject(obj);
4125 dso.root_module.addObject(obj);
41264126
41274127 const check = dso.checkObject();
41284128 check.checkInDynamicSection();
......@@ -4132,7 +4132,7 @@ fn testZNow(b: *Build, opts: Options) *Step {
41324132
41334133 {
41344134 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4135 dso.addObject(obj);
4135 dso.root_module.addObject(obj);
41364136 dso.link_z_lazy = true;
41374137
41384138 const check = dso.checkObject();
......@@ -4150,7 +4150,7 @@ fn testZStackSize(b: *Build, opts: Options) *Step {
41504150 const exe = addExecutable(b, opts, .{ .name = "main" });
41514151 addCSourceBytes(exe, "int main() { return 0; }", &.{});
41524152 exe.stack_size = 0x800000;
4153 exe.linkLibC();
4153 exe.root_module.link_libc = true;
41544154
41554155 const check = exe.checkObject();
41564156 check.checkInHeaders();
......@@ -4202,8 +4202,8 @@ fn testZText(b: *Build, opts: Options) *Step {
42024202 });
42034203
42044204 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4205 dso.addObject(a_o);
4206 dso.addObject(b_o);
4205 dso.root_module.addObject(a_o);
4206 dso.root_module.addObject(b_o);
42074207 dso.link_z_notext = true;
42084208
42094209 const exe = addExecutable(b, opts, .{ .name = "main" });
......@@ -4214,8 +4214,8 @@ fn testZText(b: *Build, opts: Options) *Step {
42144214 \\ printf("%d\n", fnn());
42154215 \\}
42164216 , &.{});
4217 exe.linkLibrary(dso);
4218 exe.linkLibC();
4217 exe.root_module.linkLibrary(dso);
4218 exe.root_module.link_libc = true;
42194219
42204220 const run = addRunArtifact(exe);
42214221 run.expectStdOutEqual("3\n");
test/link/link.zig+3-3
......@@ -140,20 +140,20 @@ pub fn addRunArtifact(comp: *Compile) *Run {
140140pub fn addCSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {
141141 const b = comp.step.owner;
142142 const file = WriteFile.create(b).add("a.c", bytes);
143 comp.addCSourceFile(.{ .file = file, .flags = flags });
143 comp.root_module.addCSourceFile(.{ .file = file, .flags = flags });
144144}
145145
146146pub fn addCppSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {
147147 const b = comp.step.owner;
148148 const file = WriteFile.create(b).add("a.cpp", bytes);
149 comp.addCSourceFile(.{ .file = file, .flags = flags });
149 comp.root_module.addCSourceFile(.{ .file = file, .flags = flags });
150150}
151151
152152pub fn addAsmSourceBytes(comp: *Compile, bytes: []const u8) void {
153153 const b = comp.step.owner;
154154 const actual_bytes = std.fmt.allocPrint(b.allocator, "{s}\n", .{bytes}) catch @panic("OOM");
155155 const file = WriteFile.create(b).add("a.s", actual_bytes);
156 comp.addAssemblyFile(file);
156 comp.root_module.addAssemblyFile(file);
157157}
158158
159159pub fn expectLinkErrors(comp: *Compile, test_step: *Step, expected_errors: Compile.ExpectedCompileErrors) void {
test/link/macho.zig+123-123
......@@ -127,7 +127,7 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
127127
128128 {
129129 const exe = addExecutable(b, opts, .{ .name = "no_dead_strip" });
130 exe.addObject(obj);
130 exe.root_module.addObject(obj);
131131 exe.link_gc_sections = false;
132132
133133 const check = exe.checkObject();
......@@ -156,7 +156,7 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
156156
157157 {
158158 const exe = addExecutable(b, opts, .{ .name = "yes_dead_strip" });
159 exe.addObject(obj);
159 exe.root_module.addObject(obj);
160160 exe.link_gc_sections = true;
161161
162162 const check = exe.checkObject();
......@@ -206,7 +206,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
206206 \\ strong();
207207 \\}
208208 });
209 exe.addObject(obj);
209 exe.root_module.addObject(obj);
210210
211211 expectLinkErrors(exe, test_step, .{ .exact = &.{
212212 "error: duplicate symbol definition: _strong",
......@@ -235,7 +235,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
235235
236236 {
237237 const exe = addExecutable(b, opts, .{ .name = "main1" });
238 exe.addObject(main_o);
238 exe.root_module.addObject(main_o);
239239 exe.root_module.linkFramework("Cocoa", .{});
240240
241241 const check = exe.checkObject();
......@@ -254,7 +254,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
254254
255255 {
256256 const exe = addExecutable(b, opts, .{ .name = "main2" });
257 exe.addObject(main_o);
257 exe.root_module.addObject(main_o);
258258 exe.root_module.linkFramework("Cocoa", .{});
259259 exe.dead_strip_dylibs = true;
260260
......@@ -350,7 +350,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
350350 \\ printf("Hello world!");
351351 \\}
352352 });
353 exe.addObject(empty);
353 exe.root_module.addObject(empty);
354354
355355 const run = addRunArtifact(exe);
356356 run.expectStdOutEqual("Hello world!");
......@@ -451,7 +451,7 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
451451 \\ return 0;
452452 \\}
453453 , &.{});
454 exe.linkLibrary(dylib);
454 exe.root_module.linkLibrary(dylib);
455455 exe.entry = .{ .symbol_name = "_bootstrap" };
456456 exe.forceUndefinedSymbol("_my_main");
457457
......@@ -604,11 +604,11 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
604604 });
605605
606606 const lib = addSharedLibrary(b, opts, .{ .name = "a" });
607 lib.addObject(obj1);
607 lib.root_module.addObject(obj1);
608608
609609 {
610610 const exe = addExecutable(b, opts, .{ .name = "main1", .c_source_bytes = "int main() { return 0; }" });
611 exe.addObject(obj1);
611 exe.root_module.addObject(obj1);
612612
613613 const check = exe.checkObject();
614614 check.checkInHeaders();
......@@ -642,8 +642,8 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
642642 }
643643
644644 const exe = addExecutable(b, opts, .{ .name = "main2" });
645 exe.linkLibrary(lib);
646 exe.addObject(obj);
645 exe.root_module.linkLibrary(lib);
646 exe.root_module.addObject(obj);
647647
648648 const check = exe.checkObject();
649649 check.checkInHeaders();
......@@ -665,7 +665,7 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
665665 \\_main:
666666 \\ ret
667667 });
668 exe.linkLibrary(lib);
668 exe.root_module.linkLibrary(lib);
669669
670670 const check = exe.checkObject();
671671 check.checkInHeaders();
......@@ -910,7 +910,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
910910 \\}
911911 ,
912912 });
913 lib.addObject(obj);
913 lib.root_module.addObject(obj);
914914
915915 const exe = addExecutable(b, opts, .{
916916 .name = "testlib",
......@@ -923,7 +923,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
923923 \\}
924924 ,
925925 });
926 exe.linkLibrary(lib);
926 exe.root_module.linkLibrary(lib);
927927
928928 const run = addRunArtifact(exe);
929929 run.expectStdErrEqual("0\n");
......@@ -1051,28 +1051,28 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
10511051
10521052 {
10531053 const exe = addExecutable(b, opts, .{ .name = "main1" });
1054 exe.addObject(a_o);
1055 exe.addObject(b_o);
1056 exe.addObject(main_o);
1054 exe.root_module.addObject(a_o);
1055 exe.root_module.addObject(b_o);
1056 exe.root_module.addObject(main_o);
10571057 runWithChecks(test_step, exe);
10581058 }
10591059
10601060 {
10611061 const exe = addExecutable(b, opts, .{ .name = "main2" });
1062 exe.addObject(b_o);
1063 exe.addObject(a_o);
1064 exe.addObject(main_o);
1062 exe.root_module.addObject(b_o);
1063 exe.root_module.addObject(a_o);
1064 exe.root_module.addObject(main_o);
10651065 runWithChecks(test_step, exe);
10661066 }
10671067
10681068 {
10691069 const c_o = addObject(b, opts, .{ .name = "c" });
1070 c_o.addObject(a_o);
1071 c_o.addObject(b_o);
1072 c_o.addObject(main_o);
1070 c_o.root_module.addObject(a_o);
1071 c_o.root_module.addObject(b_o);
1072 c_o.root_module.addObject(main_o);
10731073
10741074 const exe = addExecutable(b, opts, .{ .name = "main3" });
1075 exe.addObject(c_o);
1075 exe.root_module.addObject(c_o);
10761076 runWithChecks(test_step, exe);
10771077 }
10781078
......@@ -1167,28 +1167,28 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
11671167
11681168 {
11691169 const exe = addExecutable(b, opts, .{ .name = "main1" });
1170 exe.addObject(a_o);
1171 exe.addObject(b_o);
1172 exe.addObject(main_o);
1170 exe.root_module.addObject(a_o);
1171 exe.root_module.addObject(b_o);
1172 exe.root_module.addObject(main_o);
11731173 runWithChecks(test_step, exe);
11741174 }
11751175
11761176 {
11771177 const exe = addExecutable(b, opts, .{ .name = "main2" });
1178 exe.addObject(b_o);
1179 exe.addObject(a_o);
1180 exe.addObject(main_o);
1178 exe.root_module.addObject(b_o);
1179 exe.root_module.addObject(a_o);
1180 exe.root_module.addObject(main_o);
11811181 runWithChecks(test_step, exe);
11821182 }
11831183
11841184 {
11851185 const c_o = addObject(b, opts, .{ .name = "c" });
1186 c_o.addObject(a_o);
1187 c_o.addObject(b_o);
1188 c_o.addObject(main_o);
1186 c_o.root_module.addObject(a_o);
1187 c_o.root_module.addObject(b_o);
1188 c_o.root_module.addObject(main_o);
11891189
11901190 const exe = addExecutable(b, opts, .{ .name = "main3" });
1191 exe.addObject(c_o);
1191 exe.root_module.addObject(c_o);
11921192 runWithChecks(test_step, exe);
11931193 }
11941194
......@@ -1259,9 +1259,9 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12591259 });
12601260
12611261 const exe = addExecutable(b, opts, .{ .name = "main1" });
1262 exe.addObject(a_o);
1263 exe.addObject(b_o);
1264 exe.addObject(main_o);
1262 exe.root_module.addObject(a_o);
1263 exe.root_module.addObject(b_o);
1264 exe.root_module.addObject(main_o);
12651265
12661266 const check = exe.checkObject();
12671267 check.dumpSection("__TEXT,__const");
......@@ -1335,17 +1335,17 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
13351335
13361336 {
13371337 const exe = addExecutable(b, opts, .{ .name = "main1" });
1338 exe.addObject(a_o);
1339 exe.addObject(b_o);
1340 exe.addObject(main_o);
1338 exe.root_module.addObject(a_o);
1339 exe.root_module.addObject(b_o);
1340 exe.root_module.addObject(main_o);
13411341 runWithChecks(test_step, exe);
13421342 }
13431343
13441344 {
13451345 const exe = addExecutable(b, opts, .{ .name = "main2" });
1346 exe.addObject(b_o);
1347 exe.addObject(a_o);
1348 exe.addObject(main_o);
1346 exe.root_module.addObject(b_o);
1347 exe.root_module.addObject(a_o);
1348 exe.root_module.addObject(main_o);
13491349 runWithChecks(test_step, exe);
13501350 }
13511351
......@@ -1414,27 +1414,27 @@ fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {
14141414
14151415 {
14161416 const exe = addExecutable(b, opts, .{ .name = "main1" });
1417 exe.addObject(main_o);
1418 exe.addObject(a_o);
1417 exe.root_module.addObject(main_o);
1418 exe.root_module.addObject(a_o);
14191419 exe.root_module.linkFramework("Foundation", .{});
14201420 runWithChecks(test_step, exe);
14211421 }
14221422
14231423 {
14241424 const exe = addExecutable(b, opts, .{ .name = "main2" });
1425 exe.addObject(a_o);
1426 exe.addObject(main_o);
1425 exe.root_module.addObject(a_o);
1426 exe.root_module.addObject(main_o);
14271427 exe.root_module.linkFramework("Foundation", .{});
14281428 runWithChecks(test_step, exe);
14291429 }
14301430
14311431 {
14321432 const b_o = addObject(b, opts, .{ .name = "b" });
1433 b_o.addObject(a_o);
1434 b_o.addObject(main_o);
1433 b_o.root_module.addObject(a_o);
1434 b_o.root_module.addObject(main_o);
14351435
14361436 const exe = addExecutable(b, opts, .{ .name = "main3" });
1437 exe.addObject(b_o);
1437 exe.root_module.addObject(b_o);
14381438 exe.root_module.linkFramework("Foundation", .{});
14391439 runWithChecks(test_step, exe);
14401440 }
......@@ -1610,7 +1610,7 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
16101610 \\@end
16111611 });
16121612 foo_o.root_module.addIncludePath(foo_h.dirname());
1613 foo_o.linkLibCpp();
1613 foo_o.root_module.link_libcpp = true;
16141614
16151615 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes =
16161616 \\#import "Foo.h"
......@@ -1628,8 +1628,8 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
16281628 \\}
16291629 });
16301630 exe.root_module.addIncludePath(foo_h.dirname());
1631 exe.addObject(foo_o);
1632 exe.linkLibCpp();
1631 exe.root_module.addObject(foo_o);
1632 exe.root_module.link_libcpp = true;
16331633 exe.root_module.linkFramework("Foundation", .{});
16341634
16351635 const run = addRunArtifact(exe);
......@@ -1693,7 +1693,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
16931693 \\ return bar() - foo();
16941694 \\}
16951695 });
1696 exe.linkLibrary(lib);
1696 exe.root_module.linkLibrary(lib);
16971697
16981698 const run = addRunArtifact(exe);
16991699 run.expectExitCode(0);
......@@ -1711,7 +1711,7 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17111711 \\ throw std::runtime_error("Oh no!");
17121712 \\}
17131713 });
1714 a_o.linkLibCpp();
1714 a_o.root_module.link_libcpp = true;
17151715
17161716 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
17171717 \\extern int try_me();
......@@ -1733,19 +1733,19 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17331733 \\ return 0;
17341734 \\}
17351735 });
1736 main_o.linkLibCpp();
1736 main_o.root_module.link_libcpp = true;
17371737
17381738 const exp_stdout = "exception=Oh no!";
17391739
17401740 {
17411741 const c_o = addObject(b, opts, .{ .name = "c" });
1742 c_o.addObject(a_o);
1743 c_o.addObject(b_o);
1742 c_o.root_module.addObject(a_o);
1743 c_o.root_module.addObject(b_o);
17441744
17451745 const exe = addExecutable(b, opts, .{ .name = "main1" });
1746 exe.addObject(main_o);
1747 exe.addObject(c_o);
1748 exe.linkLibCpp();
1746 exe.root_module.addObject(main_o);
1747 exe.root_module.addObject(c_o);
1748 exe.root_module.link_libcpp = true;
17491749
17501750 const run = addRunArtifact(exe);
17511751 run.expectStdOutEqual(exp_stdout);
......@@ -1754,13 +1754,13 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17541754
17551755 {
17561756 const d_o = addObject(b, opts, .{ .name = "d" });
1757 d_o.addObject(a_o);
1758 d_o.addObject(b_o);
1759 d_o.addObject(main_o);
1757 d_o.root_module.addObject(a_o);
1758 d_o.root_module.addObject(b_o);
1759 d_o.root_module.addObject(main_o);
17601760
17611761 const exe = addExecutable(b, opts, .{ .name = "main2" });
1762 exe.addObject(d_o);
1763 exe.linkLibCpp();
1762 exe.root_module.addObject(d_o);
1763 exe.root_module.link_libcpp = true;
17641764
17651765 const run = addRunArtifact(exe);
17661766 run.expectStdOutEqual(exp_stdout);
......@@ -1805,12 +1805,12 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
18051805 });
18061806
18071807 const c_o = addObject(b, opts, .{ .name = "c" });
1808 c_o.addObject(a_o);
1809 c_o.addObject(b_o);
1810 c_o.addObject(main_o);
1808 c_o.root_module.addObject(a_o);
1809 c_o.root_module.addObject(b_o);
1810 c_o.root_module.addObject(main_o);
18111811
18121812 const exe = addExecutable(b, opts, .{ .name = "main" });
1813 exe.addObject(c_o);
1813 exe.root_module.addObject(c_o);
18141814
18151815 const run = addRunArtifact(exe);
18161816 run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") });
......@@ -1833,10 +1833,10 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18331833 });
18341834
18351835 const liba = addStaticLibrary(b, opts, .{ .name = "a" });
1836 liba.addObject(obj);
1836 liba.root_module.addObject(obj);
18371837
18381838 const dylib = addSharedLibrary(b, opts, .{ .name = "a" });
1839 dylib.addObject(obj);
1839 dylib.root_module.addObject(obj);
18401840
18411841 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
18421842 \\#include<stdio.h>
......@@ -1850,7 +1850,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18501850
18511851 {
18521852 const exe = addExecutable(b, opts, .{ .name = "main" });
1853 exe.addObject(main_o);
1853 exe.root_module.addObject(main_o);
18541854 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .mode_first });
18551855 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
18561856 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
......@@ -1869,7 +1869,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18691869
18701870 {
18711871 const exe = addExecutable(b, opts, .{ .name = "main" });
1872 exe.addObject(main_o);
1872 exe.root_module.addObject(main_o);
18731873 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .paths_first });
18741874 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
18751875 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
......@@ -1924,9 +1924,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {
19241924 });
19251925
19261926 const exe = addExecutable(b, opts, .{ .name = "test" });
1927 exe.addObject(obj1);
1928 exe.addObject(obj2);
1929 exe.addObject(main_o);
1927 exe.root_module.addObject(obj1);
1928 exe.root_module.addObject(obj2);
1929 exe.root_module.addObject(main_o);
19301930
19311931 const run = b.addRunArtifact(exe);
19321932 run.skip_foreign_checks = true;
......@@ -1951,9 +1951,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {
19511951 });
19521952
19531953 const exe = addExecutable(b, opts, .{ .name = "test" });
1954 exe.addObject(obj1);
1955 exe.addObject(obj3);
1956 exe.addObject(main_o);
1954 exe.root_module.addObject(obj1);
1955 exe.root_module.addObject(obj3);
1956 exe.root_module.addObject(main_o);
19571957
19581958 const run = b.addRunArtifact(exe);
19591959 run.skip_foreign_checks = true;
......@@ -2031,9 +2031,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20312031 });
20322032
20332033 const exe = addExecutable(b, opts, .{ .name = "main" });
2034 exe.addObject(obj1);
2035 exe.addObject(obj2);
2036 exe.addObject(main_o);
2034 exe.root_module.addObject(obj1);
2035 exe.root_module.addObject(obj2);
2036 exe.root_module.addObject(main_o);
20372037
20382038 const run = addRunArtifact(exe);
20392039 run.expectStdOutEqual("All your codebase are belong to us.\n");
......@@ -2054,9 +2054,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20542054 });
20552055
20562056 const exe = addExecutable(b, opts, .{ .name = "main2" });
2057 exe.addObject(obj1);
2058 exe.addObject(obj2);
2059 exe.addObject(main_o);
2057 exe.root_module.addObject(obj1);
2058 exe.root_module.addObject(obj2);
2059 exe.root_module.addObject(main_o);
20602060
20612061 const check = exe.checkObject();
20622062 check.checkInHeaders();
......@@ -2102,9 +2102,9 @@ fn testSymbolStabs(b: *Build, opts: Options) *Step {
21022102 });
21032103
21042104 const exe = addExecutable(b, opts, .{ .name = "main" });
2105 exe.addObject(a_o);
2106 exe.addObject(b_o);
2107 exe.addObject(main_o);
2105 exe.root_module.addObject(a_o);
2106 exe.root_module.addObject(b_o);
2107 exe.root_module.addObject(main_o);
21082108
21092109 const run = addRunArtifact(exe);
21102110 run.expectStdOutEqual("foo=42,bar=24");
......@@ -2299,7 +2299,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
22992299 \\}
23002300 });
23012301 bar_o.root_module.addIncludePath(foo_h.dirname());
2302 bar_o.linkLibCpp();
2302 bar_o.root_module.link_libcpp = true;
23032303
23042304 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes =
23052305 \\#include "foo.h"
......@@ -2309,7 +2309,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
23092309 \\}
23102310 });
23112311 baz_o.root_module.addIncludePath(foo_h.dirname());
2312 baz_o.linkLibCpp();
2312 baz_o.root_module.link_libcpp = true;
23132313
23142314 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
23152315 \\extern int bar();
......@@ -2321,13 +2321,13 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
23212321 \\}
23222322 });
23232323 main_o.root_module.addIncludePath(foo_h.dirname());
2324 main_o.linkLibCpp();
2324 main_o.root_module.link_libcpp = true;
23252325
23262326 const exe = addExecutable(b, opts, .{ .name = "main" });
2327 exe.addObject(bar_o);
2328 exe.addObject(baz_o);
2329 exe.addObject(main_o);
2330 exe.linkLibCpp();
2327 exe.root_module.addObject(bar_o);
2328 exe.root_module.addObject(baz_o);
2329 exe.root_module.addObject(main_o);
2330 exe.root_module.link_libcpp = true;
23312331
23322332 const run = addRunArtifact(exe);
23332333 run.expectExitCode(0);
......@@ -2445,7 +2445,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24452445
24462446 {
24472447 const exe = addExecutable(b, opts, .{ .name = "main1" });
2448 exe.addObject(main_o);
2448 exe.root_module.addObject(main_o);
24492449 exe.root_module.linkSystemLibrary("a", .{});
24502450 exe.root_module.linkSystemLibrary("b", .{});
24512451 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
......@@ -2474,7 +2474,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24742474
24752475 {
24762476 const exe = addExecutable(b, opts, .{ .name = "main2" });
2477 exe.addObject(main_o);
2477 exe.root_module.addObject(main_o);
24782478 exe.root_module.linkSystemLibrary("b", .{});
24792479 exe.root_module.linkSystemLibrary("a", .{});
24802480 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
......@@ -2510,14 +2510,14 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {
25102510 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "static int foo = 42;" });
25112511
25122512 const lib = addStaticLibrary(b, opts, .{ .name = "a" });
2513 lib.addObject(obj);
2513 lib.root_module.addObject(obj);
25142514
25152515 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
25162516
25172517 {
25182518 const exe = addExecutable(b, opts, .{ .name = "main3" });
2519 exe.addObject(main_o);
2520 exe.addObject(obj);
2519 exe.root_module.addObject(main_o);
2520 exe.root_module.addObject(obj);
25212521 exe.discard_local_symbols = true;
25222522
25232523 const run = addRunArtifact(exe);
......@@ -2532,8 +2532,8 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {
25322532
25332533 {
25342534 const exe = addExecutable(b, opts, .{ .name = "main4" });
2535 exe.addObject(main_o);
2536 exe.linkLibrary(lib);
2535 exe.root_module.addObject(main_o);
2536 exe.root_module.linkLibrary(lib);
25372537 exe.discard_local_symbols = true;
25382538
25392539 const run = addRunArtifact(exe);
......@@ -2555,14 +2555,14 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
25552555 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "int foo = 42;" });
25562556
25572557 const lib = addStaticLibrary(b, opts, .{ .name = "a" });
2558 lib.addObject(obj);
2558 lib.root_module.addObject(obj);
25592559
25602560 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
25612561
25622562 {
25632563 const exe = addExecutable(b, opts, .{ .name = "main1" });
2564 exe.addObject(main_o);
2565 exe.linkLibrary(lib);
2564 exe.root_module.addObject(main_o);
2565 exe.root_module.linkLibrary(lib);
25662566 exe.forceUndefinedSymbol("_foo");
25672567
25682568 const run = addRunArtifact(exe);
......@@ -2577,8 +2577,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
25772577
25782578 {
25792579 const exe = addExecutable(b, opts, .{ .name = "main2" });
2580 exe.addObject(main_o);
2581 exe.linkLibrary(lib);
2580 exe.root_module.addObject(main_o);
2581 exe.root_module.linkLibrary(lib);
25822582 exe.forceUndefinedSymbol("_foo");
25832583 exe.link_gc_sections = true;
25842584
......@@ -2594,8 +2594,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
25942594
25952595 {
25962596 const exe = addExecutable(b, opts, .{ .name = "main3" });
2597 exe.addObject(main_o);
2598 exe.addObject(obj);
2597 exe.root_module.addObject(main_o);
2598 exe.root_module.addObject(obj);
25992599
26002600 const run = addRunArtifact(exe);
26012601 run.expectExitCode(0);
......@@ -2609,8 +2609,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
26092609
26102610 {
26112611 const exe = addExecutable(b, opts, .{ .name = "main4" });
2612 exe.addObject(main_o);
2613 exe.addObject(obj);
2612 exe.root_module.addObject(main_o);
2613 exe.root_module.addObject(obj);
26142614 exe.link_gc_sections = true;
26152615
26162616 const run = addRunArtifact(exe);
......@@ -2642,7 +2642,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
26422642 \\ std.debug.print("foo() + bar() = {d}", .{foo() + bar()});
26432643 \\}
26442644 });
2645 exe.addObject(obj);
2645 exe.root_module.addObject(obj);
26462646
26472647 // TODO order should match across backends if possible
26482648 if (opts.use_llvm) {
......@@ -2764,7 +2764,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
27642764 \\}
27652765 });
27662766 main_o.root_module.addIncludePath(all_h.dirname());
2767 main_o.linkLibCpp();
2767 main_o.root_module.link_libcpp = true;
27682768
27692769 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes =
27702770 \\#include "all.h"
......@@ -2799,7 +2799,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
27992799 \\}
28002800 });
28012801 simple_string_o.root_module.addIncludePath(all_h.dirname());
2802 simple_string_o.linkLibCpp();
2802 simple_string_o.root_module.link_libcpp = true;
28032803
28042804 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes =
28052805 \\#include "all.h"
......@@ -2816,7 +2816,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
28162816 \\}
28172817 });
28182818 simple_string_owner_o.root_module.addIncludePath(all_h.dirname());
2819 simple_string_owner_o.linkLibCpp();
2819 simple_string_owner_o.root_module.link_libcpp = true;
28202820
28212821 const exp_stdout =
28222822 \\Constructed: a
......@@ -2828,10 +2828,10 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
28282828 ;
28292829
28302830 const exe = addExecutable(b, opts, .{ .name = "main" });
2831 exe.addObject(main_o);
2832 exe.addObject(simple_string_o);
2833 exe.addObject(simple_string_owner_o);
2834 exe.linkLibCpp();
2831 exe.root_module.addObject(main_o);
2832 exe.root_module.addObject(simple_string_o);
2833 exe.root_module.addObject(simple_string_owner_o);
2834 exe.root_module.link_libcpp = true;
28352835
28362836 const run = addRunArtifact(exe);
28372837 run.expectStdOutEqual(exp_stdout);
......@@ -2896,7 +2896,7 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
28962896 \\ return 0;
28972897 \\}
28982898 });
2899 exe.addObject(a_o);
2899 exe.root_module.addObject(a_o);
29002900
29012901 const run = addRunArtifact(exe);
29022902 run.expectStdOutEqual("4\n");
......@@ -2948,7 +2948,7 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
29482948 \\ return 0;
29492949 \\}
29502950 });
2951 exe.addObject(a_o);
2951 exe.root_module.addObject(a_o);
29522952
29532953 const run = addRunArtifact(exe);
29542954 run.expectStdOutEqual("4\n");
......@@ -3052,7 +3052,7 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
30523052 \\ .quad 0
30533053 \\ .quad _weak_internal_tlv$tlv$init
30543054 });
3055 exe.linkLibrary(lib);
3055 exe.root_module.linkLibrary(lib);
30563056
30573057 {
30583058 const check = exe.checkObject();
test/link/wasm/extern/build.zig+1-1
......@@ -16,7 +16,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1616 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi }),
1717 }),
1818 });
19 exe.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
19 exe.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
2020 exe.use_llvm = false;
2121 exe.use_lld = false;
2222
test/src/Cases.zig+1-1
......@@ -560,7 +560,7 @@ pub fn lowerToTranslateCSteps(
560560 .root_module = translate_c.createModule(),
561561 });
562562 run_exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
563 run_exe.linkLibC();
563 run_exe.root_module.link_libc = true;
564564 const run = b.addRunArtifact(run_exe);
565565 run.step.name = b.fmt("{s} run", .{annotated_case_name});
566566 run.expectStdOutEqual(output);
test/src/RunTranslatedC.zig+1-1
......@@ -89,7 +89,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
8989 .root_module = translate_c.createModule(),
9090 });
9191 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
92 exe.linkLibC();
92 exe.root_module.link_libc = true;
9393 const run = b.addRunArtifact(exe);
9494 run.step.name = b.fmt("{s} run", .{annotated_case_name});
9595 if (!case.allow_warnings) {
test/standalone/c_embed_path/build.zig+3-3
......@@ -13,12 +13,12 @@ pub fn build(b: *std.Build) void {
1313 .optimize = optimize,
1414 }),
1515 });
16 exe.addCSourceFile(.{
16 exe.root_module.addCSourceFile(.{
1717 .file = b.path("test.c"),
1818 .flags = &.{"-std=c23"},
1919 });
20 exe.linkLibC();
21 exe.addEmbedPath(b.path("data"));
20 exe.root_module.link_libc = true;
21 exe.root_module.addEmbedPath(b.path("data"));
2222
2323 const run_c_cmd = b.addRunArtifact(exe);
2424 run_c_cmd.expectExitCode(0);
test/standalone/extern/build.zig+2-2
......@@ -31,8 +31,8 @@ pub fn build(b: *std.Build) void {
3131 .target = b.graph.host,
3232 .optimize = optimize,
3333 }) });
34 test_exe.addObject(obj);
35 test_exe.linkLibrary(shared);
34 test_exe.root_module.addObject(obj);
35 test_exe.root_module.linkLibrary(shared);
3636
3737 test_step.dependOn(&b.addRunArtifact(test_exe).step);
3838}
test/standalone/issue_794/build.zig+1-1
......@@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {
88 .root_source_file = b.path("main.zig"),
99 .target = b.graph.host,
1010 }) });
11 test_artifact.addIncludePath(b.path("a_directory"));
11 test_artifact.root_module.addIncludePath(b.path("a_directory"));
1212
1313 // TODO: actually check the output
1414 _ = test_artifact.getEmittedBin();
test/standalone/stack_iterator/build.zig+1-1
......@@ -109,7 +109,7 @@ pub fn build(b: *std.Build) void {
109109 // .use_llvm = true,
110110 // });
111111
112 // exe.linkLibrary(c_shared_lib);
112 // exe.root_module.linkLibrary(c_shared_lib);
113113
114114 // const run_cmd = b.addRunArtifact(exe);
115115 // test_step.dependOn(&run_cmd.step);
test/tests.zig+2-2
......@@ -2371,10 +2371,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
23712371 } else "";
23722372 const use_pic = if (test_target.pic == true) "-pic" else "";
23732373
2374 for (options.include_paths) |include_path| these_tests.addIncludePath(b.path(include_path));
2374 for (options.include_paths) |include_path| these_tests.root_module.addIncludePath(b.path(include_path));
23752375
23762376 if (target.os.tag == .windows) {
2377 for (options.windows_libs) |lib| these_tests.linkSystemLibrary(lib);
2377 for (options.windows_libs) |lib| these_tests.root_module.linkSystemLibrary(lib, .{});
23782378 }
23792379
23802380 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{