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 {...@@ -4,8 +4,10 @@ pub fn build(b: *std.Build) void {
4 const optimize = b.standardOptimizeOption(.{});4 const optimize = b.standardOptimizeOption(.{});
5 const exe = b.addExecutable(.{5 const exe = b.addExecutable(.{
6 .name = "example",6 .name = "example",
7 .root_source_file = b.path("example.zig"),7 .root_module = b.createModule(.{
8 .optimize = optimize,8 .root_source_file = b.path("example.zig"),
9 .optimize = optimize,
10 }),
9 });11 });
10 b.default_step.dependOn(&exe.step);12 b.default_step.dependOn(&exe.step);
11}13}
doc/langref/build_c.zig+8-4
...@@ -4,15 +4,19 @@ pub fn build(b: *std.Build) void {...@@ -4,15 +4,19 @@ pub fn build(b: *std.Build) void {
4 const lib = b.addLibrary(.{4 const lib = b.addLibrary(.{
5 .linkage = .dynamic,5 .linkage = .dynamic,
6 .name = "mathtest",6 .name = "mathtest",
7 .root_source_file = b.path("mathtest.zig"),7 .root_module = b.createModule(.{
8 .root_source_file = b.path("mathtest.zig"),
9 }),
8 .version = .{ .major = 1, .minor = 0, .patch = 0 },10 .version = .{ .major = 1, .minor = 0, .patch = 0 },
9 });11 });
10 const exe = b.addExecutable(.{12 const exe = b.addExecutable(.{
11 .name = "test",13 .name = "test",
14 .root_module = b.createModule(.{
15 .link_libc = true,
16 }),
12 });17 });
13 exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });18 exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
14 exe.linkLibrary(lib);19 exe.root_module.linkLibrary(lib);
15 exe.linkSystemLibrary("c");
1620
17 b.default_step.dependOn(&exe.step);21 b.default_step.dependOn(&exe.step);
1822
doc/langref/build_object.zig+8-4
...@@ -3,15 +3,19 @@ const std = @import("std");...@@ -3,15 +3,19 @@ const std = @import("std");
3pub fn build(b: *std.Build) void {3pub fn build(b: *std.Build) void {
4 const obj = b.addObject(.{4 const obj = b.addObject(.{
5 .name = "base64",5 .name = "base64",
6 .root_source_file = b.path("base64.zig"),6 .root_module = b.createModule(.{
7 .root_source_file = b.path("base64.zig"),
8 }),
7 });9 });
810
9 const exe = b.addExecutable(.{11 const exe = b.addExecutable(.{
10 .name = "test",12 .name = "test",
13 .root_module = b.createModule(.{
14 .link_libc = true,
15 }),
11 });16 });
12 exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });17 exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
13 exe.addObject(obj);18 exe.root_module.addObject(obj);
14 exe.linkSystemLibrary("c");
15 b.installArtifact(exe);19 b.installArtifact(exe);
16}20}
1721
lib/std/Build/Step/Compile.zig+42-4
...@@ -681,10 +681,14 @@ pub fn producesImplib(compile: *Compile) bool {...@@ -681,10 +681,14 @@ pub fn producesImplib(compile: *Compile) bool {
681 return compile.isDll();681 return compile.isDll();
682}682}
683683
684/// Deprecated; use `compile.root_module.link_libc = true` instead.
685/// To be removed after 0.15.0 is tagged.
684pub fn linkLibC(compile: *Compile) void {686pub fn linkLibC(compile: *Compile) void {
685 compile.root_module.link_libc = true;687 compile.root_module.link_libc = true;
686}688}
687689
690/// Deprecated; use `compile.root_module.link_libcpp = true` instead.
691/// To be removed after 0.15.0 is tagged.
688pub fn linkLibCpp(compile: *Compile) void {692pub fn linkLibCpp(compile: *Compile) void {
689 compile.root_module.link_libcpp = true;693 compile.root_module.link_libcpp = true;
690}694}
...@@ -802,10 +806,14 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {...@@ -802,10 +806,14 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
802 };806 };
803}807}
804808
809/// Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead.
810/// To be removed after 0.15.0 is tagged.
805pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void {811pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void {
806 return compile.root_module.linkSystemLibrary(name, .{});812 return compile.root_module.linkSystemLibrary(name, .{});
807}813}
808814
815/// Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead.
816/// To be removed after 0.15.0 is tagged.
809pub fn linkSystemLibrary2(817pub fn linkSystemLibrary2(
810 compile: *Compile,818 compile: *Compile,
811 name: []const u8,819 name: []const u8,
...@@ -814,22 +822,26 @@ pub fn linkSystemLibrary2(...@@ -814,22 +822,26 @@ pub fn linkSystemLibrary2(
814 return compile.root_module.linkSystemLibrary(name, options);822 return compile.root_module.linkSystemLibrary(name, options);
815}823}
816824
825/// Deprecated; use `c.root_module.linkFramework(name, .{})` instead.
826/// To be removed after 0.15.0 is tagged.
817pub fn linkFramework(c: *Compile, name: []const u8) void {827pub fn linkFramework(c: *Compile, name: []const u8) void {
818 c.root_module.linkFramework(name, .{});828 c.root_module.linkFramework(name, .{});
819}829}
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.
822pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {833pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
823 compile.root_module.addCSourceFiles(options);834 compile.root_module.addCSourceFiles(options);
824}835}
825836
837/// Deprecated; use `compile.root_module.addCSourceFile(source)` instead.
838/// To be removed after 0.15.0 is tagged.
826pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void {839pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void {
827 compile.root_module.addCSourceFile(source);840 compile.root_module.addCSourceFile(source);
828}841}
829842
830/// Resource files must have the extension `.rc`.843/// Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead.
831/// Can be called regardless of target. The .rc file will be ignored844/// To be removed after 0.15.0 is tagged.
832/// if the target object format does not support embedded resources.
833pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void {845pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void {
834 compile.root_module.addWin32ResourceFile(source);846 compile.root_module.addWin32ResourceFile(source);
835}847}
...@@ -915,54 +927,80 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {...@@ -915,54 +927,80 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
915 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);927 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
916}928}
917929
930/// Deprecated; use `compile.root_module.addAssemblyFile(source)` instead.
931/// To be removed after 0.15.0 is tagged.
918pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void {932pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void {
919 compile.root_module.addAssemblyFile(source);933 compile.root_module.addAssemblyFile(source);
920}934}
921935
936/// Deprecated; use `compile.root_module.addObjectFile(source)` instead.
937/// To be removed after 0.15.0 is tagged.
922pub fn addObjectFile(compile: *Compile, source: LazyPath) void {938pub fn addObjectFile(compile: *Compile, source: LazyPath) void {
923 compile.root_module.addObjectFile(source);939 compile.root_module.addObjectFile(source);
924}940}
925941
942/// Deprecated; use `compile.root_module.addObject(object)` instead.
943/// To be removed after 0.15.0 is tagged.
926pub fn addObject(compile: *Compile, object: *Compile) void {944pub fn addObject(compile: *Compile, object: *Compile) void {
927 compile.root_module.addObject(object);945 compile.root_module.addObject(object);
928}946}
929947
948/// Deprecated; use `compile.root_module.linkLibrary(library)` instead.
949/// To be removed after 0.15.0 is tagged.
930pub fn linkLibrary(compile: *Compile, library: *Compile) void {950pub fn linkLibrary(compile: *Compile, library: *Compile) void {
931 compile.root_module.linkLibrary(library);951 compile.root_module.linkLibrary(library);
932}952}
933953
954/// Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead.
955/// To be removed after 0.15.0 is tagged.
934pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void {956pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void {
935 compile.root_module.addAfterIncludePath(lazy_path);957 compile.root_module.addAfterIncludePath(lazy_path);
936}958}
937959
960/// Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead.
961/// To be removed after 0.15.0 is tagged.
938pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void {962pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void {
939 compile.root_module.addSystemIncludePath(lazy_path);963 compile.root_module.addSystemIncludePath(lazy_path);
940}964}
941965
966/// Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead.
967/// To be removed after 0.15.0 is tagged.
942pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void {968pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void {
943 compile.root_module.addIncludePath(lazy_path);969 compile.root_module.addIncludePath(lazy_path);
944}970}
945971
972/// Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead.
973/// To be removed after 0.15.0 is tagged.
946pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void {974pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void {
947 compile.root_module.addConfigHeader(config_header);975 compile.root_module.addConfigHeader(config_header);
948}976}
949977
978/// Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead.
979/// To be removed after 0.15.0 is tagged.
950pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void {980pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void {
951 compile.root_module.addEmbedPath(lazy_path);981 compile.root_module.addEmbedPath(lazy_path);
952}982}
953983
984/// Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead.
985/// To be removed after 0.15.0 is tagged.
954pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void {986pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void {
955 compile.root_module.addLibraryPath(directory_path);987 compile.root_module.addLibraryPath(directory_path);
956}988}
957989
990/// Deprecated; use `compile.root_module.addRPath(directory_path)` instead.
991/// To be removed after 0.15.0 is tagged.
958pub fn addRPath(compile: *Compile, directory_path: LazyPath) void {992pub fn addRPath(compile: *Compile, directory_path: LazyPath) void {
959 compile.root_module.addRPath(directory_path);993 compile.root_module.addRPath(directory_path);
960}994}
961995
996/// Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead.
997/// To be removed after 0.15.0 is tagged.
962pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void {998pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
963 compile.root_module.addSystemFrameworkPath(directory_path);999 compile.root_module.addSystemFrameworkPath(directory_path);
964}1000}
9651001
1002/// Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead.
1003/// To be removed after 0.15.0 is tagged.
966pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void {1004pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
967 compile.root_module.addFrameworkPath(directory_path);1005 compile.root_module.addFrameworkPath(directory_path);
968}1006}
test/link/elf.zig+369-369
...@@ -210,8 +210,8 @@ fn testAbsSymbols(b: *Build, opts: Options) *Step {...@@ -210,8 +210,8 @@ fn testAbsSymbols(b: *Build, opts: Options) *Step {
210 \\}210 \\}
211 ,211 ,
212 });212 });
213 exe.addObject(obj);213 exe.root_module.addObject(obj);
214 exe.linkLibC();214 exe.root_module.link_libc = true;
215215
216 const run = addRunArtifact(exe);216 const run = addRunArtifact(exe);
217 run.expectExitCode(0);217 run.expectExitCode(0);
...@@ -235,7 +235,7 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {...@@ -235,7 +235,7 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
235 \\235 \\
236 ,236 ,
237 });237 });
238 main_o.linkLibC();238 main_o.root_module.link_libc = true;
239239
240 const libfoo = addSharedLibrary(b, opts, .{ .name = "foo" });240 const libfoo = addSharedLibrary(b, opts, .{ .name = "foo" });
241 addCSourceBytes(libfoo, "int foo() { return 42; }", &.{});241 addCSourceBytes(libfoo, "int foo() { return 42; }", &.{});
...@@ -253,17 +253,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {...@@ -253,17 +253,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
253 const exe = addExecutable(b, opts, .{253 const exe = addExecutable(b, opts, .{
254 .name = "test",254 .name = "test",
255 });255 });
256 exe.addObject(main_o);256 exe.root_module.addObject(main_o);
257 exe.linkSystemLibrary2("foo", .{ .needed = true });257 exe.root_module.linkSystemLibrary("foo", .{ .needed = true });
258 exe.addLibraryPath(libfoo.getEmittedBinDirectory());258 exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory());
259 exe.addRPath(libfoo.getEmittedBinDirectory());259 exe.root_module.addRPath(libfoo.getEmittedBinDirectory());
260 exe.linkSystemLibrary2("bar", .{ .needed = true });260 exe.root_module.linkSystemLibrary("bar", .{ .needed = true });
261 exe.addLibraryPath(libbar.getEmittedBinDirectory());261 exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory());
262 exe.addRPath(libbar.getEmittedBinDirectory());262 exe.root_module.addRPath(libbar.getEmittedBinDirectory());
263 exe.linkSystemLibrary2("baz", .{ .needed = true });263 exe.root_module.linkSystemLibrary("baz", .{ .needed = true });
264 exe.addLibraryPath(libbaz.getEmittedBinDirectory());264 exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory());
265 exe.addRPath(libbaz.getEmittedBinDirectory());265 exe.root_module.addRPath(libbaz.getEmittedBinDirectory());
266 exe.linkLibC();266 exe.root_module.link_libc = true;
267267
268 const run = addRunArtifact(exe);268 const run = addRunArtifact(exe);
269 run.expectStdOutEqual("42\n");269 run.expectStdOutEqual("42\n");
...@@ -281,17 +281,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {...@@ -281,17 +281,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
281 const exe = addExecutable(b, opts, .{281 const exe = addExecutable(b, opts, .{
282 .name = "test",282 .name = "test",
283 });283 });
284 exe.addObject(main_o);284 exe.root_module.addObject(main_o);
285 exe.linkSystemLibrary2("foo", .{ .needed = false });285 exe.root_module.linkSystemLibrary("foo", .{ .needed = false });
286 exe.addLibraryPath(libfoo.getEmittedBinDirectory());286 exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory());
287 exe.addRPath(libfoo.getEmittedBinDirectory());287 exe.root_module.addRPath(libfoo.getEmittedBinDirectory());
288 exe.linkSystemLibrary2("bar", .{ .needed = false });288 exe.root_module.linkSystemLibrary("bar", .{ .needed = false });
289 exe.addLibraryPath(libbar.getEmittedBinDirectory());289 exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory());
290 exe.addRPath(libbar.getEmittedBinDirectory());290 exe.root_module.addRPath(libbar.getEmittedBinDirectory());
291 exe.linkSystemLibrary2("baz", .{ .needed = false });291 exe.root_module.linkSystemLibrary("baz", .{ .needed = false });
292 exe.addLibraryPath(libbaz.getEmittedBinDirectory());292 exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory());
293 exe.addRPath(libbaz.getEmittedBinDirectory());293 exe.root_module.addRPath(libbaz.getEmittedBinDirectory());
294 exe.linkLibC();294 exe.root_module.link_libc = true;
295295
296 const run = addRunArtifact(exe);296 const run = addRunArtifact(exe);
297 run.expectStdOutEqual("42\n");297 run.expectStdOutEqual("42\n");
...@@ -351,15 +351,15 @@ fn testCanonicalPlt(b: *Build, opts: Options) *Step {...@@ -351,15 +351,15 @@ fn testCanonicalPlt(b: *Build, opts: Options) *Step {
351 ,351 ,
352 .pic = false,352 .pic = false,
353 });353 });
354 main_o.linkLibC();354 main_o.root_module.link_libc = true;
355355
356 const exe = addExecutable(b, opts, .{356 const exe = addExecutable(b, opts, .{
357 .name = "main",357 .name = "main",
358 });358 });
359 exe.addObject(main_o);359 exe.root_module.addObject(main_o);
360 exe.addObject(b_o);360 exe.root_module.addObject(b_o);
361 exe.linkLibrary(dso);361 exe.root_module.linkLibrary(dso);
362 exe.linkLibC();362 exe.root_module.link_libc = true;
363 exe.pie = false;363 exe.pie = false;
364364
365 const run = addRunArtifact(exe);365 const run = addRunArtifact(exe);
...@@ -384,7 +384,7 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {...@@ -384,7 +384,7 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
384 \\}384 \\}
385 ,385 ,
386 });386 });
387 a_o.linkLibCpp();387 a_o.root_module.link_libcpp = true;
388388
389 const main_o = addObject(b, opts, .{389 const main_o = addObject(b, opts, .{
390 .name = "main",390 .name = "main",
...@@ -401,13 +401,13 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {...@@ -401,13 +401,13 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
401 \\}401 \\}
402 ,402 ,
403 });403 });
404 main_o.linkLibCpp();404 main_o.root_module.link_libcpp = true;
405405
406 {406 {
407 const exe = addExecutable(b, opts, .{ .name = "main1" });407 const exe = addExecutable(b, opts, .{ .name = "main1" });
408 exe.addObject(a_o);408 exe.root_module.addObject(a_o);
409 exe.addObject(main_o);409 exe.root_module.addObject(main_o);
410 exe.linkLibCpp();410 exe.root_module.link_libcpp = true;
411411
412 const run = addRunArtifact(exe);412 const run = addRunArtifact(exe);
413 run.expectStdOutEqual(413 run.expectStdOutEqual(
...@@ -420,9 +420,9 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {...@@ -420,9 +420,9 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
420420
421 {421 {
422 const exe = addExecutable(b, opts, .{ .name = "main2" });422 const exe = addExecutable(b, opts, .{ .name = "main2" });
423 exe.addObject(main_o);423 exe.root_module.addObject(main_o);
424 exe.addObject(a_o);424 exe.root_module.addObject(a_o);
425 exe.linkLibCpp();425 exe.root_module.link_libcpp = true;
426426
427 const run = addRunArtifact(exe);427 const run = addRunArtifact(exe);
428 run.expectStdOutEqual(428 run.expectStdOutEqual(
...@@ -435,12 +435,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {...@@ -435,12 +435,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
435435
436 {436 {
437 const c_o = addObject(b, opts, .{ .name = "c" });437 const c_o = addObject(b, opts, .{ .name = "c" });
438 c_o.addObject(main_o);438 c_o.root_module.addObject(main_o);
439 c_o.addObject(a_o);439 c_o.root_module.addObject(a_o);
440440
441 const exe = addExecutable(b, opts, .{ .name = "main3" });441 const exe = addExecutable(b, opts, .{ .name = "main3" });
442 exe.addObject(c_o);442 exe.root_module.addObject(c_o);
443 exe.linkLibCpp();443 exe.root_module.link_libcpp = true;
444444
445 const run = addRunArtifact(exe);445 const run = addRunArtifact(exe);
446 run.expectStdOutEqual(446 run.expectStdOutEqual(
...@@ -453,12 +453,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {...@@ -453,12 +453,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
453453
454 {454 {
455 const d_o = addObject(b, opts, .{ .name = "d" });455 const d_o = addObject(b, opts, .{ .name = "d" });
456 d_o.addObject(a_o);456 d_o.root_module.addObject(a_o);
457 d_o.addObject(main_o);457 d_o.root_module.addObject(main_o);
458458
459 const exe = addExecutable(b, opts, .{ .name = "main4" });459 const exe = addExecutable(b, opts, .{ .name = "main4" });
460 exe.addObject(d_o);460 exe.root_module.addObject(d_o);
461 exe.linkLibCpp();461 exe.root_module.link_libcpp = true;
462462
463 const run = addRunArtifact(exe);463 const run = addRunArtifact(exe);
464 run.expectStdOutEqual(464 run.expectStdOutEqual(
...@@ -522,7 +522,7 @@ fn testCommonSymbols(b: *Build, opts: Options) *Step {...@@ -522,7 +522,7 @@ fn testCommonSymbols(b: *Build, opts: Options) *Step {
522 \\ printf("%d %d %d\n", foo, bar, baz);522 \\ printf("%d %d %d\n", foo, bar, baz);
523 \\}523 \\}
524 , &.{"-fcommon"});524 , &.{"-fcommon"});
525 exe.linkLibC();525 exe.root_module.link_libc = true;
526526
527 const run = addRunArtifact(exe);527 const run = addRunArtifact(exe);
528 run.expectStdOutEqual("0 5 42\n");528 run.expectStdOutEqual("0 5 42\n");
...@@ -549,7 +549,7 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {...@@ -549,7 +549,7 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
549 ,549 ,
550 .c_source_flags = &.{"-fcommon"},550 .c_source_flags = &.{"-fcommon"},
551 });551 });
552 a_o.linkLibC();552 a_o.root_module.link_libc = true;
553553
554 const b_o = addObject(b, opts, .{554 const b_o = addObject(b, opts, .{
555 .name = "b",555 .name = "b",
...@@ -575,16 +575,16 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {...@@ -575,16 +575,16 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
575 });575 });
576576
577 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });577 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
578 lib.addObject(b_o);578 lib.root_module.addObject(b_o);
579 lib.addObject(c_o);579 lib.root_module.addObject(c_o);
580 lib.addObject(d_o);580 lib.root_module.addObject(d_o);
581581
582 const exe = addExecutable(b, opts, .{582 const exe = addExecutable(b, opts, .{
583 .name = "test",583 .name = "test",
584 });584 });
585 exe.addObject(a_o);585 exe.root_module.addObject(a_o);
586 exe.linkLibrary(lib);586 exe.root_module.linkLibrary(lib);
587 exe.linkLibC();587 exe.root_module.link_libc = true;
588588
589 const run = addRunArtifact(exe);589 const run = addRunArtifact(exe);
590 run.expectStdOutEqual("5 0 0 -1\n");590 run.expectStdOutEqual("5 0 0 -1\n");
...@@ -603,15 +603,15 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {...@@ -603,15 +603,15 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step {
603 });603 });
604604
605 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });605 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
606 lib.addObject(b_o);606 lib.root_module.addObject(b_o);
607 lib.addObject(e_o);607 lib.root_module.addObject(e_o);
608608
609 const exe = addExecutable(b, opts, .{609 const exe = addExecutable(b, opts, .{
610 .name = "test",610 .name = "test",
611 });611 });
612 exe.addObject(a_o);612 exe.root_module.addObject(a_o);
613 exe.linkLibrary(lib);613 exe.root_module.linkLibrary(lib);
614 exe.linkLibC();614 exe.root_module.link_libc = true;
615615
616 const run = addRunArtifact(exe);616 const run = addRunArtifact(exe);
617 run.expectStdOutEqual("5 0 7 2\n");617 run.expectStdOutEqual("5 0 7 2\n");
...@@ -641,8 +641,8 @@ fn testCopyrel(b: *Build, opts: Options) *Step {...@@ -641,8 +641,8 @@ fn testCopyrel(b: *Build, opts: Options) *Step {
641 \\}641 \\}
642 ,642 ,
643 });643 });
644 exe.linkLibrary(dso);644 exe.root_module.linkLibrary(dso);
645 exe.linkLibC();645 exe.root_module.link_libc = true;
646646
647 const run = addRunArtifact(exe);647 const run = addRunArtifact(exe);
648 run.expectStdOutEqual("3 5\n");648 run.expectStdOutEqual("3 5\n");
...@@ -679,8 +679,8 @@ fn testCopyrelAlias(b: *Build, opts: Options) *Step {...@@ -679,8 +679,8 @@ fn testCopyrelAlias(b: *Build, opts: Options) *Step {
679 \\extern int bar;679 \\extern int bar;
680 \\int *get_bar() { return &bar; }680 \\int *get_bar() { return &bar; }
681 , &.{});681 , &.{});
682 exe.linkLibrary(dso);682 exe.root_module.linkLibrary(dso);
683 exe.linkLibC();683 exe.root_module.link_libc = true;
684 exe.pie = false;684 exe.pie = false;
685685
686 const run = addRunArtifact(exe);686 const run = addRunArtifact(exe);
...@@ -712,15 +712,15 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {...@@ -712,15 +712,15 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
712 ,712 ,
713 .pic = false,713 .pic = false,
714 });714 });
715 obj.linkLibC();715 obj.root_module.link_libc = true;
716716
717 const exp_stdout = "5\n";717 const exp_stdout = "5\n";
718718
719 {719 {
720 const exe = addExecutable(b, opts, .{ .name = "main" });720 const exe = addExecutable(b, opts, .{ .name = "main" });
721 exe.addObject(obj);721 exe.root_module.addObject(obj);
722 exe.linkLibrary(a_so);722 exe.root_module.linkLibrary(a_so);
723 exe.linkLibC();723 exe.root_module.link_libc = true;
724 exe.pie = false;724 exe.pie = false;
725725
726 const run = addRunArtifact(exe);726 const run = addRunArtifact(exe);
...@@ -737,9 +737,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {...@@ -737,9 +737,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
737737
738 {738 {
739 const exe = addExecutable(b, opts, .{ .name = "main" });739 const exe = addExecutable(b, opts, .{ .name = "main" });
740 exe.addObject(obj);740 exe.root_module.addObject(obj);
741 exe.linkLibrary(b_so);741 exe.root_module.linkLibrary(b_so);
742 exe.linkLibC();742 exe.root_module.link_libc = true;
743 exe.pie = false;743 exe.pie = false;
744744
745 const run = addRunArtifact(exe);745 const run = addRunArtifact(exe);
...@@ -756,9 +756,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {...@@ -756,9 +756,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step {
756756
757 {757 {
758 const exe = addExecutable(b, opts, .{ .name = "main" });758 const exe = addExecutable(b, opts, .{ .name = "main" });
759 exe.addObject(obj);759 exe.root_module.addObject(obj);
760 exe.linkLibrary(c_so);760 exe.root_module.linkLibrary(c_so);
761 exe.linkLibC();761 exe.root_module.link_libc = true;
762 exe.pie = false;762 exe.pie = false;
763763
764 const run = addRunArtifact(exe);764 const run = addRunArtifact(exe);
...@@ -793,7 +793,7 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {...@@ -793,7 +793,7 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {
793 \\ real_hello();793 \\ real_hello();
794 \\}794 \\}
795 , &.{});795 , &.{});
796 dso.linkLibC();796 dso.root_module.link_libc = true;
797797
798 const exe = addExecutable(b, opts, .{ .name = "test" });798 const exe = addExecutable(b, opts, .{ .name = "test" });
799 addCSourceBytes(exe,799 addCSourceBytes(exe,
...@@ -806,8 +806,8 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {...@@ -806,8 +806,8 @@ fn testDsoPlt(b: *Build, opts: Options) *Step {
806 \\ hello();806 \\ hello();
807 \\}807 \\}
808 , &.{});808 , &.{});
809 exe.linkLibrary(dso);809 exe.root_module.linkLibrary(dso);
810 exe.linkLibC();810 exe.root_module.link_libc = true;
811811
812 const run = addRunArtifact(exe);812 const run = addRunArtifact(exe);
813 run.expectStdOutEqual("Hello WORLD\n");813 run.expectStdOutEqual("Hello WORLD\n");
...@@ -825,7 +825,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {...@@ -825,7 +825,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
825 \\int bar = 5;825 \\int bar = 5;
826 \\int baz() { return foo; }826 \\int baz() { return foo; }
827 , &.{});827 , &.{});
828 dso.linkLibC();828 dso.root_module.link_libc = true;
829829
830 const obj = addObject(b, opts, .{830 const obj = addObject(b, opts, .{
831 .name = "obj",831 .name = "obj",
...@@ -833,18 +833,18 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {...@@ -833,18 +833,18 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
833 });833 });
834834
835 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });835 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
836 lib.addObject(obj);836 lib.root_module.addObject(obj);
837837
838 const exe = addExecutable(b, opts, .{ .name = "test" });838 const exe = addExecutable(b, opts, .{ .name = "test" });
839 exe.linkLibrary(dso);839 exe.root_module.linkLibrary(dso);
840 exe.linkLibrary(lib);840 exe.root_module.linkLibrary(lib);
841 addCSourceBytes(exe,841 addCSourceBytes(exe,
842 \\extern int bar;842 \\extern int bar;
843 \\int main() {843 \\int main() {
844 \\ return bar - 5;844 \\ return bar - 5;
845 \\}845 \\}
846 , &.{});846 , &.{});
847 exe.linkLibC();847 exe.root_module.link_libc = true;
848848
849 const run = addRunArtifact(exe);849 const run = addRunArtifact(exe);
850 run.expectExitCode(0);850 run.expectExitCode(0);
...@@ -871,7 +871,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {...@@ -871,7 +871,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
871 \\ std.debug.print("foo={d}\n", .{foo()});871 \\ std.debug.print("foo={d}\n", .{foo()});
872 \\}872 \\}
873 });873 });
874 a_o.linkLibC();874 a_o.root_module.link_libc = true;
875875
876 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes = 876 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
877 \\#include <stdio.h>877 \\#include <stdio.h>
...@@ -880,11 +880,11 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {...@@ -880,11 +880,11 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
880 \\ fprintf(stderr, "bar=%d\n", bar);880 \\ fprintf(stderr, "bar=%d\n", bar);
881 \\}881 \\}
882 });882 });
883 b_o.linkLibC();883 b_o.root_module.link_libc = true;
884884
885 const c_o = addObject(b, opts, .{ .name = "c" });885 const c_o = addObject(b, opts, .{ .name = "c" });
886 c_o.addObject(a_o);886 c_o.root_module.addObject(a_o);
887 c_o.addObject(b_o);887 c_o.root_module.addObject(b_o);
888888
889 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes = 889 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
890 \\const std = @import("std");890 \\const std = @import("std");
...@@ -895,8 +895,8 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {...@@ -895,8 +895,8 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
895 \\ printBar();895 \\ printBar();
896 \\}896 \\}
897 });897 });
898 exe.addObject(c_o);898 exe.root_module.addObject(c_o);
899 exe.linkLibC();899 exe.root_module.link_libc = true;
900900
901 const run = addRunArtifact(exe);901 const run = addRunArtifact(exe);
902 run.expectStdErrEqual(902 run.expectStdErrEqual(
...@@ -944,9 +944,9 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {...@@ -944,9 +944,9 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {
944 });944 });
945945
946 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });946 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
947 lib.addObject(obj1);947 lib.root_module.addObject(obj1);
948 lib.addObject(obj2);948 lib.root_module.addObject(obj2);
949 lib.addObject(obj3);949 lib.root_module.addObject(obj3);
950950
951 const check = lib.checkObject();951 const check = lib.checkObject();
952 check.checkInArchiveSymtab();952 check.checkInArchiveSymtab();
...@@ -996,7 +996,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {...@@ -996,7 +996,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {
996 \\}996 \\}
997 ,997 ,
998 });998 });
999 lib.addObject(obj1);999 lib.root_module.addObject(obj1);
10001000
1001 const exe = addExecutable(b, opts, .{1001 const exe = addExecutable(b, opts, .{
1002 .name = "test",1002 .name = "test",
...@@ -1008,7 +1008,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {...@@ -1008,7 +1008,7 @@ fn testEmitStaticLibZig(b: *Build, opts: Options) *Step {
1008 \\}1008 \\}
1009 ,1009 ,
1010 });1010 });
1011 exe.linkLibrary(lib);1011 exe.root_module.linkLibrary(lib);
10121012
1013 const run = addRunArtifact(exe);1013 const run = addRunArtifact(exe);
1014 run.expectStdErrEqual("44");1014 run.expectStdErrEqual("44");
...@@ -1023,7 +1023,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {...@@ -1023,7 +1023,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
1023 const exe = addExecutable(b, opts, .{ .name = "test" });1023 const exe = addExecutable(b, opts, .{ .name = "test" });
1024 addCSourceBytes(exe, "int main() { return 0; }", &.{});1024 addCSourceBytes(exe, "int main() { return 0; }", &.{});
1025 addCSourceBytes(exe, "", &.{});1025 addCSourceBytes(exe, "", &.{});
1026 exe.linkLibC();1026 exe.root_module.link_libc = true;
10271027
1028 const run = addRunArtifact(exe);1028 const run = addRunArtifact(exe);
1029 run.expectExitCode(0);1029 run.expectExitCode(0);
...@@ -1052,8 +1052,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {...@@ -1052,8 +1052,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {
10521052
1053 {1053 {
1054 const exe = addExecutable(b, opts, .{ .name = "main" });1054 const exe = addExecutable(b, opts, .{ .name = "main" });
1055 exe.addObject(a_o);1055 exe.root_module.addObject(a_o);
1056 exe.addObject(b_o);1056 exe.root_module.addObject(b_o);
1057 exe.entry = .{ .symbol_name = "foo" };1057 exe.entry = .{ .symbol_name = "foo" };
10581058
1059 const check = exe.checkObject();1059 const check = exe.checkObject();
...@@ -1068,8 +1068,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {...@@ -1068,8 +1068,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {
1068 // cause an artifact collision taking the cached executable from the above1068 // cause an artifact collision taking the cached executable from the above
1069 // step instead of generating a new one.1069 // step instead of generating a new one.
1070 const exe = addExecutable(b, opts, .{ .name = "other" });1070 const exe = addExecutable(b, opts, .{ .name = "other" });
1071 exe.addObject(a_o);1071 exe.root_module.addObject(a_o);
1072 exe.addObject(b_o);1072 exe.root_module.addObject(b_o);
1073 exe.entry = .{ .symbol_name = "bar" };1073 exe.entry = .{ .symbol_name = "bar" };
10741074
1075 const check = exe.checkObject();1075 const check = exe.checkObject();
...@@ -1113,8 +1113,8 @@ fn testExportDynamic(b: *Build, opts: Options) *Step {...@@ -1113,8 +1113,8 @@ fn testExportDynamic(b: *Build, opts: Options) *Step {
1113 \\ return baz;1113 \\ return baz;
1114 \\}1114 \\}
1115 , &.{});1115 , &.{});
1116 exe.addObject(obj);1116 exe.root_module.addObject(obj);
1117 exe.linkLibrary(dso);1117 exe.root_module.linkLibrary(dso);
1118 exe.rdynamic = true;1118 exe.rdynamic = true;
11191119
1120 const check = exe.checkObject();1120 const check = exe.checkObject();
...@@ -1152,8 +1152,8 @@ fn testExportSymbolsFromExe(b: *Build, opts: Options) *Step {...@@ -1152,8 +1152,8 @@ fn testExportSymbolsFromExe(b: *Build, opts: Options) *Step {
1152 \\ foo();1152 \\ foo();
1153 \\}1153 \\}
1154 , &.{});1154 , &.{});
1155 exe.linkLibrary(dso);1155 exe.root_module.linkLibrary(dso);
1156 exe.linkLibC();1156 exe.root_module.link_libc = true;
11571157
1158 const check = exe.checkObject();1158 const check = exe.checkObject();
1159 check.checkInDynamicSymtab();1159 check.checkInDynamicSymtab();
...@@ -1181,7 +1181,7 @@ fn testFuncAddress(b: *Build, opts: Options) *Step {...@@ -1181,7 +1181,7 @@ fn testFuncAddress(b: *Build, opts: Options) *Step {
1181 \\ assert(fn == ptr);1181 \\ assert(fn == ptr);
1182 \\}1182 \\}
1183 , &.{});1183 , &.{});
1184 exe.linkLibrary(dso);1184 exe.root_module.linkLibrary(dso);
1185 exe.root_module.pic = false;1185 exe.root_module.pic = false;
1186 exe.pie = false;1186 exe.pie = false;
11871187
...@@ -1216,15 +1216,15 @@ fn testGcSections(b: *Build, opts: Options) *Step {...@@ -1216,15 +1216,15 @@ fn testGcSections(b: *Build, opts: Options) *Step {
1216 });1216 });
1217 obj.link_function_sections = true;1217 obj.link_function_sections = true;
1218 obj.link_data_sections = true;1218 obj.link_data_sections = true;
1219 obj.linkLibC();1219 obj.root_module.link_libc = true;
1220 obj.linkLibCpp();1220 obj.root_module.link_libcpp = true;
12211221
1222 {1222 {
1223 const exe = addExecutable(b, opts, .{ .name = "test" });1223 const exe = addExecutable(b, opts, .{ .name = "test" });
1224 exe.addObject(obj);1224 exe.root_module.addObject(obj);
1225 exe.link_gc_sections = false;1225 exe.link_gc_sections = false;
1226 exe.linkLibC();1226 exe.root_module.link_libc = true;
1227 exe.linkLibCpp();1227 exe.root_module.link_libcpp = true;
12281228
1229 const run = addRunArtifact(exe);1229 const run = addRunArtifact(exe);
1230 run.expectStdOutEqual("1 2\n");1230 run.expectStdOutEqual("1 2\n");
...@@ -1252,10 +1252,10 @@ fn testGcSections(b: *Build, opts: Options) *Step {...@@ -1252,10 +1252,10 @@ fn testGcSections(b: *Build, opts: Options) *Step {
12521252
1253 {1253 {
1254 const exe = addExecutable(b, opts, .{ .name = "test" });1254 const exe = addExecutable(b, opts, .{ .name = "test" });
1255 exe.addObject(obj);1255 exe.root_module.addObject(obj);
1256 exe.link_gc_sections = true;1256 exe.link_gc_sections = true;
1257 exe.linkLibC();1257 exe.root_module.link_libc = true;
1258 exe.linkLibCpp();1258 exe.root_module.link_libcpp = true;
12591259
1260 const run = addRunArtifact(exe);1260 const run = addRunArtifact(exe);
1261 run.expectStdOutEqual("1 2\n");1261 run.expectStdOutEqual("1 2\n");
...@@ -1321,7 +1321,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {...@@ -1321,7 +1321,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
1321 \\}1321 \\}
1322 ,1322 ,
1323 });1323 });
1324 exe.addObject(obj);1324 exe.root_module.addObject(obj);
1325 exe.link_gc_sections = false;1325 exe.link_gc_sections = false;
13261326
1327 const run = addRunArtifact(exe);1327 const run = addRunArtifact(exe);
...@@ -1363,7 +1363,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {...@@ -1363,7 +1363,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
1363 \\}1363 \\}
1364 ,1364 ,
1365 });1365 });
1366 exe.addObject(obj);1366 exe.root_module.addObject(obj);
1367 exe.link_gc_sections = true;1367 exe.link_gc_sections = true;
13681368
1369 const run = addRunArtifact(exe);1369 const run = addRunArtifact(exe);
...@@ -1427,7 +1427,7 @@ fn testIFuncAlias(b: *Build, opts: Options) *Step {...@@ -1427,7 +1427,7 @@ fn testIFuncAlias(b: *Build, opts: Options) *Step {
1427 \\}1427 \\}
1428 , &.{});1428 , &.{});
1429 exe.root_module.pic = true;1429 exe.root_module.pic = true;
1430 exe.linkLibC();1430 exe.root_module.link_libc = true;
14311431
1432 const run = addRunArtifact(exe);1432 const run = addRunArtifact(exe);
1433 run.expectExitCode(0);1433 run.expectExitCode(0);
...@@ -1467,9 +1467,9 @@ fn testIFuncDlopen(b: *Build, opts: Options) *Step {...@@ -1467,9 +1467,9 @@ fn testIFuncDlopen(b: *Build, opts: Options) *Step {
1467 \\ assert(foo == p);1467 \\ assert(foo == p);
1468 \\}1468 \\}
1469 , &.{});1469 , &.{});
1470 exe.linkLibrary(dso);1470 exe.root_module.linkLibrary(dso);
1471 exe.linkLibC();1471 exe.root_module.link_libc = true;
1472 exe.linkSystemLibrary2("dl", .{});1472 exe.root_module.linkSystemLibrary("dl", .{});
1473 exe.root_module.pic = false;1473 exe.root_module.pic = false;
1474 exe.pie = false;1474 exe.pie = false;
14751475
...@@ -1498,7 +1498,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {...@@ -1498,7 +1498,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {
1498 \\}1498 \\}
1499 ,1499 ,
1500 });1500 });
1501 dso.linkLibC();1501 dso.root_module.link_libc = true;
15021502
1503 const exe = addExecutable(b, opts, .{1503 const exe = addExecutable(b, opts, .{
1504 .name = "main",1504 .name = "main",
...@@ -1509,7 +1509,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {...@@ -1509,7 +1509,7 @@ fn testIFuncDso(b: *Build, opts: Options) *Step {
1509 \\}1509 \\}
1510 ,1510 ,
1511 });1511 });
1512 exe.linkLibrary(dso);1512 exe.root_module.linkLibrary(dso);
15131513
1514 const run = addRunArtifact(exe);1514 const run = addRunArtifact(exe);
1515 run.expectStdOutEqual("Hello world\n");1515 run.expectStdOutEqual("Hello world\n");
...@@ -1540,7 +1540,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {...@@ -1540,7 +1540,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {
1540 {1540 {
1541 const exe = addExecutable(b, opts, .{ .name = "main" });1541 const exe = addExecutable(b, opts, .{ .name = "main" });
1542 addCSourceBytes(exe, main_c, &.{});1542 addCSourceBytes(exe, main_c, &.{});
1543 exe.linkLibC();1543 exe.root_module.link_libc = true;
1544 exe.link_z_lazy = true;1544 exe.link_z_lazy = true;
15451545
1546 const run = addRunArtifact(exe);1546 const run = addRunArtifact(exe);
...@@ -1550,7 +1550,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {...@@ -1550,7 +1550,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step {
1550 {1550 {
1551 const exe = addExecutable(b, opts, .{ .name = "other" });1551 const exe = addExecutable(b, opts, .{ .name = "other" });
1552 addCSourceBytes(exe, main_c, &.{});1552 addCSourceBytes(exe, main_c, &.{});
1553 exe.linkLibC();1553 exe.root_module.link_libc = true;
15541554
1555 const run = addRunArtifact(exe);1555 const run = addRunArtifact(exe);
1556 run.expectStdOutEqual("Hello world\n");1556 run.expectStdOutEqual("Hello world\n");
...@@ -1576,7 +1576,7 @@ fn testIFuncExport(b: *Build, opts: Options) *Step {...@@ -1576,7 +1576,7 @@ fn testIFuncExport(b: *Build, opts: Options) *Step {
1576 \\ return real_foobar;1576 \\ return real_foobar;
1577 \\}1577 \\}
1578 , &.{});1578 , &.{});
1579 dso.linkLibC();1579 dso.root_module.link_libc = true;
15801580
1581 const check = dso.checkObject();1581 const check = dso.checkObject();
1582 check.checkInDynamicSymtab();1582 check.checkInDynamicSymtab();
...@@ -1613,7 +1613,7 @@ fn testIFuncFuncPtr(b: *Build, opts: Options) *Step {...@@ -1613,7 +1613,7 @@ fn testIFuncFuncPtr(b: *Build, opts: Options) *Step {
1613 \\}1613 \\}
1614 , &.{});1614 , &.{});
1615 exe.root_module.pic = true;1615 exe.root_module.pic = true;
1616 exe.linkLibC();1616 exe.root_module.link_libc = true;
16171617
1618 const run = addRunArtifact(exe);1618 const run = addRunArtifact(exe);
1619 run.expectStdOutEqual("3\n");1619 run.expectStdOutEqual("3\n");
...@@ -1642,7 +1642,7 @@ fn testIFuncNoPlt(b: *Build, opts: Options) *Step {...@@ -1642,7 +1642,7 @@ fn testIFuncNoPlt(b: *Build, opts: Options) *Step {
1642 \\}1642 \\}
1643 , &.{"-fno-plt"});1643 , &.{"-fno-plt"});
1644 exe.root_module.pic = true;1644 exe.root_module.pic = true;
1645 exe.linkLibC();1645 exe.root_module.link_libc = true;
16461646
1647 const run = addRunArtifact(exe);1647 const run = addRunArtifact(exe);
1648 run.expectStdOutEqual("Hello world\n");1648 run.expectStdOutEqual("Hello world\n");
...@@ -1669,7 +1669,7 @@ fn testIFuncStatic(b: *Build, opts: Options) *Step {...@@ -1669,7 +1669,7 @@ fn testIFuncStatic(b: *Build, opts: Options) *Step {
1669 \\ return 0;1669 \\ return 0;
1670 \\}1670 \\}
1671 , &.{});1671 , &.{});
1672 exe.linkLibC();1672 exe.root_module.link_libc = true;
1673 exe.linkage = .static;1673 exe.linkage = .static;
16741674
1675 const run = addRunArtifact(exe);1675 const run = addRunArtifact(exe);
...@@ -1700,7 +1700,7 @@ fn testIFuncStaticPie(b: *Build, opts: Options) *Step {...@@ -1700,7 +1700,7 @@ fn testIFuncStaticPie(b: *Build, opts: Options) *Step {
1700 exe.linkage = .static;1700 exe.linkage = .static;
1701 exe.root_module.pic = true;1701 exe.root_module.pic = true;
1702 exe.pie = true;1702 exe.pie = true;
1703 exe.linkLibC();1703 exe.root_module.link_libc = true;
17041704
1705 const run = addRunArtifact(exe);1705 const run = addRunArtifact(exe);
1706 run.expectStdOutEqual("Hello world\n");1706 run.expectStdOutEqual("Hello world\n");
...@@ -1733,7 +1733,7 @@ fn testImageBase(b: *Build, opts: Options) *Step {...@@ -1733,7 +1733,7 @@ fn testImageBase(b: *Build, opts: Options) *Step {
1733 \\ return 0;1733 \\ return 0;
1734 \\}1734 \\}
1735 , &.{});1735 , &.{});
1736 exe.linkLibC();1736 exe.root_module.link_libc = true;
1737 exe.image_base = 0x8000000;1737 exe.image_base = 0x8000000;
17381738
1739 const run = addRunArtifact(exe);1739 const run = addRunArtifact(exe);
...@@ -1779,7 +1779,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {...@@ -1779,7 +1779,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
1779 \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); }1779 \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); }
1780 ,1780 ,
1781 });1781 });
1782 dso.linkLibC();1782 dso.root_module.link_libc = true;
17831783
1784 const main = addExecutable(b, opts, .{1784 const main = addExecutable(b, opts, .{
1785 .name = "main",1785 .name = "main",
...@@ -1798,7 +1798,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {...@@ -1798,7 +1798,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
1798 .strip = true, // TODO temp hack1798 .strip = true, // TODO temp hack
1799 });1799 });
1800 main.pie = true;1800 main.pie = true;
1801 main.linkLibrary(dso);1801 main.root_module.linkLibrary(dso);
18021802
1803 const run = addRunArtifact(main);1803 const run = addRunArtifact(main);
1804 run.expectStdErrEqual(1804 run.expectStdErrEqual(
...@@ -1832,7 +1832,7 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {...@@ -1832,7 +1832,7 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {
1832 }, .{1832 }, .{
1833 .name = "a",1833 .name = "a",
1834 });1834 });
1835 lib.addObject(obj);1835 lib.root_module.addObject(obj);
18361836
1837 const main = addExecutable(b, opts, .{1837 const main = addExecutable(b, opts, .{
1838 .name = "main",1838 .name = "main",
...@@ -1844,8 +1844,8 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {...@@ -1844,8 +1844,8 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step {
1844 ,1844 ,
1845 .strip = true, // TODO temp hack1845 .strip = true, // TODO temp hack
1846 });1846 });
1847 main.linkLibrary(lib);1847 main.root_module.linkLibrary(lib);
1848 main.linkLibC();1848 main.root_module.link_libc = true;
18491849
1850 const run = addRunArtifact(main);1850 const run = addRunArtifact(main);
1851 run.expectStdErrEqual("42\n");1851 run.expectStdErrEqual("42\n");
...@@ -1864,7 +1864,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1864,7 +1864,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1864 \\__attribute__((constructor(10000))) void init4() { printf("1"); }1864 \\__attribute__((constructor(10000))) void init4() { printf("1"); }
1865 ,1865 ,
1866 });1866 });
1867 a_o.linkLibC();1867 a_o.root_module.link_libc = true;
18681868
1869 const b_o = addObject(b, opts, .{1869 const b_o = addObject(b, opts, .{
1870 .name = "b",1870 .name = "b",
...@@ -1873,7 +1873,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1873,7 +1873,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1873 \\__attribute__((constructor(1000))) void init3() { printf("2"); }1873 \\__attribute__((constructor(1000))) void init3() { printf("2"); }
1874 ,1874 ,
1875 });1875 });
1876 b_o.linkLibC();1876 b_o.root_module.link_libc = true;
18771877
1878 const c_o = addObject(b, opts, .{1878 const c_o = addObject(b, opts, .{
1879 .name = "c",1879 .name = "c",
...@@ -1882,7 +1882,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1882,7 +1882,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1882 \\__attribute__((constructor)) void init1() { printf("3"); }1882 \\__attribute__((constructor)) void init1() { printf("3"); }
1883 ,1883 ,
1884 });1884 });
1885 c_o.linkLibC();1885 c_o.root_module.link_libc = true;
18861886
1887 const d_o = addObject(b, opts, .{1887 const d_o = addObject(b, opts, .{
1888 .name = "d",1888 .name = "d",
...@@ -1891,7 +1891,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1891,7 +1891,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1891 \\__attribute__((constructor)) void init2() { printf("4"); }1891 \\__attribute__((constructor)) void init2() { printf("4"); }
1892 ,1892 ,
1893 });1893 });
1894 d_o.linkLibC();1894 d_o.root_module.link_libc = true;
18951895
1896 const e_o = addObject(b, opts, .{1896 const e_o = addObject(b, opts, .{
1897 .name = "e",1897 .name = "e",
...@@ -1900,7 +1900,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1900,7 +1900,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1900 \\__attribute__((destructor(10000))) void fini4() { printf("5"); }1900 \\__attribute__((destructor(10000))) void fini4() { printf("5"); }
1901 ,1901 ,
1902 });1902 });
1903 e_o.linkLibC();1903 e_o.root_module.link_libc = true;
19041904
1905 const f_o = addObject(b, opts, .{1905 const f_o = addObject(b, opts, .{
1906 .name = "f",1906 .name = "f",
...@@ -1909,7 +1909,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1909,7 +1909,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1909 \\__attribute__((destructor(1000))) void fini3() { printf("6"); }1909 \\__attribute__((destructor(1000))) void fini3() { printf("6"); }
1910 ,1910 ,
1911 });1911 });
1912 f_o.linkLibC();1912 f_o.root_module.link_libc = true;
19131913
1914 const g_o = addObject(b, opts, .{1914 const g_o = addObject(b, opts, .{
1915 .name = "g",1915 .name = "g",
...@@ -1918,24 +1918,24 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1918,24 +1918,24 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1918 \\__attribute__((destructor)) void fini1() { printf("7"); }1918 \\__attribute__((destructor)) void fini1() { printf("7"); }
1919 ,1919 ,
1920 });1920 });
1921 g_o.linkLibC();1921 g_o.root_module.link_libc = true;
19221922
1923 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes = 1923 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
1924 \\#include <stdio.h>1924 \\#include <stdio.h>
1925 \\__attribute__((destructor)) void fini2() { printf("8"); }1925 \\__attribute__((destructor)) void fini2() { printf("8"); }
1926 });1926 });
1927 h_o.linkLibC();1927 h_o.root_module.link_libc = true;
19281928
1929 const exe = addExecutable(b, opts, .{ .name = "main" });1929 const exe = addExecutable(b, opts, .{ .name = "main" });
1930 addCSourceBytes(exe, "int main() { return 0; }", &.{});1930 addCSourceBytes(exe, "int main() { return 0; }", &.{});
1931 exe.addObject(a_o);1931 exe.root_module.addObject(a_o);
1932 exe.addObject(b_o);1932 exe.root_module.addObject(b_o);
1933 exe.addObject(c_o);1933 exe.root_module.addObject(c_o);
1934 exe.addObject(d_o);1934 exe.root_module.addObject(d_o);
1935 exe.addObject(e_o);1935 exe.root_module.addObject(e_o);
1936 exe.addObject(f_o);1936 exe.root_module.addObject(f_o);
1937 exe.addObject(g_o);1937 exe.root_module.addObject(g_o);
1938 exe.addObject(h_o);1938 exe.root_module.addObject(h_o);
19391939
1940 if (opts.target.result.isGnuLibC()) {1940 if (opts.target.result.isGnuLibC()) {
1941 // TODO I think we need to clarify our use of `-fPIC -fPIE` flags for different targets1941 // 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 {...@@ -1970,7 +1970,7 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step {
1970 \\}1970 \\}
1971 , &.{});1971 , &.{});
1972 dso.link_function_sections = true;1972 dso.link_function_sections = true;
1973 dso.linkLibC();1973 dso.root_module.link_libc = true;
19741974
1975 const check = dso.checkObject();1975 const check = dso.checkObject();
1976 check.checkInSymtab();1976 check.checkInSymtab();
...@@ -1986,8 +1986,8 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step {...@@ -1986,8 +1986,8 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step {
1986 \\void greet();1986 \\void greet();
1987 \\int main() { greet(); }1987 \\int main() { greet(); }
1988 , &.{});1988 , &.{});
1989 exe.linkLibrary(dso);1989 exe.root_module.linkLibrary(dso);
1990 exe.linkLibC();1990 exe.root_module.link_libc = true;
19911991
1992 const run = addRunArtifact(exe);1992 const run = addRunArtifact(exe);
1993 run.expectStdOutEqual("Hello world");1993 run.expectStdOutEqual("Hello world");
...@@ -2021,7 +2021,7 @@ fn testLargeAlignmentExe(b: *Build, opts: Options) *Step {...@@ -2021,7 +2021,7 @@ fn testLargeAlignmentExe(b: *Build, opts: Options) *Step {
2021 \\}2021 \\}
2022 , &.{});2022 , &.{});
2023 exe.link_function_sections = true;2023 exe.link_function_sections = true;
2024 exe.linkLibC();2024 exe.root_module.link_libc = true;
20252025
2026 const check = exe.checkObject();2026 const check = exe.checkObject();
2027 check.checkInSymtab();2027 check.checkInSymtab();
...@@ -2049,7 +2049,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step {...@@ -2049,7 +2049,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step {
2049 \\ return arr[2000];2049 \\ return arr[2000];
2050 \\}2050 \\}
2051 , &.{});2051 , &.{});
2052 exe.linkLibC();2052 exe.root_module.link_libc = true;
2053 // Disabled to work around the ELF linker crashing.2053 // Disabled to work around the ELF linker crashing.
2054 // Can be reproduced on a x86_64-linux host by commenting out the line below.2054 // Can be reproduced on a x86_64-linux host by commenting out the line below.
2055 exe.root_module.sanitize_c = .off;2055 exe.root_module.sanitize_c = .off;
...@@ -2071,10 +2071,10 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {...@@ -2071,10 +2071,10 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
2071 });2071 });
20722072
2073 const dso = addSharedLibrary(b, opts, .{ .name = "a" });2073 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
2074 dso.addObject(obj);2074 dso.root_module.addObject(obj);
20752075
2076 const lib = addStaticLibrary(b, opts, .{ .name = "b" });2076 const lib = addStaticLibrary(b, opts, .{ .name = "b" });
2077 lib.addObject(obj);2077 lib.root_module.addObject(obj);
20782078
2079 const main_o = addObject(b, opts, .{2079 const main_o = addObject(b, opts, .{
2080 .name = "main",2080 .name = "main",
...@@ -2089,14 +2089,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {...@@ -2089,14 +2089,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
2089 // https://github.com/ziglang/zig/issues/174502089 // https://github.com/ziglang/zig/issues/17450
2090 // {2090 // {
2091 // const exe = addExecutable(b, opts, .{ .name = "main1"});2091 // const exe = addExecutable(b, opts, .{ .name = "main1"});
2092 // exe.addObject(main_o);2092 // exe.root_module.addObject(main_o);
2093 // exe.linkSystemLibrary2("a", .{});2093 // exe.root_module.linkSystemLibrary("a", .{});
2094 // exe.addLibraryPath(dso.getEmittedBinDirectory());2094 // exe.root_module.addLibraryPath(dso.getEmittedBinDirectory());
2095 // exe.addRPath(dso.getEmittedBinDirectory());2095 // exe.root_module.addRPath(dso.getEmittedBinDirectory());
2096 // exe.linkSystemLibrary2("b", .{});2096 // exe.root_module.linkSystemLibrary("b", .{});
2097 // exe.addLibraryPath(lib.getEmittedBinDirectory());2097 // exe.root_module.addLibraryPath(lib.getEmittedBinDirectory());
2098 // exe.addRPath(lib.getEmittedBinDirectory());2098 // exe.root_module.addRPath(lib.getEmittedBinDirectory());
2099 // exe.linkLibC();2099 // exe.root_module.link_libc = true;
21002100
2101 // const check = exe.checkObject();2101 // const check = exe.checkObject();
2102 // check.checkInDynamicSection();2102 // check.checkInDynamicSection();
...@@ -2106,14 +2106,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {...@@ -2106,14 +2106,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
21062106
2107 {2107 {
2108 const exe = addExecutable(b, opts, .{ .name = "main2" });2108 const exe = addExecutable(b, opts, .{ .name = "main2" });
2109 exe.addObject(main_o);2109 exe.root_module.addObject(main_o);
2110 exe.linkSystemLibrary2("b", .{});2110 exe.root_module.linkSystemLibrary("b", .{});
2111 exe.addLibraryPath(lib.getEmittedBinDirectory());2111 exe.root_module.addLibraryPath(lib.getEmittedBinDirectory());
2112 exe.addRPath(lib.getEmittedBinDirectory());2112 exe.root_module.addRPath(lib.getEmittedBinDirectory());
2113 exe.linkSystemLibrary2("a", .{});2113 exe.root_module.linkSystemLibrary("a", .{});
2114 exe.addLibraryPath(dso.getEmittedBinDirectory());2114 exe.root_module.addLibraryPath(dso.getEmittedBinDirectory());
2115 exe.addRPath(dso.getEmittedBinDirectory());2115 exe.root_module.addRPath(dso.getEmittedBinDirectory());
2116 exe.linkLibC();2116 exe.root_module.link_libc = true;
21172117
2118 const check = exe.checkObject();2118 const check = exe.checkObject();
2119 check.checkInDynamicSection();2119 check.checkInDynamicSection();
...@@ -2149,14 +2149,14 @@ fn testLdScript(b: *Build, opts: Options) *Step {...@@ -2149,14 +2149,14 @@ fn testLdScript(b: *Build, opts: Options) *Step {
2149 \\ return bar() - baz();2149 \\ return bar() - baz();
2150 \\}2150 \\}
2151 , &.{});2151 , &.{});
2152 exe.linkSystemLibrary2("a", .{});2152 exe.root_module.linkSystemLibrary("a", .{});
2153 exe.addLibraryPath(scripts.getDirectory());2153 exe.root_module.addLibraryPath(scripts.getDirectory());
2154 exe.addLibraryPath(scripts2.getDirectory());2154 exe.root_module.addLibraryPath(scripts2.getDirectory());
2155 exe.addLibraryPath(bar.getEmittedBinDirectory());2155 exe.root_module.addLibraryPath(bar.getEmittedBinDirectory());
2156 exe.addLibraryPath(baz.getEmittedBinDirectory());2156 exe.root_module.addLibraryPath(baz.getEmittedBinDirectory());
2157 exe.addRPath(bar.getEmittedBinDirectory());2157 exe.root_module.addRPath(bar.getEmittedBinDirectory());
2158 exe.addRPath(baz.getEmittedBinDirectory());2158 exe.root_module.addRPath(baz.getEmittedBinDirectory());
2159 exe.linkLibC();2159 exe.root_module.link_libc = true;
2160 exe.allow_so_scripts = true;2160 exe.allow_so_scripts = true;
21612161
2162 const run = addRunArtifact(exe);2162 const run = addRunArtifact(exe);
...@@ -2174,9 +2174,9 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step {...@@ -2174,9 +2174,9 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step {
21742174
2175 const exe = addExecutable(b, opts, .{ .name = "main" });2175 const exe = addExecutable(b, opts, .{ .name = "main" });
2176 addCSourceBytes(exe, "int main() { return 0; }", &.{});2176 addCSourceBytes(exe, "int main() { return 0; }", &.{});
2177 exe.linkSystemLibrary2("a", .{});2177 exe.root_module.linkSystemLibrary("a", .{});
2178 exe.addLibraryPath(scripts.getDirectory());2178 exe.root_module.addLibraryPath(scripts.getDirectory());
2179 exe.linkLibC();2179 exe.root_module.link_libc = true;
2180 exe.allow_so_scripts = true;2180 exe.allow_so_scripts = true;
21812181
2182 // TODO: A future enhancement could make this error message also mention2182 // TODO: A future enhancement could make this error message also mention
...@@ -2213,8 +2213,8 @@ fn testLdScriptAllowUndefinedVersion(b: *Build, opts: Options) *Step {...@@ -2213,8 +2213,8 @@ fn testLdScriptAllowUndefinedVersion(b: *Build, opts: Options) *Step {
2213 \\}2213 \\}
2214 ,2214 ,
2215 });2215 });
2216 exe.linkLibrary(so);2216 exe.root_module.linkLibrary(so);
2217 exe.linkLibC();2217 exe.root_module.link_libc = true;
2218 exe.allow_so_scripts = true;2218 exe.allow_so_scripts = true;
22192219
2220 const run = addRunArtifact(exe);2220 const run = addRunArtifact(exe);
...@@ -2269,8 +2269,8 @@ fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step {...@@ -2269,8 +2269,8 @@ fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step {
2269 \\ return foo;2269 \\ return foo;
2270 \\}2270 \\}
2271 , &.{});2271 , &.{});
2272 exe.addObject(obj);2272 exe.root_module.addObject(obj);
2273 exe.linkLibC();2273 exe.root_module.link_libc = true;
22742274
2275 expectLinkErrors(exe, test_step, .{ .exact = &.{2275 expectLinkErrors(exe, test_step, .{ .exact = &.{
2276 "invalid ELF machine type: AARCH64",2276 "invalid ELF machine type: AARCH64",
...@@ -2291,7 +2291,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step {...@@ -2291,7 +2291,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step {
2291 \\ return 0;2291 \\ return 0;
2292 \\}2292 \\}
2293 , &.{});2293 , &.{});
2294 exe.linkLibC();2294 exe.root_module.link_libc = true;
22952295
2296 const run = addRunArtifact(exe);2296 const run = addRunArtifact(exe);
2297 run.expectStdOutEqual("Hello World!\n");2297 run.expectStdOutEqual("Hello World!\n");
...@@ -2320,8 +2320,8 @@ fn testLinkingCpp(b: *Build, opts: Options) *Step {...@@ -2320,8 +2320,8 @@ fn testLinkingCpp(b: *Build, opts: Options) *Step {
2320 \\ return 0;2320 \\ return 0;
2321 \\}2321 \\}
2322 , &.{});2322 , &.{});
2323 exe.linkLibC();2323 exe.root_module.link_libc = true;
2324 exe.linkLibCpp();2324 exe.root_module.link_libcpp = true;
23252325
2326 const run = addRunArtifact(exe);2326 const run = addRunArtifact(exe);
2327 run.expectStdOutEqual("Hello World!\n");2327 run.expectStdOutEqual("Hello World!\n");
...@@ -2364,7 +2364,7 @@ fn testLinkingObj(b: *Build, opts: Options) *Step {...@@ -2364,7 +2364,7 @@ fn testLinkingObj(b: *Build, opts: Options) *Step {
2364 \\}2364 \\}
2365 ,2365 ,
2366 });2366 });
2367 exe.addObject(obj);2367 exe.root_module.addObject(obj);
23682368
2369 const run = addRunArtifact(exe);2369 const run = addRunArtifact(exe);
2370 run.expectStdErrEqual("84\n");2370 run.expectStdErrEqual("84\n");
...@@ -2389,7 +2389,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {...@@ -2389,7 +2389,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
2389 \\}2389 \\}
2390 ,2390 ,
2391 });2391 });
2392 lib.addObject(obj);2392 lib.root_module.addObject(obj);
23932393
2394 const exe = addExecutable(b, opts, .{2394 const exe = addExecutable(b, opts, .{
2395 .name = "testlib",2395 .name = "testlib",
...@@ -2402,7 +2402,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {...@@ -2402,7 +2402,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
2402 \\}2402 \\}
2403 ,2403 ,
2404 });2404 });
2405 exe.linkLibrary(lib);2405 exe.root_module.linkLibrary(lib);
24062406
2407 const run = addRunArtifact(exe);2407 const run = addRunArtifact(exe);
2408 run.expectStdErrEqual("0\n");2408 run.expectStdErrEqual("0\n");
...@@ -2452,7 +2452,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {...@@ -2452,7 +2452,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
2452 \\char16_t *utf16_1 = u"foo";2452 \\char16_t *utf16_1 = u"foo";
2453 \\char32_t *utf32_1 = U"foo";2453 \\char32_t *utf32_1 = U"foo";
2454 , &.{"-O2"});2454 , &.{"-O2"});
2455 obj1.linkLibC();2455 obj1.root_module.link_libc = true;
24562456
2457 const obj2 = addObject(b, opts, .{ .name = "b.o" });2457 const obj2 = addObject(b, opts, .{ .name = "b.o" });
2458 addCSourceBytes(obj2,2458 addCSourceBytes(obj2,
...@@ -2481,12 +2481,12 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {...@@ -2481,12 +2481,12 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
2481 \\ assert((void*)wide1 != (void*)utf16_1);2481 \\ assert((void*)wide1 != (void*)utf16_1);
2482 \\}2482 \\}
2483 , &.{"-O2"});2483 , &.{"-O2"});
2484 obj2.linkLibC();2484 obj2.root_module.link_libc = true;
24852485
2486 const exe = addExecutable(b, opts, .{ .name = "main" });2486 const exe = addExecutable(b, opts, .{ .name = "main" });
2487 exe.addObject(obj1);2487 exe.root_module.addObject(obj1);
2488 exe.addObject(obj2);2488 exe.root_module.addObject(obj2);
2489 exe.linkLibC();2489 exe.root_module.link_libc = true;
24902490
2491 const run = addRunArtifact(exe);2491 const run = addRunArtifact(exe);
2492 run.expectExitCode(0);2492 run.expectExitCode(0);
...@@ -2520,8 +2520,8 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {...@@ -2520,8 +2520,8 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
25202520
2521 {2521 {
2522 const exe = addExecutable(b, opts, .{ .name = "main1" });2522 const exe = addExecutable(b, opts, .{ .name = "main1" });
2523 exe.addObject(obj1);2523 exe.root_module.addObject(obj1);
2524 exe.addObject(obj2);2524 exe.root_module.addObject(obj2);
25252525
2526 const run = addRunArtifact(exe);2526 const run = addRunArtifact(exe);
2527 run.expectExitCode(0);2527 run.expectExitCode(0);
...@@ -2537,11 +2537,11 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {...@@ -2537,11 +2537,11 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
25372537
2538 {2538 {
2539 const obj3 = addObject(b, opts, .{ .name = "c" });2539 const obj3 = addObject(b, opts, .{ .name = "c" });
2540 obj3.addObject(obj1);2540 obj3.root_module.addObject(obj1);
2541 obj3.addObject(obj2);2541 obj3.root_module.addObject(obj2);
25422542
2543 const exe = addExecutable(b, opts, .{ .name = "main2" });2543 const exe = addExecutable(b, opts, .{ .name = "main2" });
2544 exe.addObject(obj3);2544 exe.root_module.addObject(obj3);
25452545
2546 const run = addRunArtifact(exe);2546 const run = addRunArtifact(exe);
2547 run.expectExitCode(0);2547 run.expectExitCode(0);
...@@ -2564,7 +2564,7 @@ fn testNoEhFrameHdr(b: *Build, opts: Options) *Step {...@@ -2564,7 +2564,7 @@ fn testNoEhFrameHdr(b: *Build, opts: Options) *Step {
2564 const exe = addExecutable(b, opts, .{ .name = "main" });2564 const exe = addExecutable(b, opts, .{ .name = "main" });
2565 addCSourceBytes(exe, "int main() { return 0; }", &.{});2565 addCSourceBytes(exe, "int main() { return 0; }", &.{});
2566 exe.link_eh_frame_hdr = false;2566 exe.link_eh_frame_hdr = false;
2567 exe.linkLibC();2567 exe.root_module.link_libc = true;
25682568
2569 const check = exe.checkObject();2569 const check = exe.checkObject();
2570 check.checkInHeaders();2570 check.checkInHeaders();
...@@ -2586,7 +2586,7 @@ fn testPie(b: *Build, opts: Options) *Step {...@@ -2586,7 +2586,7 @@ fn testPie(b: *Build, opts: Options) *Step {
2586 \\ return 0;2586 \\ return 0;
2587 \\}2587 \\}
2588 , &.{});2588 , &.{});
2589 exe.linkLibC();2589 exe.root_module.link_libc = true;
2590 exe.root_module.pic = true;2590 exe.root_module.pic = true;
2591 exe.pie = true;2591 exe.pie = true;
25922592
...@@ -2617,7 +2617,7 @@ fn testPltGot(b: *Build, opts: Options) *Step {...@@ -2617,7 +2617,7 @@ fn testPltGot(b: *Build, opts: Options) *Step {
2617 \\ printf("Hello world\n");2617 \\ printf("Hello world\n");
2618 \\}2618 \\}
2619 , &.{});2619 , &.{});
2620 dso.linkLibC();2620 dso.root_module.link_libc = true;
26212621
2622 const exe = addExecutable(b, opts, .{ .name = "main" });2622 const exe = addExecutable(b, opts, .{ .name = "main" });
2623 addCSourceBytes(exe,2623 addCSourceBytes(exe,
...@@ -2626,9 +2626,9 @@ fn testPltGot(b: *Build, opts: Options) *Step {...@@ -2626,9 +2626,9 @@ fn testPltGot(b: *Build, opts: Options) *Step {
2626 \\void foo() { ignore(hello); }2626 \\void foo() { ignore(hello); }
2627 \\int main() { hello(); }2627 \\int main() { hello(); }
2628 , &.{});2628 , &.{});
2629 exe.linkLibrary(dso);2629 exe.root_module.linkLibrary(dso);
2630 exe.root_module.pic = true;2630 exe.root_module.pic = true;
2631 exe.linkLibC();2631 exe.root_module.link_libc = true;
26322632
2633 const run = addRunArtifact(exe);2633 const run = addRunArtifact(exe);
2634 run.expectStdOutEqual("Hello world\n");2634 run.expectStdOutEqual("Hello world\n");
...@@ -2647,7 +2647,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {...@@ -2647,7 +2647,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
2647 });2647 });
26482648
2649 const exe = addExecutable(b, opts, .{ .name = "main1" });2649 const exe = addExecutable(b, opts, .{ .name = "main1" });
2650 exe.addObject(obj);2650 exe.root_module.addObject(obj);
26512651
2652 const check = exe.checkObject();2652 const check = exe.checkObject();
2653 check.checkInDynamicSection();2653 check.checkInDynamicSection();
...@@ -2662,7 +2662,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {...@@ -2662,7 +2662,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
2662 \\__attribute__((section(".preinit_array")))2662 \\__attribute__((section(".preinit_array")))
2663 \\void *preinit[] = { preinit_fn };2663 \\void *preinit[] = { preinit_fn };
2664 , &.{});2664 , &.{});
2665 exe.linkLibC();2665 exe.root_module.link_libc = true;
26662666
2667 const check = exe.checkObject();2667 const check = exe.checkObject();
2668 check.checkInDynamicSection();2668 check.checkInDynamicSection();
...@@ -2710,15 +2710,15 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {...@@ -2710,15 +2710,15 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {
2710 });2710 });
27112711
2712 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });2712 const lib = addStaticLibrary(b, opts, .{ .name = "lib" });
2713 lib.addObject(obj1);2713 lib.root_module.addObject(obj1);
2714 lib.addObject(obj2);2714 lib.root_module.addObject(obj2);
2715 lib.addObject(obj3);2715 lib.root_module.addObject(obj3);
27162716
2717 const obj5 = addObject(b, opts, .{2717 const obj5 = addObject(b, opts, .{
2718 .name = "obj5",2718 .name = "obj5",
2719 });2719 });
2720 obj5.addObject(obj4);2720 obj5.root_module.addObject(obj4);
2721 obj5.linkLibrary(lib);2721 obj5.root_module.linkLibrary(lib);
27222722
2723 const check = obj5.checkObject();2723 const check = obj5.checkObject();
2724 check.checkInSymtab();2724 check.checkInSymtab();
...@@ -2744,7 +2744,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2744,7 +2744,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2744 \\}2744 \\}
2745 ,2745 ,
2746 });2746 });
2747 obj1.linkLibCpp();2747 obj1.root_module.link_libcpp = true;
2748 const obj2 = addObject(b, opts, .{2748 const obj2 = addObject(b, opts, .{
2749 .name = "obj2",2749 .name = "obj2",
2750 .cpp_source_bytes =2750 .cpp_source_bytes =
...@@ -2754,7 +2754,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2754,7 +2754,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2754 \\}2754 \\}
2755 ,2755 ,
2756 });2756 });
2757 obj2.linkLibCpp();2757 obj2.root_module.link_libcpp = true;
2758 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes = 2758 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
2759 \\#include <iostream>2759 \\#include <iostream>
2760 \\#include <stdexcept>2760 \\#include <stdexcept>
...@@ -2768,18 +2768,18 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2768,18 +2768,18 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2768 \\ return 0;2768 \\ return 0;
2769 \\}2769 \\}
2770 });2770 });
2771 obj3.linkLibCpp();2771 obj3.root_module.link_libcpp = true;
27722772
2773 {2773 {
2774 const obj = addObject(b, opts, .{ .name = "obj" });2774 const obj = addObject(b, opts, .{ .name = "obj" });
2775 obj.addObject(obj1);2775 obj.root_module.addObject(obj1);
2776 obj.addObject(obj2);2776 obj.root_module.addObject(obj2);
2777 obj.linkLibCpp();2777 obj.root_module.link_libcpp = true;
27782778
2779 const exe = addExecutable(b, opts, .{ .name = "test1" });2779 const exe = addExecutable(b, opts, .{ .name = "test1" });
2780 exe.addObject(obj3);2780 exe.root_module.addObject(obj3);
2781 exe.addObject(obj);2781 exe.root_module.addObject(obj);
2782 exe.linkLibCpp();2782 exe.root_module.link_libcpp = true;
27832783
2784 const run = addRunArtifact(exe);2784 const run = addRunArtifact(exe);
2785 run.expectStdOutEqual("exception=Oh no!");2785 run.expectStdOutEqual("exception=Oh no!");
...@@ -2788,14 +2788,14 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2788,14 +2788,14 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2788 {2788 {
2789 // Flipping the order should not influence the end result.2789 // Flipping the order should not influence the end result.
2790 const obj = addObject(b, opts, .{ .name = "obj" });2790 const obj = addObject(b, opts, .{ .name = "obj" });
2791 obj.addObject(obj2);2791 obj.root_module.addObject(obj2);
2792 obj.addObject(obj1);2792 obj.root_module.addObject(obj1);
2793 obj.linkLibCpp();2793 obj.root_module.link_libcpp = true;
27942794
2795 const exe = addExecutable(b, opts, .{ .name = "test2" });2795 const exe = addExecutable(b, opts, .{ .name = "test2" });
2796 exe.addObject(obj3);2796 exe.root_module.addObject(obj3);
2797 exe.addObject(obj);2797 exe.root_module.addObject(obj);
2798 exe.linkLibCpp();2798 exe.root_module.link_libcpp = true;
27992799
2800 const run = addRunArtifact(exe);2800 const run = addRunArtifact(exe);
2801 run.expectStdOutEqual("exception=Oh no!");2801 run.expectStdOutEqual("exception=Oh no!");
...@@ -2817,7 +2817,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {...@@ -2817,7 +2817,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2817 \\}2817 \\}
2818 ,2818 ,
2819 });2819 });
2820 obj1.linkLibCpp();2820 obj1.root_module.link_libcpp = true;
2821 const obj2 = addObject(b, opts, .{2821 const obj2 = addObject(b, opts, .{
2822 .name = "obj2",2822 .name = "obj2",
2823 .cpp_source_bytes =2823 .cpp_source_bytes =
...@@ -2827,7 +2827,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {...@@ -2827,7 +2827,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2827 \\}2827 \\}
2828 ,2828 ,
2829 });2829 });
2830 obj2.linkLibCpp();2830 obj2.root_module.link_libcpp = true;
2831 const obj3 = addObject(b, opts, .{2831 const obj3 = addObject(b, opts, .{
2832 .name = "obj3",2832 .name = "obj3",
2833 .cpp_source_bytes =2833 .cpp_source_bytes =
...@@ -2844,17 +2844,17 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {...@@ -2844,17 +2844,17 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2844 \\}2844 \\}
2845 ,2845 ,
2846 });2846 });
2847 obj3.linkLibCpp();2847 obj3.root_module.link_libcpp = true;
28482848
2849 const obj = addObject(b, opts, .{ .name = "obj" });2849 const obj = addObject(b, opts, .{ .name = "obj" });
2850 obj.addObject(obj1);2850 obj.root_module.addObject(obj1);
2851 obj.addObject(obj2);2851 obj.root_module.addObject(obj2);
2852 obj.addObject(obj3);2852 obj.root_module.addObject(obj3);
2853 obj.linkLibCpp();2853 obj.root_module.link_libcpp = true;
28542854
2855 const exe = addExecutable(b, opts, .{ .name = "test2" });2855 const exe = addExecutable(b, opts, .{ .name = "test2" });
2856 exe.addObject(obj);2856 exe.root_module.addObject(obj);
2857 exe.linkLibCpp();2857 exe.root_module.link_libcpp = true;
28582858
2859 const run = addRunArtifact(exe);2859 const run = addRunArtifact(exe);
2860 run.expectStdOutEqual("exception=Oh no!");2860 run.expectStdOutEqual("exception=Oh no!");
...@@ -2880,7 +2880,7 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {...@@ -2880,7 +2880,7 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
2880 });2880 });
28812881
2882 const obj2 = addObject(b, opts, .{ .name = "b" });2882 const obj2 = addObject(b, opts, .{ .name = "b" });
2883 obj2.addObject(obj1);2883 obj2.root_module.addObject(obj1);
28842884
2885 const check = obj2.checkObject();2885 const check = obj2.checkObject();
2886 check.dumpSection(".rodata.str1.1");2886 check.dumpSection(".rodata.str1.1");
...@@ -2905,7 +2905,7 @@ fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step {...@@ -2905,7 +2905,7 @@ fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step {
2905 const obj2 = addObject(b, opts, .{2905 const obj2 = addObject(b, opts, .{
2906 .name = "obj2",2906 .name = "obj2",
2907 });2907 });
2908 obj2.addObject(obj1);2908 obj2.root_module.addObject(obj1);
29092909
2910 const check1 = obj1.checkObject();2910 const check1 = obj1.checkObject();
2911 check1.checkInHeaders();2911 check1.checkInHeaders();
...@@ -2940,12 +2940,12 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {...@@ -2940,12 +2940,12 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
2940 ,2940 ,
2941 .pic = true,2941 .pic = true,
2942 });2942 });
2943 obj.linkLibC();2943 obj.root_module.link_libc = true;
29442944
2945 {2945 {
2946 const exe = addExecutable(b, opts, .{ .name = "main1" });2946 const exe = addExecutable(b, opts, .{ .name = "main1" });
2947 exe.addObject(obj);2947 exe.root_module.addObject(obj);
2948 exe.linkLibrary(dso);2948 exe.root_module.linkLibrary(dso);
2949 exe.pie = true;2949 exe.pie = true;
29502950
2951 const run = addRunArtifact(exe);2951 const run = addRunArtifact(exe);
...@@ -2965,8 +2965,8 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {...@@ -2965,8 +2965,8 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
2965 // https://github.com/ziglang/zig/issues/174302965 // https://github.com/ziglang/zig/issues/17430
2966 // {2966 // {
2967 // const exe = addExecutable(b, opts, .{ .name = "main2"});2967 // const exe = addExecutable(b, opts, .{ .name = "main2"});
2968 // exe.addObject(obj);2968 // exe.root_module.addObject(obj);
2969 // exe.linkLibrary(dso);2969 // exe.root_module.linkLibrary(dso);
2970 // exe.pie = false;2970 // exe.pie = false;
29712971
2972 // const run = addRunArtifact(exe);2972 // const run = addRunArtifact(exe);
...@@ -2999,13 +2999,13 @@ fn testStrip(b: *Build, opts: Options) *Step {...@@ -2999,13 +2999,13 @@ fn testStrip(b: *Build, opts: Options) *Step {
2999 \\}2999 \\}
3000 ,3000 ,
3001 });3001 });
3002 obj.linkLibC();3002 obj.root_module.link_libc = true;
30033003
3004 {3004 {
3005 const exe = addExecutable(b, opts, .{ .name = "main1" });3005 const exe = addExecutable(b, opts, .{ .name = "main1" });
3006 exe.addObject(obj);3006 exe.root_module.addObject(obj);
3007 exe.root_module.strip = false;3007 exe.root_module.strip = false;
3008 exe.linkLibC();3008 exe.root_module.link_libc = true;
30093009
3010 const check = exe.checkObject();3010 const check = exe.checkObject();
3011 check.checkInHeaders();3011 check.checkInHeaders();
...@@ -3016,9 +3016,9 @@ fn testStrip(b: *Build, opts: Options) *Step {...@@ -3016,9 +3016,9 @@ fn testStrip(b: *Build, opts: Options) *Step {
30163016
3017 {3017 {
3018 const exe = addExecutable(b, opts, .{ .name = "main2" });3018 const exe = addExecutable(b, opts, .{ .name = "main2" });
3019 exe.addObject(obj);3019 exe.root_module.addObject(obj);
3020 exe.root_module.strip = true;3020 exe.root_module.strip = true;
3021 exe.linkLibC();3021 exe.root_module.link_libc = true;
30223022
3023 const check = exe.checkObject();3023 const check = exe.checkObject();
3024 check.checkInHeaders();3024 check.checkInHeaders();
...@@ -3074,7 +3074,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {...@@ -3074,7 +3074,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {
30743074
3075 {3075 {
3076 const dso = addSharedLibrary(b, opts, .{ .name = "a" });3076 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3077 dso.addObject(obj);3077 dso.root_module.addObject(obj);
3078 // dso.link_relax = true;3078 // dso.link_relax = true;
30793079
3080 const check = dso.checkObject();3080 const check = dso.checkObject();
...@@ -3086,7 +3086,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {...@@ -3086,7 +3086,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step {
3086 // TODO add -Wl,--no-relax3086 // TODO add -Wl,--no-relax
3087 // {3087 // {
3088 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});3088 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3089 // dso.addObject(obj);3089 // dso.root_module.addObject(obj);
3090 // dso.link_relax = false;3090 // dso.link_relax = false;
30913091
3092 // const check = dso.checkObject();3092 // const check = dso.checkObject();
...@@ -3128,8 +3128,8 @@ fn testTlsDso(b: *Build, opts: Options) *Step {...@@ -3128,8 +3128,8 @@ fn testTlsDso(b: *Build, opts: Options) *Step {
3128 \\ return 0;3128 \\ return 0;
3129 \\}3129 \\}
3130 , &.{});3130 , &.{});
3131 exe.linkLibrary(dso);3131 exe.root_module.linkLibrary(dso);
3132 exe.linkLibC();3132 exe.root_module.link_libc = true;
31333133
3134 const run = addRunArtifact(exe);3134 const run = addRunArtifact(exe);
3135 run.expectStdOutEqual("5 3 5 3 5 3\n");3135 run.expectStdOutEqual("5 3 5 3 5 3\n");
...@@ -3159,7 +3159,7 @@ fn testTlsGd(b: *Build, opts: Options) *Step {...@@ -3159,7 +3159,7 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
3159 ,3159 ,
3160 .pic = true,3160 .pic = true,
3161 });3161 });
3162 main_o.linkLibC();3162 main_o.root_module.link_libc = true;
31633163
3164 const a_o = addObject(b, opts, .{3164 const a_o = addObject(b, opts, .{
3165 .name = "a",3165 .name = "a",
...@@ -3184,17 +3184,17 @@ fn testTlsGd(b: *Build, opts: Options) *Step {...@@ -3184,17 +3184,17 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
3184 const exp_stdout = "1 2 3 4 5 6\n";3184 const exp_stdout = "1 2 3 4 5 6\n";
31853185
3186 const dso1 = addSharedLibrary(b, opts, .{ .name = "a" });3186 const dso1 = addSharedLibrary(b, opts, .{ .name = "a" });
3187 dso1.addObject(a_o);3187 dso1.root_module.addObject(a_o);
31883188
3189 const dso2 = addSharedLibrary(b, opts, .{ .name = "b" });3189 const dso2 = addSharedLibrary(b, opts, .{ .name = "b" });
3190 dso2.addObject(b_o);3190 dso2.root_module.addObject(b_o);
3191 // dso2.link_relax = false; // TODO3191 // dso2.link_relax = false; // TODO
31923192
3193 {3193 {
3194 const exe = addExecutable(b, opts, .{ .name = "main1" });3194 const exe = addExecutable(b, opts, .{ .name = "main1" });
3195 exe.addObject(main_o);3195 exe.root_module.addObject(main_o);
3196 exe.linkLibrary(dso1);3196 exe.root_module.linkLibrary(dso1);
3197 exe.linkLibrary(dso2);3197 exe.root_module.linkLibrary(dso2);
31983198
3199 const run = addRunArtifact(exe);3199 const run = addRunArtifact(exe);
3200 run.expectStdOutEqual(exp_stdout);3200 run.expectStdOutEqual(exp_stdout);
...@@ -3203,10 +3203,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {...@@ -3203,10 +3203,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
32033203
3204 {3204 {
3205 const exe = addExecutable(b, opts, .{ .name = "main2" });3205 const exe = addExecutable(b, opts, .{ .name = "main2" });
3206 exe.addObject(main_o);3206 exe.root_module.addObject(main_o);
3207 // exe.link_relax = false; // TODO3207 // exe.link_relax = false; // TODO
3208 exe.linkLibrary(dso1);3208 exe.root_module.linkLibrary(dso1);
3209 exe.linkLibrary(dso2);3209 exe.root_module.linkLibrary(dso2);
32103210
3211 const run = addRunArtifact(exe);3211 const run = addRunArtifact(exe);
3212 run.expectStdOutEqual(exp_stdout);3212 run.expectStdOutEqual(exp_stdout);
...@@ -3216,9 +3216,9 @@ fn testTlsGd(b: *Build, opts: Options) *Step {...@@ -3216,9 +3216,9 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
3216 // https://github.com/ziglang/zig/issues/17430 ??3216 // https://github.com/ziglang/zig/issues/17430 ??
3217 // {3217 // {
3218 // const exe = addExecutable(b, opts, .{ .name = "main3"});3218 // const exe = addExecutable(b, opts, .{ .name = "main3"});
3219 // exe.addObject(main_o);3219 // exe.root_module.addObject(main_o);
3220 // exe.linkLibrary(dso1);3220 // exe.root_module.linkLibrary(dso1);
3221 // exe.linkLibrary(dso2);3221 // exe.root_module.linkLibrary(dso2);
3222 // exe.linkage = .static;3222 // exe.linkage = .static;
32233223
3224 // const run = addRunArtifact(exe);3224 // const run = addRunArtifact(exe);
...@@ -3228,10 +3228,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {...@@ -3228,10 +3228,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step {
32283228
3229 // {3229 // {
3230 // const exe = addExecutable(b, opts, .{ .name = "main4"});3230 // const exe = addExecutable(b, opts, .{ .name = "main4"});
3231 // exe.addObject(main_o);3231 // exe.root_module.addObject(main_o);
3232 // // exe.link_relax = false; // TODO3232 // // exe.link_relax = false; // TODO
3233 // exe.linkLibrary(dso1);3233 // exe.root_module.linkLibrary(dso1);
3234 // exe.linkLibrary(dso2);3234 // exe.root_module.linkLibrary(dso2);
3235 // exe.linkage = .static;3235 // exe.linkage = .static;
32363236
3237 // const run = addRunArtifact(exe);3237 // const run = addRunArtifact(exe);
...@@ -3265,7 +3265,7 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {...@@ -3265,7 +3265,7 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
3265 .c_source_flags = &.{"-fno-plt"},3265 .c_source_flags = &.{"-fno-plt"},
3266 .pic = true,3266 .pic = true,
3267 });3267 });
3268 obj.linkLibC();3268 obj.root_module.link_libc = true;
32693269
3270 const a_so = addSharedLibrary(b, opts, .{ .name = "a" });3270 const a_so = addSharedLibrary(b, opts, .{ .name = "a" });
3271 addCSourceBytes(a_so,3271 addCSourceBytes(a_so,
...@@ -3284,10 +3284,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {...@@ -3284,10 +3284,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
32843284
3285 {3285 {
3286 const exe = addExecutable(b, opts, .{ .name = "main1" });3286 const exe = addExecutable(b, opts, .{ .name = "main1" });
3287 exe.addObject(obj);3287 exe.root_module.addObject(obj);
3288 exe.linkLibrary(a_so);3288 exe.root_module.linkLibrary(a_so);
3289 exe.linkLibrary(b_so);3289 exe.root_module.linkLibrary(b_so);
3290 exe.linkLibC();3290 exe.root_module.link_libc = true;
32913291
3292 const run = addRunArtifact(exe);3292 const run = addRunArtifact(exe);
3293 run.expectStdOutEqual("1 2 3 4 5 6\n");3293 run.expectStdOutEqual("1 2 3 4 5 6\n");
...@@ -3296,10 +3296,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {...@@ -3296,10 +3296,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step {
32963296
3297 {3297 {
3298 const exe = addExecutable(b, opts, .{ .name = "main2" });3298 const exe = addExecutable(b, opts, .{ .name = "main2" });
3299 exe.addObject(obj);3299 exe.root_module.addObject(obj);
3300 exe.linkLibrary(a_so);3300 exe.root_module.linkLibrary(a_so);
3301 exe.linkLibrary(b_so);3301 exe.root_module.linkLibrary(b_so);
3302 exe.linkLibC();3302 exe.root_module.link_libc = true;
3303 // exe.link_relax = false; // TODO3303 // exe.link_relax = false; // TODO
33043304
3305 const run = addRunArtifact(exe);3305 const run = addRunArtifact(exe);
...@@ -3329,7 +3329,7 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {...@@ -3329,7 +3329,7 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
3329 ,3329 ,
3330 .pic = true,3330 .pic = true,
3331 });3331 });
3332 a_o.linkLibC();3332 a_o.root_module.link_libc = true;
33333333
3334 const b_o = addObject(b, opts, .{3334 const b_o = addObject(b, opts, .{
3335 .name = "b",3335 .name = "b",
...@@ -3342,12 +3342,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {...@@ -3342,12 +3342,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33423342
3343 {3343 {
3344 const dso = addSharedLibrary(b, opts, .{ .name = "a1" });3344 const dso = addSharedLibrary(b, opts, .{ .name = "a1" });
3345 dso.addObject(a_o);3345 dso.root_module.addObject(a_o);
33463346
3347 const exe = addExecutable(b, opts, .{ .name = "main1" });3347 const exe = addExecutable(b, opts, .{ .name = "main1" });
3348 exe.addObject(b_o);3348 exe.root_module.addObject(b_o);
3349 exe.linkLibrary(dso);3349 exe.root_module.linkLibrary(dso);
3350 exe.linkLibC();3350 exe.root_module.link_libc = true;
33513351
3352 const run = addRunArtifact(exe);3352 const run = addRunArtifact(exe);
3353 run.expectStdOutEqual("1 2 3\n");3353 run.expectStdOutEqual("1 2 3\n");
...@@ -3356,13 +3356,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {...@@ -3356,13 +3356,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33563356
3357 {3357 {
3358 const dso = addSharedLibrary(b, opts, .{ .name = "a2" });3358 const dso = addSharedLibrary(b, opts, .{ .name = "a2" });
3359 dso.addObject(a_o);3359 dso.root_module.addObject(a_o);
3360 // dso.link_relax = false; // TODO3360 // dso.link_relax = false; // TODO
33613361
3362 const exe = addExecutable(b, opts, .{ .name = "main2" });3362 const exe = addExecutable(b, opts, .{ .name = "main2" });
3363 exe.addObject(b_o);3363 exe.root_module.addObject(b_o);
3364 exe.linkLibrary(dso);3364 exe.root_module.linkLibrary(dso);
3365 exe.linkLibC();3365 exe.root_module.link_libc = true;
33663366
3367 const run = addRunArtifact(exe);3367 const run = addRunArtifact(exe);
3368 run.expectStdOutEqual("1 2 3\n");3368 run.expectStdOutEqual("1 2 3\n");
...@@ -3371,12 +3371,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {...@@ -3371,12 +3371,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33713371
3372 // {3372 // {
3373 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});3373 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3374 // dso.addObject(a_o);3374 // dso.root_module.addObject(a_o);
3375 // dso.link_z_nodlopen = true;3375 // dso.link_z_nodlopen = true;
33763376
3377 // const exe = addExecutable(b, opts, .{ .name = "main"});3377 // const exe = addExecutable(b, opts, .{ .name = "main"});
3378 // exe.addObject(b_o);3378 // exe.root_module.addObject(b_o);
3379 // exe.linkLibrary(dso);3379 // exe.root_module.linkLibrary(dso);
33803380
3381 // const run = addRunArtifact(exe);3381 // const run = addRunArtifact(exe);
3382 // run.expectStdOutEqual("1 2 3\n");3382 // run.expectStdOutEqual("1 2 3\n");
...@@ -3385,13 +3385,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {...@@ -3385,13 +3385,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step {
33853385
3386 // {3386 // {
3387 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});3387 // const dso = addSharedLibrary(b, opts, .{ .name = "a"});
3388 // dso.addObject(a_o);3388 // dso.root_module.addObject(a_o);
3389 // dso.link_relax = false;3389 // dso.link_relax = false;
3390 // dso.link_z_nodlopen = true;3390 // dso.link_z_nodlopen = true;
33913391
3392 // const exe = addExecutable(b, opts, .{ .name = "main"});3392 // const exe = addExecutable(b, opts, .{ .name = "main"});
3393 // exe.addObject(b_o);3393 // exe.root_module.addObject(b_o);
3394 // exe.linkLibrary(dso);3394 // exe.root_module.linkLibrary(dso);
33953395
3396 // const run = addRunArtifact(exe);3396 // const run = addRunArtifact(exe);
3397 // run.expectStdOutEqual("1 2 3\n");3397 // run.expectStdOutEqual("1 2 3\n");
...@@ -3417,7 +3417,7 @@ fn testTlsIe(b: *Build, opts: Options) *Step {...@@ -3417,7 +3417,7 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
3417 \\ printf("%d %d ", foo, bar);3417 \\ printf("%d %d ", foo, bar);
3418 \\}3418 \\}
3419 , &.{});3419 , &.{});
3420 dso.linkLibC();3420 dso.root_module.link_libc = true;
34213421
3422 const main_o = addObject(b, opts, .{3422 const main_o = addObject(b, opts, .{
3423 .name = "main",3423 .name = "main",
...@@ -3435,15 +3435,15 @@ fn testTlsIe(b: *Build, opts: Options) *Step {...@@ -3435,15 +3435,15 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
3435 \\}3435 \\}
3436 ,3436 ,
3437 });3437 });
3438 main_o.linkLibC();3438 main_o.root_module.link_libc = true;
34393439
3440 const exp_stdout = "0 0 3 5 7\n";3440 const exp_stdout = "0 0 3 5 7\n";
34413441
3442 {3442 {
3443 const exe = addExecutable(b, opts, .{ .name = "main1" });3443 const exe = addExecutable(b, opts, .{ .name = "main1" });
3444 exe.addObject(main_o);3444 exe.root_module.addObject(main_o);
3445 exe.linkLibrary(dso);3445 exe.root_module.linkLibrary(dso);
3446 exe.linkLibC();3446 exe.root_module.link_libc = true;
34473447
3448 const run = addRunArtifact(exe);3448 const run = addRunArtifact(exe);
3449 run.expectStdOutEqual(exp_stdout);3449 run.expectStdOutEqual(exp_stdout);
...@@ -3452,9 +3452,9 @@ fn testTlsIe(b: *Build, opts: Options) *Step {...@@ -3452,9 +3452,9 @@ fn testTlsIe(b: *Build, opts: Options) *Step {
34523452
3453 {3453 {
3454 const exe = addExecutable(b, opts, .{ .name = "main2" });3454 const exe = addExecutable(b, opts, .{ .name = "main2" });
3455 exe.addObject(main_o);3455 exe.root_module.addObject(main_o);
3456 exe.linkLibrary(dso);3456 exe.root_module.linkLibrary(dso);
3457 exe.linkLibC();3457 exe.root_module.link_libc = true;
3458 // exe.link_relax = false; // TODO3458 // exe.link_relax = false; // TODO
34593459
3460 const run = addRunArtifact(exe);3460 const run = addRunArtifact(exe);
...@@ -3500,17 +3500,17 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {...@@ -3500,17 +3500,17 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {
3500 ,3500 ,
3501 .pic = true,3501 .pic = true,
3502 });3502 });
3503 c_o.linkLibC();3503 c_o.root_module.link_libc = true;
35043504
3505 {3505 {
3506 const dso = addSharedLibrary(b, opts, .{ .name = "a" });3506 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3507 dso.addObject(a_o);3507 dso.root_module.addObject(a_o);
3508 dso.addObject(b_o);3508 dso.root_module.addObject(b_o);
35093509
3510 const exe = addExecutable(b, opts, .{ .name = "main" });3510 const exe = addExecutable(b, opts, .{ .name = "main" });
3511 exe.addObject(c_o);3511 exe.root_module.addObject(c_o);
3512 exe.linkLibrary(dso);3512 exe.root_module.linkLibrary(dso);
3513 exe.linkLibC();3513 exe.root_module.link_libc = true;
35143514
3515 const run = addRunArtifact(exe);3515 const run = addRunArtifact(exe);
3516 run.expectStdOutEqual("42 1 2 3\n");3516 run.expectStdOutEqual("42 1 2 3\n");
...@@ -3519,10 +3519,10 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {...@@ -3519,10 +3519,10 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step {
35193519
3520 {3520 {
3521 const exe = addExecutable(b, opts, .{ .name = "main" });3521 const exe = addExecutable(b, opts, .{ .name = "main" });
3522 exe.addObject(a_o);3522 exe.root_module.addObject(a_o);
3523 exe.addObject(b_o);3523 exe.root_module.addObject(b_o);
3524 exe.addObject(c_o);3524 exe.root_module.addObject(c_o);
3525 exe.linkLibC();3525 exe.root_module.link_libc = true;
35263526
3527 const run = addRunArtifact(exe);3527 const run = addRunArtifact(exe);
3528 run.expectStdOutEqual("42 1 2 3\n");3528 run.expectStdOutEqual("42 1 2 3\n");
...@@ -3555,7 +3555,7 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step {...@@ -3555,7 +3555,7 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
3555 \\ printf("%d %d %d %d %d %d\n", x[0], x[1], x[1023], y[0], y[1], y[1023]);3555 \\ printf("%d %d %d %d %d %d\n", x[0], x[1], x[1023], y[0], y[1], y[1023]);
3556 \\}3556 \\}
3557 , &.{});3557 , &.{});
3558 exe.linkLibC();3558 exe.root_module.link_libc = true;
3559 // Disabled to work around the ELF linker crashing.3559 // Disabled to work around the ELF linker crashing.
3560 // Can be reproduced on a x86_64-linux host by commenting out the line below.3560 // Can be reproduced on a x86_64-linux host by commenting out the line below.
3561 exe.root_module.sanitize_c = .off;3561 exe.root_module.sanitize_c = .off;
...@@ -3580,7 +3580,7 @@ fn testTlsLargeStaticImage(b: *Build, opts: Options) *Step {...@@ -3580,7 +3580,7 @@ fn testTlsLargeStaticImage(b: *Build, opts: Options) *Step {
3580 \\}3580 \\}
3581 , &.{});3581 , &.{});
3582 exe.root_module.pic = true;3582 exe.root_module.pic = true;
3583 exe.linkLibC();3583 exe.root_module.link_libc = true;
35843584
3585 const run = addRunArtifact(exe);3585 const run = addRunArtifact(exe);
3586 run.expectStdOutEqual("1 2 3 0 5\n");3586 run.expectStdOutEqual("1 2 3 0 5\n");
...@@ -3609,7 +3609,7 @@ fn testTlsLd(b: *Build, opts: Options) *Step {...@@ -3609,7 +3609,7 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
3609 .c_source_flags = &.{"-ftls-model=local-dynamic"},3609 .c_source_flags = &.{"-ftls-model=local-dynamic"},
3610 .pic = true,3610 .pic = true,
3611 });3611 });
3612 main_o.linkLibC();3612 main_o.root_module.link_libc = true;
36133613
3614 const a_o = addObject(b, opts, .{3614 const a_o = addObject(b, opts, .{
3615 .name = "a",3615 .name = "a",
...@@ -3622,9 +3622,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {...@@ -3622,9 +3622,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
36223622
3623 {3623 {
3624 const exe = addExecutable(b, opts, .{ .name = "main1" });3624 const exe = addExecutable(b, opts, .{ .name = "main1" });
3625 exe.addObject(main_o);3625 exe.root_module.addObject(main_o);
3626 exe.addObject(a_o);3626 exe.root_module.addObject(a_o);
3627 exe.linkLibC();3627 exe.root_module.link_libc = true;
36283628
3629 const run = addRunArtifact(exe);3629 const run = addRunArtifact(exe);
3630 run.expectStdOutEqual(exp_stdout);3630 run.expectStdOutEqual(exp_stdout);
...@@ -3633,9 +3633,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {...@@ -3633,9 +3633,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step {
36333633
3634 {3634 {
3635 const exe = addExecutable(b, opts, .{ .name = "main2" });3635 const exe = addExecutable(b, opts, .{ .name = "main2" });
3636 exe.addObject(main_o);3636 exe.root_module.addObject(main_o);
3637 exe.addObject(a_o);3637 exe.root_module.addObject(a_o);
3638 exe.linkLibC();3638 exe.root_module.link_libc = true;
3639 // exe.link_relax = false; // TODO3639 // exe.link_relax = false; // TODO
36403640
3641 const run = addRunArtifact(exe);3641 const run = addRunArtifact(exe);
...@@ -3668,8 +3668,8 @@ fn testTlsLdDso(b: *Build, opts: Options) *Step {...@@ -3668,8 +3668,8 @@ fn testTlsLdDso(b: *Build, opts: Options) *Step {
3668 \\ return 0;3668 \\ return 0;
3669 \\}3669 \\}
3670 , &.{});3670 , &.{});
3671 exe.linkLibrary(dso);3671 exe.root_module.linkLibrary(dso);
3672 exe.linkLibC();3672 exe.root_module.link_libc = true;
36733673
3674 const run = addRunArtifact(exe);3674 const run = addRunArtifact(exe);
3675 run.expectStdOutEqual("1 2\n");3675 run.expectStdOutEqual("1 2\n");
...@@ -3699,7 +3699,7 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {...@@ -3699,7 +3699,7 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
3699 .c_source_flags = &.{ "-ftls-model=local-dynamic", "-fno-plt" },3699 .c_source_flags = &.{ "-ftls-model=local-dynamic", "-fno-plt" },
3700 .pic = true,3700 .pic = true,
3701 });3701 });
3702 a_o.linkLibC();3702 a_o.root_module.link_libc = true;
37033703
3704 const b_o = addObject(b, opts, .{3704 const b_o = addObject(b, opts, .{
3705 .name = "b",3705 .name = "b",
...@@ -3710,9 +3710,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {...@@ -3710,9 +3710,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
37103710
3711 {3711 {
3712 const exe = addExecutable(b, opts, .{ .name = "main1" });3712 const exe = addExecutable(b, opts, .{ .name = "main1" });
3713 exe.addObject(a_o);3713 exe.root_module.addObject(a_o);
3714 exe.addObject(b_o);3714 exe.root_module.addObject(b_o);
3715 exe.linkLibC();3715 exe.root_module.link_libc = true;
37163716
3717 const run = addRunArtifact(exe);3717 const run = addRunArtifact(exe);
3718 run.expectStdOutEqual("3 5 3 5\n");3718 run.expectStdOutEqual("3 5 3 5\n");
...@@ -3721,9 +3721,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {...@@ -3721,9 +3721,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step {
37213721
3722 {3722 {
3723 const exe = addExecutable(b, opts, .{ .name = "main2" });3723 const exe = addExecutable(b, opts, .{ .name = "main2" });
3724 exe.addObject(a_o);3724 exe.root_module.addObject(a_o);
3725 exe.addObject(b_o);3725 exe.root_module.addObject(b_o);
3726 exe.linkLibC();3726 exe.root_module.link_libc = true;
3727 // exe.link_relax = false; // TODO3727 // exe.link_relax = false; // TODO
37283728
3729 const run = addRunArtifact(exe);3729 const run = addRunArtifact(exe);
...@@ -3756,7 +3756,7 @@ fn testTlsNoPic(b: *Build, opts: Options) *Step {...@@ -3756,7 +3756,7 @@ fn testTlsNoPic(b: *Build, opts: Options) *Step {
3756 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo;3756 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo;
3757 , &.{});3757 , &.{});
3758 exe.root_module.pic = false;3758 exe.root_module.pic = false;
3759 exe.linkLibC();3759 exe.root_module.link_libc = true;
37603760
3761 const run = addRunArtifact(exe);3761 const run = addRunArtifact(exe);
3762 run.expectStdOutEqual("3 5 3 5\n");3762 run.expectStdOutEqual("3 5 3 5\n");
...@@ -3784,7 +3784,7 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {...@@ -3784,7 +3784,7 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {
3784 \\ return NULL;3784 \\ return NULL;
3785 \\}3785 \\}
3786 , &.{});3786 , &.{});
3787 dso.linkLibC();3787 dso.root_module.link_libc = true;
37883788
3789 const exe = addExecutable(b, opts, .{ .name = "main" });3789 const exe = addExecutable(b, opts, .{ .name = "main" });
3790 addCSourceBytes(exe,3790 addCSourceBytes(exe,
...@@ -3811,8 +3811,8 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {...@@ -3811,8 +3811,8 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step {
3811 \\ pthread_join(thread, NULL);3811 \\ pthread_join(thread, NULL);
3812 \\}3812 \\}
3813 , &.{});3813 , &.{});
3814 exe.addRPath(dso.getEmittedBinDirectory());3814 exe.root_module.addRPath(dso.getEmittedBinDirectory());
3815 exe.linkLibC();3815 exe.root_module.link_libc = true;
3816 exe.root_module.pic = true;3816 exe.root_module.pic = true;
38173817
3818 const run = addRunArtifact(exe);3818 const run = addRunArtifact(exe);
...@@ -3842,14 +3842,14 @@ fn testTlsPic(b: *Build, opts: Options) *Step {...@@ -3842,14 +3842,14 @@ fn testTlsPic(b: *Build, opts: Options) *Step {
3842 ,3842 ,
3843 .pic = true,3843 .pic = true,
3844 });3844 });
3845 obj.linkLibC();3845 obj.root_module.link_libc = true;
38463846
3847 const exe = addExecutable(b, opts, .{ .name = "main" });3847 const exe = addExecutable(b, opts, .{ .name = "main" });
3848 addCSourceBytes(exe,3848 addCSourceBytes(exe,
3849 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo = 3;3849 \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo = 3;
3850 , &.{});3850 , &.{});
3851 exe.addObject(obj);3851 exe.root_module.addObject(obj);
3852 exe.linkLibC();3852 exe.root_module.link_libc = true;
38533853
3854 const run = addRunArtifact(exe);3854 const run = addRunArtifact(exe);
3855 run.expectStdOutEqual("3 5 3 5\n");3855 run.expectStdOutEqual("3 5 3 5\n");
...@@ -3889,14 +3889,14 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {...@@ -3889,14 +3889,14 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {
3889 ,3889 ,
3890 .pic = true,3890 .pic = true,
3891 });3891 });
3892 c_o.linkLibC();3892 c_o.root_module.link_libc = true;
38933893
3894 {3894 {
3895 const exe = addExecutable(b, opts, .{ .name = "main" });3895 const exe = addExecutable(b, opts, .{ .name = "main" });
3896 exe.addObject(a_o);3896 exe.root_module.addObject(a_o);
3897 exe.addObject(b_o);3897 exe.root_module.addObject(b_o);
3898 exe.addObject(c_o);3898 exe.root_module.addObject(c_o);
3899 exe.linkLibC();3899 exe.root_module.link_libc = true;
39003900
3901 const run = addRunArtifact(exe);3901 const run = addRunArtifact(exe);
3902 run.expectStdOutEqual("42\n");3902 run.expectStdOutEqual("42\n");
...@@ -3905,13 +3905,13 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {...@@ -3905,13 +3905,13 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step {
39053905
3906 {3906 {
3907 const dso = addSharedLibrary(b, opts, .{ .name = "a" });3907 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
3908 dso.addObject(a_o);3908 dso.root_module.addObject(a_o);
3909 dso.addObject(b_o);3909 dso.root_module.addObject(b_o);
39103910
3911 const exe = addExecutable(b, opts, .{ .name = "main" });3911 const exe = addExecutable(b, opts, .{ .name = "main" });
3912 exe.addObject(c_o);3912 exe.root_module.addObject(c_o);
3913 exe.linkLibrary(dso);3913 exe.root_module.linkLibrary(dso);
3914 exe.linkLibC();3914 exe.root_module.link_libc = true;
39153915
3916 const run = addRunArtifact(exe);3916 const run = addRunArtifact(exe);
3917 run.expectStdOutEqual("42\n");3917 run.expectStdOutEqual("42\n");
...@@ -3939,7 +3939,7 @@ fn testTlsStatic(b: *Build, opts: Options) *Step {...@@ -3939,7 +3939,7 @@ fn testTlsStatic(b: *Build, opts: Options) *Step {
3939 \\ return 0;3939 \\ return 0;
3940 \\}3940 \\}
3941 , &.{});3941 , &.{});
3942 exe.linkLibC();3942 exe.root_module.link_libc = true;
39433943
3944 const run = addRunArtifact(exe);3944 const run = addRunArtifact(exe);
3945 run.expectStdOutEqual(3945 run.expectStdOutEqual(
...@@ -3969,8 +3969,8 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step {...@@ -3969,8 +3969,8 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step {
3969 \\ return foo;3969 \\ return foo;
3970 \\}3970 \\}
3971 , &.{});3971 , &.{});
3972 exe.linkLibrary(dylib);3972 exe.root_module.linkLibrary(dylib);
3973 exe.linkLibC();3973 exe.root_module.link_libc = true;
39743974
3975 expectLinkErrors(exe, test_step, .{3975 expectLinkErrors(exe, test_step, .{
3976 .contains = "error: failed to parse shared library: BadMagic",3976 .contains = "error: failed to parse shared library: BadMagic",
...@@ -3993,7 +3993,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {...@@ -3993,7 +3993,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
3993 ,3993 ,
3994 .c_source_flags = &.{"-ffunction-sections"},3994 .c_source_flags = &.{"-ffunction-sections"},
3995 });3995 });
3996 obj1.linkLibC();3996 obj1.root_module.link_libc = true;
39973997
3998 const obj2 = addObject(b, opts, .{3998 const obj2 = addObject(b, opts, .{
3999 .name = "b",3999 .name = "b",
...@@ -4007,12 +4007,12 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {...@@ -4007,12 +4007,12 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
4007 ,4007 ,
4008 .c_source_flags = &.{"-ffunction-sections"},4008 .c_source_flags = &.{"-ffunction-sections"},
4009 });4009 });
4010 obj2.linkLibC();4010 obj2.root_module.link_libc = true;
40114011
4012 const exe = addExecutable(b, opts, .{ .name = "main" });4012 const exe = addExecutable(b, opts, .{ .name = "main" });
4013 exe.addObject(obj1);4013 exe.root_module.addObject(obj1);
4014 exe.addObject(obj2);4014 exe.root_module.addObject(obj2);
4015 exe.linkLibC();4015 exe.root_module.link_libc = true;
40164016
4017 expectLinkErrors(exe, test_step, .{ .exact = &.{4017 expectLinkErrors(exe, test_step, .{ .exact = &.{
4018 "error: undefined symbol: foo",4018 "error: undefined symbol: foo",
...@@ -4037,12 +4037,12 @@ fn testWeakExports(b: *Build, opts: Options) *Step {...@@ -4037,12 +4037,12 @@ fn testWeakExports(b: *Build, opts: Options) *Step {
4037 ,4037 ,
4038 .pic = true,4038 .pic = true,
4039 });4039 });
4040 obj.linkLibC();4040 obj.root_module.link_libc = true;
40414041
4042 {4042 {
4043 const dso = addSharedLibrary(b, opts, .{ .name = "a" });4043 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4044 dso.addObject(obj);4044 dso.root_module.addObject(obj);
4045 dso.linkLibC();4045 dso.root_module.link_libc = true;
40464046
4047 const check = dso.checkObject();4047 const check = dso.checkObject();
4048 check.checkInDynamicSymtab();4048 check.checkInDynamicSymtab();
...@@ -4052,8 +4052,8 @@ fn testWeakExports(b: *Build, opts: Options) *Step {...@@ -4052,8 +4052,8 @@ fn testWeakExports(b: *Build, opts: Options) *Step {
40524052
4053 {4053 {
4054 const exe = addExecutable(b, opts, .{ .name = "main" });4054 const exe = addExecutable(b, opts, .{ .name = "main" });
4055 exe.addObject(obj);4055 exe.root_module.addObject(obj);
4056 exe.linkLibC();4056 exe.root_module.link_libc = true;
40574057
4058 const check = exe.checkObject();4058 const check = exe.checkObject();
4059 check.checkInDynamicSymtab();4059 check.checkInDynamicSymtab();
...@@ -4084,8 +4084,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {...@@ -4084,8 +4084,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {
4084 \\int bar();4084 \\int bar();
4085 \\int main() { printf("bar=%d\n", bar()); }4085 \\int main() { printf("bar=%d\n", bar()); }
4086 , &.{});4086 , &.{});
4087 exe.linkLibrary(dso);4087 exe.root_module.linkLibrary(dso);
4088 exe.linkLibC();4088 exe.root_module.link_libc = true;
40894089
4090 const run = addRunArtifact(exe);4090 const run = addRunArtifact(exe);
4091 run.expectStdOutEqual("bar=-1\n");4091 run.expectStdOutEqual("bar=-1\n");
...@@ -4100,8 +4100,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {...@@ -4100,8 +4100,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step {
4100 \\int bar();4100 \\int bar();
4101 \\int main() { printf("bar=%d\n", bar()); }4101 \\int main() { printf("bar=%d\n", bar()); }
4102 , &.{});4102 , &.{});
4103 exe.linkLibrary(dso);4103 exe.root_module.linkLibrary(dso);
4104 exe.linkLibC();4104 exe.root_module.link_libc = true;
41054105
4106 const run = addRunArtifact(exe);4106 const run = addRunArtifact(exe);
4107 run.expectStdOutEqual("bar=5\n");4107 run.expectStdOutEqual("bar=5\n");
...@@ -4122,7 +4122,7 @@ fn testZNow(b: *Build, opts: Options) *Step {...@@ -4122,7 +4122,7 @@ fn testZNow(b: *Build, opts: Options) *Step {
41224122
4123 {4123 {
4124 const dso = addSharedLibrary(b, opts, .{ .name = "a" });4124 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4125 dso.addObject(obj);4125 dso.root_module.addObject(obj);
41264126
4127 const check = dso.checkObject();4127 const check = dso.checkObject();
4128 check.checkInDynamicSection();4128 check.checkInDynamicSection();
...@@ -4132,7 +4132,7 @@ fn testZNow(b: *Build, opts: Options) *Step {...@@ -4132,7 +4132,7 @@ fn testZNow(b: *Build, opts: Options) *Step {
41324132
4133 {4133 {
4134 const dso = addSharedLibrary(b, opts, .{ .name = "a" });4134 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4135 dso.addObject(obj);4135 dso.root_module.addObject(obj);
4136 dso.link_z_lazy = true;4136 dso.link_z_lazy = true;
41374137
4138 const check = dso.checkObject();4138 const check = dso.checkObject();
...@@ -4150,7 +4150,7 @@ fn testZStackSize(b: *Build, opts: Options) *Step {...@@ -4150,7 +4150,7 @@ fn testZStackSize(b: *Build, opts: Options) *Step {
4150 const exe = addExecutable(b, opts, .{ .name = "main" });4150 const exe = addExecutable(b, opts, .{ .name = "main" });
4151 addCSourceBytes(exe, "int main() { return 0; }", &.{});4151 addCSourceBytes(exe, "int main() { return 0; }", &.{});
4152 exe.stack_size = 0x800000;4152 exe.stack_size = 0x800000;
4153 exe.linkLibC();4153 exe.root_module.link_libc = true;
41544154
4155 const check = exe.checkObject();4155 const check = exe.checkObject();
4156 check.checkInHeaders();4156 check.checkInHeaders();
...@@ -4202,8 +4202,8 @@ fn testZText(b: *Build, opts: Options) *Step {...@@ -4202,8 +4202,8 @@ fn testZText(b: *Build, opts: Options) *Step {
4202 });4202 });
42034203
4204 const dso = addSharedLibrary(b, opts, .{ .name = "a" });4204 const dso = addSharedLibrary(b, opts, .{ .name = "a" });
4205 dso.addObject(a_o);4205 dso.root_module.addObject(a_o);
4206 dso.addObject(b_o);4206 dso.root_module.addObject(b_o);
4207 dso.link_z_notext = true;4207 dso.link_z_notext = true;
42084208
4209 const exe = addExecutable(b, opts, .{ .name = "main" });4209 const exe = addExecutable(b, opts, .{ .name = "main" });
...@@ -4214,8 +4214,8 @@ fn testZText(b: *Build, opts: Options) *Step {...@@ -4214,8 +4214,8 @@ fn testZText(b: *Build, opts: Options) *Step {
4214 \\ printf("%d\n", fnn());4214 \\ printf("%d\n", fnn());
4215 \\}4215 \\}
4216 , &.{});4216 , &.{});
4217 exe.linkLibrary(dso);4217 exe.root_module.linkLibrary(dso);
4218 exe.linkLibC();4218 exe.root_module.link_libc = true;
42194219
4220 const run = addRunArtifact(exe);4220 const run = addRunArtifact(exe);
4221 run.expectStdOutEqual("3\n");4221 run.expectStdOutEqual("3\n");
test/link/link.zig+3-3
...@@ -140,20 +140,20 @@ pub fn addRunArtifact(comp: *Compile) *Run {...@@ -140,20 +140,20 @@ pub fn addRunArtifact(comp: *Compile) *Run {
140pub fn addCSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {140pub fn addCSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {
141 const b = comp.step.owner;141 const b = comp.step.owner;
142 const file = WriteFile.create(b).add("a.c", bytes);142 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 });
144}144}
145145
146pub fn addCppSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {146pub fn addCppSourceBytes(comp: *Compile, bytes: []const u8, flags: []const []const u8) void {
147 const b = comp.step.owner;147 const b = comp.step.owner;
148 const file = WriteFile.create(b).add("a.cpp", bytes);148 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 });
150}150}
151151
152pub fn addAsmSourceBytes(comp: *Compile, bytes: []const u8) void {152pub fn addAsmSourceBytes(comp: *Compile, bytes: []const u8) void {
153 const b = comp.step.owner;153 const b = comp.step.owner;
154 const actual_bytes = std.fmt.allocPrint(b.allocator, "{s}\n", .{bytes}) catch @panic("OOM");154 const actual_bytes = std.fmt.allocPrint(b.allocator, "{s}\n", .{bytes}) catch @panic("OOM");
155 const file = WriteFile.create(b).add("a.s", actual_bytes);155 const file = WriteFile.create(b).add("a.s", actual_bytes);
156 comp.addAssemblyFile(file);156 comp.root_module.addAssemblyFile(file);
157}157}
158158
159pub fn expectLinkErrors(comp: *Compile, test_step: *Step, expected_errors: Compile.ExpectedCompileErrors) void {159pub 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 {...@@ -127,7 +127,7 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
127127
128 {128 {
129 const exe = addExecutable(b, opts, .{ .name = "no_dead_strip" });129 const exe = addExecutable(b, opts, .{ .name = "no_dead_strip" });
130 exe.addObject(obj);130 exe.root_module.addObject(obj);
131 exe.link_gc_sections = false;131 exe.link_gc_sections = false;
132132
133 const check = exe.checkObject();133 const check = exe.checkObject();
...@@ -156,7 +156,7 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {...@@ -156,7 +156,7 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
156156
157 {157 {
158 const exe = addExecutable(b, opts, .{ .name = "yes_dead_strip" });158 const exe = addExecutable(b, opts, .{ .name = "yes_dead_strip" });
159 exe.addObject(obj);159 exe.root_module.addObject(obj);
160 exe.link_gc_sections = true;160 exe.link_gc_sections = true;
161161
162 const check = exe.checkObject();162 const check = exe.checkObject();
...@@ -206,7 +206,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {...@@ -206,7 +206,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
206 \\ strong();206 \\ strong();
207 \\}207 \\}
208 });208 });
209 exe.addObject(obj);209 exe.root_module.addObject(obj);
210210
211 expectLinkErrors(exe, test_step, .{ .exact = &.{211 expectLinkErrors(exe, test_step, .{ .exact = &.{
212 "error: duplicate symbol definition: _strong",212 "error: duplicate symbol definition: _strong",
...@@ -235,7 +235,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {...@@ -235,7 +235,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
235235
236 {236 {
237 const exe = addExecutable(b, opts, .{ .name = "main1" });237 const exe = addExecutable(b, opts, .{ .name = "main1" });
238 exe.addObject(main_o);238 exe.root_module.addObject(main_o);
239 exe.root_module.linkFramework("Cocoa", .{});239 exe.root_module.linkFramework("Cocoa", .{});
240240
241 const check = exe.checkObject();241 const check = exe.checkObject();
...@@ -254,7 +254,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {...@@ -254,7 +254,7 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
254254
255 {255 {
256 const exe = addExecutable(b, opts, .{ .name = "main2" });256 const exe = addExecutable(b, opts, .{ .name = "main2" });
257 exe.addObject(main_o);257 exe.root_module.addObject(main_o);
258 exe.root_module.linkFramework("Cocoa", .{});258 exe.root_module.linkFramework("Cocoa", .{});
259 exe.dead_strip_dylibs = true;259 exe.dead_strip_dylibs = true;
260260
...@@ -350,7 +350,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {...@@ -350,7 +350,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
350 \\ printf("Hello world!");350 \\ printf("Hello world!");
351 \\}351 \\}
352 });352 });
353 exe.addObject(empty);353 exe.root_module.addObject(empty);
354354
355 const run = addRunArtifact(exe);355 const run = addRunArtifact(exe);
356 run.expectStdOutEqual("Hello world!");356 run.expectStdOutEqual("Hello world!");
...@@ -451,7 +451,7 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {...@@ -451,7 +451,7 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
451 \\ return 0;451 \\ return 0;
452 \\}452 \\}
453 , &.{});453 , &.{});
454 exe.linkLibrary(dylib);454 exe.root_module.linkLibrary(dylib);
455 exe.entry = .{ .symbol_name = "_bootstrap" };455 exe.entry = .{ .symbol_name = "_bootstrap" };
456 exe.forceUndefinedSymbol("_my_main");456 exe.forceUndefinedSymbol("_my_main");
457457
...@@ -604,11 +604,11 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {...@@ -604,11 +604,11 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
604 });604 });
605605
606 const lib = addSharedLibrary(b, opts, .{ .name = "a" });606 const lib = addSharedLibrary(b, opts, .{ .name = "a" });
607 lib.addObject(obj1);607 lib.root_module.addObject(obj1);
608608
609 {609 {
610 const exe = addExecutable(b, opts, .{ .name = "main1", .c_source_bytes = "int main() { return 0; }" });610 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
613 const check = exe.checkObject();613 const check = exe.checkObject();
614 check.checkInHeaders();614 check.checkInHeaders();
...@@ -642,8 +642,8 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {...@@ -642,8 +642,8 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
642 }642 }
643643
644 const exe = addExecutable(b, opts, .{ .name = "main2" });644 const exe = addExecutable(b, opts, .{ .name = "main2" });
645 exe.linkLibrary(lib);645 exe.root_module.linkLibrary(lib);
646 exe.addObject(obj);646 exe.root_module.addObject(obj);
647647
648 const check = exe.checkObject();648 const check = exe.checkObject();
649 check.checkInHeaders();649 check.checkInHeaders();
...@@ -665,7 +665,7 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {...@@ -665,7 +665,7 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
665 \\_main:665 \\_main:
666 \\ ret666 \\ ret
667 });667 });
668 exe.linkLibrary(lib);668 exe.root_module.linkLibrary(lib);
669669
670 const check = exe.checkObject();670 const check = exe.checkObject();
671 check.checkInHeaders();671 check.checkInHeaders();
...@@ -910,7 +910,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {...@@ -910,7 +910,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
910 \\}910 \\}
911 ,911 ,
912 });912 });
913 lib.addObject(obj);913 lib.root_module.addObject(obj);
914914
915 const exe = addExecutable(b, opts, .{915 const exe = addExecutable(b, opts, .{
916 .name = "testlib",916 .name = "testlib",
...@@ -923,7 +923,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {...@@ -923,7 +923,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
923 \\}923 \\}
924 ,924 ,
925 });925 });
926 exe.linkLibrary(lib);926 exe.root_module.linkLibrary(lib);
927927
928 const run = addRunArtifact(exe);928 const run = addRunArtifact(exe);
929 run.expectStdErrEqual("0\n");929 run.expectStdErrEqual("0\n");
...@@ -1051,28 +1051,28 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {...@@ -1051,28 +1051,28 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
10511051
1052 {1052 {
1053 const exe = addExecutable(b, opts, .{ .name = "main1" });1053 const exe = addExecutable(b, opts, .{ .name = "main1" });
1054 exe.addObject(a_o);1054 exe.root_module.addObject(a_o);
1055 exe.addObject(b_o);1055 exe.root_module.addObject(b_o);
1056 exe.addObject(main_o);1056 exe.root_module.addObject(main_o);
1057 runWithChecks(test_step, exe);1057 runWithChecks(test_step, exe);
1058 }1058 }
10591059
1060 {1060 {
1061 const exe = addExecutable(b, opts, .{ .name = "main2" });1061 const exe = addExecutable(b, opts, .{ .name = "main2" });
1062 exe.addObject(b_o);1062 exe.root_module.addObject(b_o);
1063 exe.addObject(a_o);1063 exe.root_module.addObject(a_o);
1064 exe.addObject(main_o);1064 exe.root_module.addObject(main_o);
1065 runWithChecks(test_step, exe);1065 runWithChecks(test_step, exe);
1066 }1066 }
10671067
1068 {1068 {
1069 const c_o = addObject(b, opts, .{ .name = "c" });1069 const c_o = addObject(b, opts, .{ .name = "c" });
1070 c_o.addObject(a_o);1070 c_o.root_module.addObject(a_o);
1071 c_o.addObject(b_o);1071 c_o.root_module.addObject(b_o);
1072 c_o.addObject(main_o);1072 c_o.root_module.addObject(main_o);
10731073
1074 const exe = addExecutable(b, opts, .{ .name = "main3" });1074 const exe = addExecutable(b, opts, .{ .name = "main3" });
1075 exe.addObject(c_o);1075 exe.root_module.addObject(c_o);
1076 runWithChecks(test_step, exe);1076 runWithChecks(test_step, exe);
1077 }1077 }
10781078
...@@ -1167,28 +1167,28 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {...@@ -1167,28 +1167,28 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
11671167
1168 {1168 {
1169 const exe = addExecutable(b, opts, .{ .name = "main1" });1169 const exe = addExecutable(b, opts, .{ .name = "main1" });
1170 exe.addObject(a_o);1170 exe.root_module.addObject(a_o);
1171 exe.addObject(b_o);1171 exe.root_module.addObject(b_o);
1172 exe.addObject(main_o);1172 exe.root_module.addObject(main_o);
1173 runWithChecks(test_step, exe);1173 runWithChecks(test_step, exe);
1174 }1174 }
11751175
1176 {1176 {
1177 const exe = addExecutable(b, opts, .{ .name = "main2" });1177 const exe = addExecutable(b, opts, .{ .name = "main2" });
1178 exe.addObject(b_o);1178 exe.root_module.addObject(b_o);
1179 exe.addObject(a_o);1179 exe.root_module.addObject(a_o);
1180 exe.addObject(main_o);1180 exe.root_module.addObject(main_o);
1181 runWithChecks(test_step, exe);1181 runWithChecks(test_step, exe);
1182 }1182 }
11831183
1184 {1184 {
1185 const c_o = addObject(b, opts, .{ .name = "c" });1185 const c_o = addObject(b, opts, .{ .name = "c" });
1186 c_o.addObject(a_o);1186 c_o.root_module.addObject(a_o);
1187 c_o.addObject(b_o);1187 c_o.root_module.addObject(b_o);
1188 c_o.addObject(main_o);1188 c_o.root_module.addObject(main_o);
11891189
1190 const exe = addExecutable(b, opts, .{ .name = "main3" });1190 const exe = addExecutable(b, opts, .{ .name = "main3" });
1191 exe.addObject(c_o);1191 exe.root_module.addObject(c_o);
1192 runWithChecks(test_step, exe);1192 runWithChecks(test_step, exe);
1193 }1193 }
11941194
...@@ -1259,9 +1259,9 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {...@@ -1259,9 +1259,9 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
1259 });1259 });
12601260
1261 const exe = addExecutable(b, opts, .{ .name = "main1" });1261 const exe = addExecutable(b, opts, .{ .name = "main1" });
1262 exe.addObject(a_o);1262 exe.root_module.addObject(a_o);
1263 exe.addObject(b_o);1263 exe.root_module.addObject(b_o);
1264 exe.addObject(main_o);1264 exe.root_module.addObject(main_o);
12651265
1266 const check = exe.checkObject();1266 const check = exe.checkObject();
1267 check.dumpSection("__TEXT,__const");1267 check.dumpSection("__TEXT,__const");
...@@ -1335,17 +1335,17 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {...@@ -1335,17 +1335,17 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
13351335
1336 {1336 {
1337 const exe = addExecutable(b, opts, .{ .name = "main1" });1337 const exe = addExecutable(b, opts, .{ .name = "main1" });
1338 exe.addObject(a_o);1338 exe.root_module.addObject(a_o);
1339 exe.addObject(b_o);1339 exe.root_module.addObject(b_o);
1340 exe.addObject(main_o);1340 exe.root_module.addObject(main_o);
1341 runWithChecks(test_step, exe);1341 runWithChecks(test_step, exe);
1342 }1342 }
13431343
1344 {1344 {
1345 const exe = addExecutable(b, opts, .{ .name = "main2" });1345 const exe = addExecutable(b, opts, .{ .name = "main2" });
1346 exe.addObject(b_o);1346 exe.root_module.addObject(b_o);
1347 exe.addObject(a_o);1347 exe.root_module.addObject(a_o);
1348 exe.addObject(main_o);1348 exe.root_module.addObject(main_o);
1349 runWithChecks(test_step, exe);1349 runWithChecks(test_step, exe);
1350 }1350 }
13511351
...@@ -1414,27 +1414,27 @@ fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {...@@ -1414,27 +1414,27 @@ fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {
14141414
1415 {1415 {
1416 const exe = addExecutable(b, opts, .{ .name = "main1" });1416 const exe = addExecutable(b, opts, .{ .name = "main1" });
1417 exe.addObject(main_o);1417 exe.root_module.addObject(main_o);
1418 exe.addObject(a_o);1418 exe.root_module.addObject(a_o);
1419 exe.root_module.linkFramework("Foundation", .{});1419 exe.root_module.linkFramework("Foundation", .{});
1420 runWithChecks(test_step, exe);1420 runWithChecks(test_step, exe);
1421 }1421 }
14221422
1423 {1423 {
1424 const exe = addExecutable(b, opts, .{ .name = "main2" });1424 const exe = addExecutable(b, opts, .{ .name = "main2" });
1425 exe.addObject(a_o);1425 exe.root_module.addObject(a_o);
1426 exe.addObject(main_o);1426 exe.root_module.addObject(main_o);
1427 exe.root_module.linkFramework("Foundation", .{});1427 exe.root_module.linkFramework("Foundation", .{});
1428 runWithChecks(test_step, exe);1428 runWithChecks(test_step, exe);
1429 }1429 }
14301430
1431 {1431 {
1432 const b_o = addObject(b, opts, .{ .name = "b" });1432 const b_o = addObject(b, opts, .{ .name = "b" });
1433 b_o.addObject(a_o);1433 b_o.root_module.addObject(a_o);
1434 b_o.addObject(main_o);1434 b_o.root_module.addObject(main_o);
14351435
1436 const exe = addExecutable(b, opts, .{ .name = "main3" });1436 const exe = addExecutable(b, opts, .{ .name = "main3" });
1437 exe.addObject(b_o);1437 exe.root_module.addObject(b_o);
1438 exe.root_module.linkFramework("Foundation", .{});1438 exe.root_module.linkFramework("Foundation", .{});
1439 runWithChecks(test_step, exe);1439 runWithChecks(test_step, exe);
1440 }1440 }
...@@ -1610,7 +1610,7 @@ fn testObjcpp(b: *Build, opts: Options) *Step {...@@ -1610,7 +1610,7 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
1610 \\@end1610 \\@end
1611 });1611 });
1612 foo_o.root_module.addIncludePath(foo_h.dirname());1612 foo_o.root_module.addIncludePath(foo_h.dirname());
1613 foo_o.linkLibCpp();1613 foo_o.root_module.link_libcpp = true;
16141614
1615 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes = 1615 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes =
1616 \\#import "Foo.h"1616 \\#import "Foo.h"
...@@ -1628,8 +1628,8 @@ fn testObjcpp(b: *Build, opts: Options) *Step {...@@ -1628,8 +1628,8 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
1628 \\}1628 \\}
1629 });1629 });
1630 exe.root_module.addIncludePath(foo_h.dirname());1630 exe.root_module.addIncludePath(foo_h.dirname());
1631 exe.addObject(foo_o);1631 exe.root_module.addObject(foo_o);
1632 exe.linkLibCpp();1632 exe.root_module.link_libcpp = true;
1633 exe.root_module.linkFramework("Foundation", .{});1633 exe.root_module.linkFramework("Foundation", .{});
16341634
1635 const run = addRunArtifact(exe);1635 const run = addRunArtifact(exe);
...@@ -1693,7 +1693,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {...@@ -1693,7 +1693,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
1693 \\ return bar() - foo();1693 \\ return bar() - foo();
1694 \\}1694 \\}
1695 });1695 });
1696 exe.linkLibrary(lib);1696 exe.root_module.linkLibrary(lib);
16971697
1698 const run = addRunArtifact(exe);1698 const run = addRunArtifact(exe);
1699 run.expectExitCode(0);1699 run.expectExitCode(0);
...@@ -1711,7 +1711,7 @@ fn testRelocatable(b: *Build, opts: Options) *Step {...@@ -1711,7 +1711,7 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
1711 \\ throw std::runtime_error("Oh no!");1711 \\ throw std::runtime_error("Oh no!");
1712 \\}1712 \\}
1713 });1713 });
1714 a_o.linkLibCpp();1714 a_o.root_module.link_libcpp = true;
17151715
1716 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes = 1716 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
1717 \\extern int try_me();1717 \\extern int try_me();
...@@ -1733,19 +1733,19 @@ fn testRelocatable(b: *Build, opts: Options) *Step {...@@ -1733,19 +1733,19 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
1733 \\ return 0;1733 \\ return 0;
1734 \\}1734 \\}
1735 });1735 });
1736 main_o.linkLibCpp();1736 main_o.root_module.link_libcpp = true;
17371737
1738 const exp_stdout = "exception=Oh no!";1738 const exp_stdout = "exception=Oh no!";
17391739
1740 {1740 {
1741 const c_o = addObject(b, opts, .{ .name = "c" });1741 const c_o = addObject(b, opts, .{ .name = "c" });
1742 c_o.addObject(a_o);1742 c_o.root_module.addObject(a_o);
1743 c_o.addObject(b_o);1743 c_o.root_module.addObject(b_o);
17441744
1745 const exe = addExecutable(b, opts, .{ .name = "main1" });1745 const exe = addExecutable(b, opts, .{ .name = "main1" });
1746 exe.addObject(main_o);1746 exe.root_module.addObject(main_o);
1747 exe.addObject(c_o);1747 exe.root_module.addObject(c_o);
1748 exe.linkLibCpp();1748 exe.root_module.link_libcpp = true;
17491749
1750 const run = addRunArtifact(exe);1750 const run = addRunArtifact(exe);
1751 run.expectStdOutEqual(exp_stdout);1751 run.expectStdOutEqual(exp_stdout);
...@@ -1754,13 +1754,13 @@ fn testRelocatable(b: *Build, opts: Options) *Step {...@@ -1754,13 +1754,13 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17541754
1755 {1755 {
1756 const d_o = addObject(b, opts, .{ .name = "d" });1756 const d_o = addObject(b, opts, .{ .name = "d" });
1757 d_o.addObject(a_o);1757 d_o.root_module.addObject(a_o);
1758 d_o.addObject(b_o);1758 d_o.root_module.addObject(b_o);
1759 d_o.addObject(main_o);1759 d_o.root_module.addObject(main_o);
17601760
1761 const exe = addExecutable(b, opts, .{ .name = "main2" });1761 const exe = addExecutable(b, opts, .{ .name = "main2" });
1762 exe.addObject(d_o);1762 exe.root_module.addObject(d_o);
1763 exe.linkLibCpp();1763 exe.root_module.link_libcpp = true;
17641764
1765 const run = addRunArtifact(exe);1765 const run = addRunArtifact(exe);
1766 run.expectStdOutEqual(exp_stdout);1766 run.expectStdOutEqual(exp_stdout);
...@@ -1805,12 +1805,12 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {...@@ -1805,12 +1805,12 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
1805 });1805 });
18061806
1807 const c_o = addObject(b, opts, .{ .name = "c" });1807 const c_o = addObject(b, opts, .{ .name = "c" });
1808 c_o.addObject(a_o);1808 c_o.root_module.addObject(a_o);
1809 c_o.addObject(b_o);1809 c_o.root_module.addObject(b_o);
1810 c_o.addObject(main_o);1810 c_o.root_module.addObject(main_o);
18111811
1812 const exe = addExecutable(b, opts, .{ .name = "main" });1812 const exe = addExecutable(b, opts, .{ .name = "main" });
1813 exe.addObject(c_o);1813 exe.root_module.addObject(c_o);
18141814
1815 const run = addRunArtifact(exe);1815 const run = addRunArtifact(exe);
1816 run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") });1816 run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") });
...@@ -1833,10 +1833,10 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {...@@ -1833,10 +1833,10 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
1833 });1833 });
18341834
1835 const liba = addStaticLibrary(b, opts, .{ .name = "a" });1835 const liba = addStaticLibrary(b, opts, .{ .name = "a" });
1836 liba.addObject(obj);1836 liba.root_module.addObject(obj);
18371837
1838 const dylib = addSharedLibrary(b, opts, .{ .name = "a" });1838 const dylib = addSharedLibrary(b, opts, .{ .name = "a" });
1839 dylib.addObject(obj);1839 dylib.root_module.addObject(obj);
18401840
1841 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = 1841 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1842 \\#include<stdio.h>1842 \\#include<stdio.h>
...@@ -1850,7 +1850,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {...@@ -1850,7 +1850,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18501850
1851 {1851 {
1852 const exe = addExecutable(b, opts, .{ .name = "main" });1852 const exe = addExecutable(b, opts, .{ .name = "main" });
1853 exe.addObject(main_o);1853 exe.root_module.addObject(main_o);
1854 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .mode_first });1854 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .mode_first });
1855 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());1855 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
1856 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());1856 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
...@@ -1869,7 +1869,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {...@@ -1869,7 +1869,7 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18691869
1870 {1870 {
1871 const exe = addExecutable(b, opts, .{ .name = "main" });1871 const exe = addExecutable(b, opts, .{ .name = "main" });
1872 exe.addObject(main_o);1872 exe.root_module.addObject(main_o);
1873 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .paths_first });1873 exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .paths_first });
1874 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());1874 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
1875 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());1875 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
...@@ -1924,9 +1924,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {...@@ -1924,9 +1924,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {
1924 });1924 });
19251925
1926 const exe = addExecutable(b, opts, .{ .name = "test" });1926 const exe = addExecutable(b, opts, .{ .name = "test" });
1927 exe.addObject(obj1);1927 exe.root_module.addObject(obj1);
1928 exe.addObject(obj2);1928 exe.root_module.addObject(obj2);
1929 exe.addObject(main_o);1929 exe.root_module.addObject(main_o);
19301930
1931 const run = b.addRunArtifact(exe);1931 const run = b.addRunArtifact(exe);
1932 run.skip_foreign_checks = true;1932 run.skip_foreign_checks = true;
...@@ -1951,9 +1951,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {...@@ -1951,9 +1951,9 @@ fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step {
1951 });1951 });
19521952
1953 const exe = addExecutable(b, opts, .{ .name = "test" });1953 const exe = addExecutable(b, opts, .{ .name = "test" });
1954 exe.addObject(obj1);1954 exe.root_module.addObject(obj1);
1955 exe.addObject(obj3);1955 exe.root_module.addObject(obj3);
1956 exe.addObject(main_o);1956 exe.root_module.addObject(main_o);
19571957
1958 const run = b.addRunArtifact(exe);1958 const run = b.addRunArtifact(exe);
1959 run.skip_foreign_checks = true;1959 run.skip_foreign_checks = true;
...@@ -2031,9 +2031,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {...@@ -2031,9 +2031,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
2031 });2031 });
20322032
2033 const exe = addExecutable(b, opts, .{ .name = "main" });2033 const exe = addExecutable(b, opts, .{ .name = "main" });
2034 exe.addObject(obj1);2034 exe.root_module.addObject(obj1);
2035 exe.addObject(obj2);2035 exe.root_module.addObject(obj2);
2036 exe.addObject(main_o);2036 exe.root_module.addObject(main_o);
20372037
2038 const run = addRunArtifact(exe);2038 const run = addRunArtifact(exe);
2039 run.expectStdOutEqual("All your codebase are belong to us.\n");2039 run.expectStdOutEqual("All your codebase are belong to us.\n");
...@@ -2054,9 +2054,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {...@@ -2054,9 +2054,9 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
2054 });2054 });
20552055
2056 const exe = addExecutable(b, opts, .{ .name = "main2" });2056 const exe = addExecutable(b, opts, .{ .name = "main2" });
2057 exe.addObject(obj1);2057 exe.root_module.addObject(obj1);
2058 exe.addObject(obj2);2058 exe.root_module.addObject(obj2);
2059 exe.addObject(main_o);2059 exe.root_module.addObject(main_o);
20602060
2061 const check = exe.checkObject();2061 const check = exe.checkObject();
2062 check.checkInHeaders();2062 check.checkInHeaders();
...@@ -2102,9 +2102,9 @@ fn testSymbolStabs(b: *Build, opts: Options) *Step {...@@ -2102,9 +2102,9 @@ fn testSymbolStabs(b: *Build, opts: Options) *Step {
2102 });2102 });
21032103
2104 const exe = addExecutable(b, opts, .{ .name = "main" });2104 const exe = addExecutable(b, opts, .{ .name = "main" });
2105 exe.addObject(a_o);2105 exe.root_module.addObject(a_o);
2106 exe.addObject(b_o);2106 exe.root_module.addObject(b_o);
2107 exe.addObject(main_o);2107 exe.root_module.addObject(main_o);
21082108
2109 const run = addRunArtifact(exe);2109 const run = addRunArtifact(exe);
2110 run.expectStdOutEqual("foo=42,bar=24");2110 run.expectStdOutEqual("foo=42,bar=24");
...@@ -2299,7 +2299,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {...@@ -2299,7 +2299,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
2299 \\}2299 \\}
2300 });2300 });
2301 bar_o.root_module.addIncludePath(foo_h.dirname());2301 bar_o.root_module.addIncludePath(foo_h.dirname());
2302 bar_o.linkLibCpp();2302 bar_o.root_module.link_libcpp = true;
23032303
2304 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes = 2304 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes =
2305 \\#include "foo.h"2305 \\#include "foo.h"
...@@ -2309,7 +2309,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {...@@ -2309,7 +2309,7 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
2309 \\}2309 \\}
2310 });2310 });
2311 baz_o.root_module.addIncludePath(foo_h.dirname());2311 baz_o.root_module.addIncludePath(foo_h.dirname());
2312 baz_o.linkLibCpp();2312 baz_o.root_module.link_libcpp = true;
23132313
2314 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes = 2314 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
2315 \\extern int bar();2315 \\extern int bar();
...@@ -2321,13 +2321,13 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {...@@ -2321,13 +2321,13 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
2321 \\}2321 \\}
2322 });2322 });
2323 main_o.root_module.addIncludePath(foo_h.dirname());2323 main_o.root_module.addIncludePath(foo_h.dirname());
2324 main_o.linkLibCpp();2324 main_o.root_module.link_libcpp = true;
23252325
2326 const exe = addExecutable(b, opts, .{ .name = "main" });2326 const exe = addExecutable(b, opts, .{ .name = "main" });
2327 exe.addObject(bar_o);2327 exe.root_module.addObject(bar_o);
2328 exe.addObject(baz_o);2328 exe.root_module.addObject(baz_o);
2329 exe.addObject(main_o);2329 exe.root_module.addObject(main_o);
2330 exe.linkLibCpp();2330 exe.root_module.link_libcpp = true;
23312331
2332 const run = addRunArtifact(exe);2332 const run = addRunArtifact(exe);
2333 run.expectExitCode(0);2333 run.expectExitCode(0);
...@@ -2445,7 +2445,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {...@@ -2445,7 +2445,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24452445
2446 {2446 {
2447 const exe = addExecutable(b, opts, .{ .name = "main1" });2447 const exe = addExecutable(b, opts, .{ .name = "main1" });
2448 exe.addObject(main_o);2448 exe.root_module.addObject(main_o);
2449 exe.root_module.linkSystemLibrary("a", .{});2449 exe.root_module.linkSystemLibrary("a", .{});
2450 exe.root_module.linkSystemLibrary("b", .{});2450 exe.root_module.linkSystemLibrary("b", .{});
2451 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());2451 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
...@@ -2474,7 +2474,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {...@@ -2474,7 +2474,7 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24742474
2475 {2475 {
2476 const exe = addExecutable(b, opts, .{ .name = "main2" });2476 const exe = addExecutable(b, opts, .{ .name = "main2" });
2477 exe.addObject(main_o);2477 exe.root_module.addObject(main_o);
2478 exe.root_module.linkSystemLibrary("b", .{});2478 exe.root_module.linkSystemLibrary("b", .{});
2479 exe.root_module.linkSystemLibrary("a", .{});2479 exe.root_module.linkSystemLibrary("a", .{});
2480 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());2480 exe.root_module.addLibraryPath(liba.getEmittedBinDirectory());
...@@ -2510,14 +2510,14 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {...@@ -2510,14 +2510,14 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {
2510 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "static int foo = 42;" });2510 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "static int foo = 42;" });
25112511
2512 const lib = addStaticLibrary(b, opts, .{ .name = "a" });2512 const lib = addStaticLibrary(b, opts, .{ .name = "a" });
2513 lib.addObject(obj);2513 lib.root_module.addObject(obj);
25142514
2515 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });2515 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
25162516
2517 {2517 {
2518 const exe = addExecutable(b, opts, .{ .name = "main3" });2518 const exe = addExecutable(b, opts, .{ .name = "main3" });
2519 exe.addObject(main_o);2519 exe.root_module.addObject(main_o);
2520 exe.addObject(obj);2520 exe.root_module.addObject(obj);
2521 exe.discard_local_symbols = true;2521 exe.discard_local_symbols = true;
25222522
2523 const run = addRunArtifact(exe);2523 const run = addRunArtifact(exe);
...@@ -2532,8 +2532,8 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {...@@ -2532,8 +2532,8 @@ fn testDiscardLocalSymbols(b: *Build, opts: Options) *Step {
25322532
2533 {2533 {
2534 const exe = addExecutable(b, opts, .{ .name = "main4" });2534 const exe = addExecutable(b, opts, .{ .name = "main4" });
2535 exe.addObject(main_o);2535 exe.root_module.addObject(main_o);
2536 exe.linkLibrary(lib);2536 exe.root_module.linkLibrary(lib);
2537 exe.discard_local_symbols = true;2537 exe.discard_local_symbols = true;
25382538
2539 const run = addRunArtifact(exe);2539 const run = addRunArtifact(exe);
...@@ -2555,14 +2555,14 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {...@@ -2555,14 +2555,14 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
2555 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "int foo = 42;" });2555 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = "int foo = 42;" });
25562556
2557 const lib = addStaticLibrary(b, opts, .{ .name = "a" });2557 const lib = addStaticLibrary(b, opts, .{ .name = "a" });
2558 lib.addObject(obj);2558 lib.root_module.addObject(obj);
25592559
2560 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });2560 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
25612561
2562 {2562 {
2563 const exe = addExecutable(b, opts, .{ .name = "main1" });2563 const exe = addExecutable(b, opts, .{ .name = "main1" });
2564 exe.addObject(main_o);2564 exe.root_module.addObject(main_o);
2565 exe.linkLibrary(lib);2565 exe.root_module.linkLibrary(lib);
2566 exe.forceUndefinedSymbol("_foo");2566 exe.forceUndefinedSymbol("_foo");
25672567
2568 const run = addRunArtifact(exe);2568 const run = addRunArtifact(exe);
...@@ -2577,8 +2577,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {...@@ -2577,8 +2577,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
25772577
2578 {2578 {
2579 const exe = addExecutable(b, opts, .{ .name = "main2" });2579 const exe = addExecutable(b, opts, .{ .name = "main2" });
2580 exe.addObject(main_o);2580 exe.root_module.addObject(main_o);
2581 exe.linkLibrary(lib);2581 exe.root_module.linkLibrary(lib);
2582 exe.forceUndefinedSymbol("_foo");2582 exe.forceUndefinedSymbol("_foo");
2583 exe.link_gc_sections = true;2583 exe.link_gc_sections = true;
25842584
...@@ -2594,8 +2594,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {...@@ -2594,8 +2594,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
25942594
2595 {2595 {
2596 const exe = addExecutable(b, opts, .{ .name = "main3" });2596 const exe = addExecutable(b, opts, .{ .name = "main3" });
2597 exe.addObject(main_o);2597 exe.root_module.addObject(main_o);
2598 exe.addObject(obj);2598 exe.root_module.addObject(obj);
25992599
2600 const run = addRunArtifact(exe);2600 const run = addRunArtifact(exe);
2601 run.expectExitCode(0);2601 run.expectExitCode(0);
...@@ -2609,8 +2609,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {...@@ -2609,8 +2609,8 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
26092609
2610 {2610 {
2611 const exe = addExecutable(b, opts, .{ .name = "main4" });2611 const exe = addExecutable(b, opts, .{ .name = "main4" });
2612 exe.addObject(main_o);2612 exe.root_module.addObject(main_o);
2613 exe.addObject(obj);2613 exe.root_module.addObject(obj);
2614 exe.link_gc_sections = true;2614 exe.link_gc_sections = true;
26152615
2616 const run = addRunArtifact(exe);2616 const run = addRunArtifact(exe);
...@@ -2642,7 +2642,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {...@@ -2642,7 +2642,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
2642 \\ std.debug.print("foo() + bar() = {d}", .{foo() + bar()});2642 \\ std.debug.print("foo() + bar() = {d}", .{foo() + bar()});
2643 \\}2643 \\}
2644 });2644 });
2645 exe.addObject(obj);2645 exe.root_module.addObject(obj);
26462646
2647 // TODO order should match across backends if possible2647 // TODO order should match across backends if possible
2648 if (opts.use_llvm) {2648 if (opts.use_llvm) {
...@@ -2764,7 +2764,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {...@@ -2764,7 +2764,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
2764 \\}2764 \\}
2765 });2765 });
2766 main_o.root_module.addIncludePath(all_h.dirname());2766 main_o.root_module.addIncludePath(all_h.dirname());
2767 main_o.linkLibCpp();2767 main_o.root_module.link_libcpp = true;
27682768
2769 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes = 2769 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes =
2770 \\#include "all.h"2770 \\#include "all.h"
...@@ -2799,7 +2799,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {...@@ -2799,7 +2799,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
2799 \\}2799 \\}
2800 });2800 });
2801 simple_string_o.root_module.addIncludePath(all_h.dirname());2801 simple_string_o.root_module.addIncludePath(all_h.dirname());
2802 simple_string_o.linkLibCpp();2802 simple_string_o.root_module.link_libcpp = true;
28032803
2804 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes = 2804 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes =
2805 \\#include "all.h"2805 \\#include "all.h"
...@@ -2816,7 +2816,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {...@@ -2816,7 +2816,7 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
2816 \\}2816 \\}
2817 });2817 });
2818 simple_string_owner_o.root_module.addIncludePath(all_h.dirname());2818 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
2821 const exp_stdout =2821 const exp_stdout =
2822 \\Constructed: a2822 \\Constructed: a
...@@ -2828,10 +2828,10 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {...@@ -2828,10 +2828,10 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
2828 ;2828 ;
28292829
2830 const exe = addExecutable(b, opts, .{ .name = "main" });2830 const exe = addExecutable(b, opts, .{ .name = "main" });
2831 exe.addObject(main_o);2831 exe.root_module.addObject(main_o);
2832 exe.addObject(simple_string_o);2832 exe.root_module.addObject(simple_string_o);
2833 exe.addObject(simple_string_owner_o);2833 exe.root_module.addObject(simple_string_owner_o);
2834 exe.linkLibCpp();2834 exe.root_module.link_libcpp = true;
28352835
2836 const run = addRunArtifact(exe);2836 const run = addRunArtifact(exe);
2837 run.expectStdOutEqual(exp_stdout);2837 run.expectStdOutEqual(exp_stdout);
...@@ -2896,7 +2896,7 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {...@@ -2896,7 +2896,7 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
2896 \\ return 0;2896 \\ return 0;
2897 \\}2897 \\}
2898 });2898 });
2899 exe.addObject(a_o);2899 exe.root_module.addObject(a_o);
29002900
2901 const run = addRunArtifact(exe);2901 const run = addRunArtifact(exe);
2902 run.expectStdOutEqual("4\n");2902 run.expectStdOutEqual("4\n");
...@@ -2948,7 +2948,7 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {...@@ -2948,7 +2948,7 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
2948 \\ return 0;2948 \\ return 0;
2949 \\}2949 \\}
2950 });2950 });
2951 exe.addObject(a_o);2951 exe.root_module.addObject(a_o);
29522952
2953 const run = addRunArtifact(exe);2953 const run = addRunArtifact(exe);
2954 run.expectStdOutEqual("4\n");2954 run.expectStdOutEqual("4\n");
...@@ -3052,7 +3052,7 @@ fn testWeakBind(b: *Build, opts: Options) *Step {...@@ -3052,7 +3052,7 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
3052 \\ .quad 03052 \\ .quad 0
3053 \\ .quad _weak_internal_tlv$tlv$init3053 \\ .quad _weak_internal_tlv$tlv$init
3054 });3054 });
3055 exe.linkLibrary(lib);3055 exe.root_module.linkLibrary(lib);
30563056
3057 {3057 {
3058 const check = exe.checkObject();3058 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...@@ -16,7 +16,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
16 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi }),16 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi }),
17 }),17 }),
18 });18 });
19 exe.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });19 exe.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
20 exe.use_llvm = false;20 exe.use_llvm = false;
21 exe.use_lld = false;21 exe.use_lld = false;
2222
test/src/Cases.zig+1-1
...@@ -560,7 +560,7 @@ pub fn lowerToTranslateCSteps(...@@ -560,7 +560,7 @@ pub fn lowerToTranslateCSteps(
560 .root_module = translate_c.createModule(),560 .root_module = translate_c.createModule(),
561 });561 });
562 run_exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});562 run_exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
563 run_exe.linkLibC();563 run_exe.root_module.link_libc = true;
564 const run = b.addRunArtifact(run_exe);564 const run = b.addRunArtifact(run_exe);
565 run.step.name = b.fmt("{s} run", .{annotated_case_name});565 run.step.name = b.fmt("{s} run", .{annotated_case_name});
566 run.expectStdOutEqual(output);566 run.expectStdOutEqual(output);
test/src/RunTranslatedC.zig+1-1
...@@ -89,7 +89,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {...@@ -89,7 +89,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
89 .root_module = translate_c.createModule(),89 .root_module = translate_c.createModule(),
90 });90 });
91 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});91 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
92 exe.linkLibC();92 exe.root_module.link_libc = true;
93 const run = b.addRunArtifact(exe);93 const run = b.addRunArtifact(exe);
94 run.step.name = b.fmt("{s} run", .{annotated_case_name});94 run.step.name = b.fmt("{s} run", .{annotated_case_name});
95 if (!case.allow_warnings) {95 if (!case.allow_warnings) {
test/standalone/c_embed_path/build.zig+3-3
...@@ -13,12 +13,12 @@ pub fn build(b: *std.Build) void {...@@ -13,12 +13,12 @@ pub fn build(b: *std.Build) void {
13 .optimize = optimize,13 .optimize = optimize,
14 }),14 }),
15 });15 });
16 exe.addCSourceFile(.{16 exe.root_module.addCSourceFile(.{
17 .file = b.path("test.c"),17 .file = b.path("test.c"),
18 .flags = &.{"-std=c23"},18 .flags = &.{"-std=c23"},
19 });19 });
20 exe.linkLibC();20 exe.root_module.link_libc = true;
21 exe.addEmbedPath(b.path("data"));21 exe.root_module.addEmbedPath(b.path("data"));
2222
23 const run_c_cmd = b.addRunArtifact(exe);23 const run_c_cmd = b.addRunArtifact(exe);
24 run_c_cmd.expectExitCode(0);24 run_c_cmd.expectExitCode(0);
test/standalone/extern/build.zig+2-2
...@@ -31,8 +31,8 @@ pub fn build(b: *std.Build) void {...@@ -31,8 +31,8 @@ pub fn build(b: *std.Build) void {
31 .target = b.graph.host,31 .target = b.graph.host,
32 .optimize = optimize,32 .optimize = optimize,
33 }) });33 }) });
34 test_exe.addObject(obj);34 test_exe.root_module.addObject(obj);
35 test_exe.linkLibrary(shared);35 test_exe.root_module.linkLibrary(shared);
3636
37 test_step.dependOn(&b.addRunArtifact(test_exe).step);37 test_step.dependOn(&b.addRunArtifact(test_exe).step);
38}38}
test/standalone/issue_794/build.zig+1-1
...@@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {...@@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {
8 .root_source_file = b.path("main.zig"),8 .root_source_file = b.path("main.zig"),
9 .target = b.graph.host,9 .target = b.graph.host,
10 }) });10 }) });
11 test_artifact.addIncludePath(b.path("a_directory"));11 test_artifact.root_module.addIncludePath(b.path("a_directory"));
1212
13 // TODO: actually check the output13 // TODO: actually check the output
14 _ = test_artifact.getEmittedBin();14 _ = test_artifact.getEmittedBin();
test/standalone/stack_iterator/build.zig+1-1
...@@ -109,7 +109,7 @@ pub fn build(b: *std.Build) void {...@@ -109,7 +109,7 @@ pub fn build(b: *std.Build) void {
109 // .use_llvm = true,109 // .use_llvm = true,
110 // });110 // });
111111
112 // exe.linkLibrary(c_shared_lib);112 // exe.root_module.linkLibrary(c_shared_lib);
113113
114 // const run_cmd = b.addRunArtifact(exe);114 // const run_cmd = b.addRunArtifact(exe);
115 // test_step.dependOn(&run_cmd.step);115 // test_step.dependOn(&run_cmd.step);
test/tests.zig+2-2
...@@ -2371,10 +2371,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -2371,10 +2371,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
2371 } else "";2371 } else "";
2372 const use_pic = if (test_target.pic == true) "-pic" else "";2372 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
2376 if (target.os.tag == .windows) {2376 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, .{});
2378 }2378 }
23792379
2380 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{2380 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{