| ... | ... | @@ -210,8 +210,8 @@ fn testAbsSymbols(b: *Build, opts: Options) *Step { |
| 210 | 210 | \\} |
| 211 | 211 | , |
| 212 | 212 | }); |
| 213 | | exe.addObject(obj); |
| 214 | | exe.linkLibC(); |
| 213 | exe.root_module.addObject(obj); |
| 214 | exe.root_module.link_libc = true; |
| 215 | 215 | |
| 216 | 216 | const run = addRunArtifact(exe); |
| 217 | 217 | run.expectExitCode(0); |
| ... | ... | @@ -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; |
| 239 | 239 | |
| 240 | 240 | const libfoo = addSharedLibrary(b, opts, .{ .name = "foo" }); |
| 241 | 241 | addCSourceBytes(libfoo, "int foo() { return 42; }", &.{}); |
| ... | ... | @@ -253,17 +253,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step { |
| 253 | 253 | const exe = addExecutable(b, opts, .{ |
| 254 | 254 | .name = "test", |
| 255 | 255 | }); |
| 256 | | exe.addObject(main_o); |
| 257 | | exe.linkSystemLibrary2("foo", .{ .needed = true }); |
| 258 | | exe.addLibraryPath(libfoo.getEmittedBinDirectory()); |
| 259 | | exe.addRPath(libfoo.getEmittedBinDirectory()); |
| 260 | | exe.linkSystemLibrary2("bar", .{ .needed = true }); |
| 261 | | exe.addLibraryPath(libbar.getEmittedBinDirectory()); |
| 262 | | exe.addRPath(libbar.getEmittedBinDirectory()); |
| 263 | | exe.linkSystemLibrary2("baz", .{ .needed = true }); |
| 264 | | exe.addLibraryPath(libbaz.getEmittedBinDirectory()); |
| 265 | | exe.addRPath(libbaz.getEmittedBinDirectory()); |
| 266 | | exe.linkLibC(); |
| 256 | exe.root_module.addObject(main_o); |
| 257 | exe.root_module.linkSystemLibrary("foo", .{ .needed = true }); |
| 258 | exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory()); |
| 259 | exe.root_module.addRPath(libfoo.getEmittedBinDirectory()); |
| 260 | exe.root_module.linkSystemLibrary("bar", .{ .needed = true }); |
| 261 | exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory()); |
| 262 | exe.root_module.addRPath(libbar.getEmittedBinDirectory()); |
| 263 | exe.root_module.linkSystemLibrary("baz", .{ .needed = true }); |
| 264 | exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory()); |
| 265 | exe.root_module.addRPath(libbaz.getEmittedBinDirectory()); |
| 266 | exe.root_module.link_libc = true; |
| 267 | 267 | |
| 268 | 268 | const run = addRunArtifact(exe); |
| 269 | 269 | run.expectStdOutEqual("42\n"); |
| ... | ... | @@ -281,17 +281,17 @@ fn testAsNeeded(b: *Build, opts: Options) *Step { |
| 281 | 281 | const exe = addExecutable(b, opts, .{ |
| 282 | 282 | .name = "test", |
| 283 | 283 | }); |
| 284 | | exe.addObject(main_o); |
| 285 | | exe.linkSystemLibrary2("foo", .{ .needed = false }); |
| 286 | | exe.addLibraryPath(libfoo.getEmittedBinDirectory()); |
| 287 | | exe.addRPath(libfoo.getEmittedBinDirectory()); |
| 288 | | exe.linkSystemLibrary2("bar", .{ .needed = false }); |
| 289 | | exe.addLibraryPath(libbar.getEmittedBinDirectory()); |
| 290 | | exe.addRPath(libbar.getEmittedBinDirectory()); |
| 291 | | exe.linkSystemLibrary2("baz", .{ .needed = false }); |
| 292 | | exe.addLibraryPath(libbaz.getEmittedBinDirectory()); |
| 293 | | exe.addRPath(libbaz.getEmittedBinDirectory()); |
| 294 | | exe.linkLibC(); |
| 284 | exe.root_module.addObject(main_o); |
| 285 | exe.root_module.linkSystemLibrary("foo", .{ .needed = false }); |
| 286 | exe.root_module.addLibraryPath(libfoo.getEmittedBinDirectory()); |
| 287 | exe.root_module.addRPath(libfoo.getEmittedBinDirectory()); |
| 288 | exe.root_module.linkSystemLibrary("bar", .{ .needed = false }); |
| 289 | exe.root_module.addLibraryPath(libbar.getEmittedBinDirectory()); |
| 290 | exe.root_module.addRPath(libbar.getEmittedBinDirectory()); |
| 291 | exe.root_module.linkSystemLibrary("baz", .{ .needed = false }); |
| 292 | exe.root_module.addLibraryPath(libbaz.getEmittedBinDirectory()); |
| 293 | exe.root_module.addRPath(libbaz.getEmittedBinDirectory()); |
| 294 | exe.root_module.link_libc = true; |
| 295 | 295 | |
| 296 | 296 | const run = addRunArtifact(exe); |
| 297 | 297 | run.expectStdOutEqual("42\n"); |
| ... | ... | @@ -351,15 +351,15 @@ fn testCanonicalPlt(b: *Build, opts: Options) *Step { |
| 351 | 351 | , |
| 352 | 352 | .pic = false, |
| 353 | 353 | }); |
| 354 | | main_o.linkLibC(); |
| 354 | main_o.root_module.link_libc = true; |
| 355 | 355 | |
| 356 | 356 | const exe = addExecutable(b, opts, .{ |
| 357 | 357 | .name = "main", |
| 358 | 358 | }); |
| 359 | | exe.addObject(main_o); |
| 360 | | exe.addObject(b_o); |
| 361 | | exe.linkLibrary(dso); |
| 362 | | exe.linkLibC(); |
| 359 | exe.root_module.addObject(main_o); |
| 360 | exe.root_module.addObject(b_o); |
| 361 | exe.root_module.linkLibrary(dso); |
| 362 | exe.root_module.link_libc = true; |
| 363 | 363 | exe.pie = false; |
| 364 | 364 | |
| 365 | 365 | const run = addRunArtifact(exe); |
| ... | ... | @@ -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; |
| 388 | 388 | |
| 389 | 389 | const main_o = addObject(b, opts, .{ |
| 390 | 390 | .name = "main", |
| ... | ... | @@ -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; |
| 405 | 405 | |
| 406 | 406 | { |
| 407 | 407 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 408 | | exe.addObject(a_o); |
| 409 | | exe.addObject(main_o); |
| 410 | | exe.linkLibCpp(); |
| 408 | exe.root_module.addObject(a_o); |
| 409 | exe.root_module.addObject(main_o); |
| 410 | exe.root_module.link_libcpp = true; |
| 411 | 411 | |
| 412 | 412 | const run = addRunArtifact(exe); |
| 413 | 413 | run.expectStdOutEqual( |
| ... | ... | @@ -420,9 +420,9 @@ fn testComdatElimination(b: *Build, opts: Options) *Step { |
| 420 | 420 | |
| 421 | 421 | { |
| 422 | 422 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 423 | | exe.addObject(main_o); |
| 424 | | exe.addObject(a_o); |
| 425 | | exe.linkLibCpp(); |
| 423 | exe.root_module.addObject(main_o); |
| 424 | exe.root_module.addObject(a_o); |
| 425 | exe.root_module.link_libcpp = true; |
| 426 | 426 | |
| 427 | 427 | const run = addRunArtifact(exe); |
| 428 | 428 | run.expectStdOutEqual( |
| ... | ... | @@ -435,12 +435,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step { |
| 435 | 435 | |
| 436 | 436 | { |
| 437 | 437 | const c_o = addObject(b, opts, .{ .name = "c" }); |
| 438 | | c_o.addObject(main_o); |
| 439 | | c_o.addObject(a_o); |
| 438 | c_o.root_module.addObject(main_o); |
| 439 | c_o.root_module.addObject(a_o); |
| 440 | 440 | |
| 441 | 441 | const exe = addExecutable(b, opts, .{ .name = "main3" }); |
| 442 | | exe.addObject(c_o); |
| 443 | | exe.linkLibCpp(); |
| 442 | exe.root_module.addObject(c_o); |
| 443 | exe.root_module.link_libcpp = true; |
| 444 | 444 | |
| 445 | 445 | const run = addRunArtifact(exe); |
| 446 | 446 | run.expectStdOutEqual( |
| ... | ... | @@ -453,12 +453,12 @@ fn testComdatElimination(b: *Build, opts: Options) *Step { |
| 453 | 453 | |
| 454 | 454 | { |
| 455 | 455 | const d_o = addObject(b, opts, .{ .name = "d" }); |
| 456 | | d_o.addObject(a_o); |
| 457 | | d_o.addObject(main_o); |
| 456 | d_o.root_module.addObject(a_o); |
| 457 | d_o.root_module.addObject(main_o); |
| 458 | 458 | |
| 459 | 459 | const exe = addExecutable(b, opts, .{ .name = "main4" }); |
| 460 | | exe.addObject(d_o); |
| 461 | | exe.linkLibCpp(); |
| 460 | exe.root_module.addObject(d_o); |
| 461 | exe.root_module.link_libcpp = true; |
| 462 | 462 | |
| 463 | 463 | const run = addRunArtifact(exe); |
| 464 | 464 | run.expectStdOutEqual( |
| ... | ... | @@ -522,7 +522,7 @@ fn testCommonSymbols(b: *Build, opts: Options) *Step { |
| 522 | 522 | \\ printf("%d %d %d\n", foo, bar, baz); |
| 523 | 523 | \\} |
| 524 | 524 | , &.{"-fcommon"}); |
| 525 | | exe.linkLibC(); |
| 525 | exe.root_module.link_libc = true; |
| 526 | 526 | |
| 527 | 527 | const run = addRunArtifact(exe); |
| 528 | 528 | run.expectStdOutEqual("0 5 42\n"); |
| ... | ... | @@ -549,7 +549,7 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step { |
| 549 | 549 | , |
| 550 | 550 | .c_source_flags = &.{"-fcommon"}, |
| 551 | 551 | }); |
| 552 | | a_o.linkLibC(); |
| 552 | a_o.root_module.link_libc = true; |
| 553 | 553 | |
| 554 | 554 | const b_o = addObject(b, opts, .{ |
| 555 | 555 | .name = "b", |
| ... | ... | @@ -575,16 +575,16 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step { |
| 575 | 575 | }); |
| 576 | 576 | |
| 577 | 577 | const lib = addStaticLibrary(b, opts, .{ .name = "lib" }); |
| 578 | | lib.addObject(b_o); |
| 579 | | lib.addObject(c_o); |
| 580 | | lib.addObject(d_o); |
| 578 | lib.root_module.addObject(b_o); |
| 579 | lib.root_module.addObject(c_o); |
| 580 | lib.root_module.addObject(d_o); |
| 581 | 581 | |
| 582 | 582 | const exe = addExecutable(b, opts, .{ |
| 583 | 583 | .name = "test", |
| 584 | 584 | }); |
| 585 | | exe.addObject(a_o); |
| 586 | | exe.linkLibrary(lib); |
| 587 | | exe.linkLibC(); |
| 585 | exe.root_module.addObject(a_o); |
| 586 | exe.root_module.linkLibrary(lib); |
| 587 | exe.root_module.link_libc = true; |
| 588 | 588 | |
| 589 | 589 | const run = addRunArtifact(exe); |
| 590 | 590 | run.expectStdOutEqual("5 0 0 -1\n"); |
| ... | ... | @@ -603,15 +603,15 @@ fn testCommonSymbolsInArchive(b: *Build, opts: Options) *Step { |
| 603 | 603 | }); |
| 604 | 604 | |
| 605 | 605 | const lib = addStaticLibrary(b, opts, .{ .name = "lib" }); |
| 606 | | lib.addObject(b_o); |
| 607 | | lib.addObject(e_o); |
| 606 | lib.root_module.addObject(b_o); |
| 607 | lib.root_module.addObject(e_o); |
| 608 | 608 | |
| 609 | 609 | const exe = addExecutable(b, opts, .{ |
| 610 | 610 | .name = "test", |
| 611 | 611 | }); |
| 612 | | exe.addObject(a_o); |
| 613 | | exe.linkLibrary(lib); |
| 614 | | exe.linkLibC(); |
| 612 | exe.root_module.addObject(a_o); |
| 613 | exe.root_module.linkLibrary(lib); |
| 614 | exe.root_module.link_libc = true; |
| 615 | 615 | |
| 616 | 616 | const run = addRunArtifact(exe); |
| 617 | 617 | run.expectStdOutEqual("5 0 7 2\n"); |
| ... | ... | @@ -641,8 +641,8 @@ fn testCopyrel(b: *Build, opts: Options) *Step { |
| 641 | 641 | \\} |
| 642 | 642 | , |
| 643 | 643 | }); |
| 644 | | exe.linkLibrary(dso); |
| 645 | | exe.linkLibC(); |
| 644 | exe.root_module.linkLibrary(dso); |
| 645 | exe.root_module.link_libc = true; |
| 646 | 646 | |
| 647 | 647 | const run = addRunArtifact(exe); |
| 648 | 648 | run.expectStdOutEqual("3 5\n"); |
| ... | ... | @@ -679,8 +679,8 @@ fn testCopyrelAlias(b: *Build, opts: Options) *Step { |
| 679 | 679 | \\extern int bar; |
| 680 | 680 | \\int *get_bar() { return &bar; } |
| 681 | 681 | , &.{}); |
| 682 | | exe.linkLibrary(dso); |
| 683 | | exe.linkLibC(); |
| 682 | exe.root_module.linkLibrary(dso); |
| 683 | exe.root_module.link_libc = true; |
| 684 | 684 | exe.pie = false; |
| 685 | 685 | |
| 686 | 686 | const run = addRunArtifact(exe); |
| ... | ... | @@ -712,15 +712,15 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step { |
| 712 | 712 | , |
| 713 | 713 | .pic = false, |
| 714 | 714 | }); |
| 715 | | obj.linkLibC(); |
| 715 | obj.root_module.link_libc = true; |
| 716 | 716 | |
| 717 | 717 | const exp_stdout = "5\n"; |
| 718 | 718 | |
| 719 | 719 | { |
| 720 | 720 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 721 | | exe.addObject(obj); |
| 722 | | exe.linkLibrary(a_so); |
| 723 | | exe.linkLibC(); |
| 721 | exe.root_module.addObject(obj); |
| 722 | exe.root_module.linkLibrary(a_so); |
| 723 | exe.root_module.link_libc = true; |
| 724 | 724 | exe.pie = false; |
| 725 | 725 | |
| 726 | 726 | const run = addRunArtifact(exe); |
| ... | ... | @@ -737,9 +737,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step { |
| 737 | 737 | |
| 738 | 738 | { |
| 739 | 739 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 740 | | exe.addObject(obj); |
| 741 | | exe.linkLibrary(b_so); |
| 742 | | exe.linkLibC(); |
| 740 | exe.root_module.addObject(obj); |
| 741 | exe.root_module.linkLibrary(b_so); |
| 742 | exe.root_module.link_libc = true; |
| 743 | 743 | exe.pie = false; |
| 744 | 744 | |
| 745 | 745 | const run = addRunArtifact(exe); |
| ... | ... | @@ -756,9 +756,9 @@ fn testCopyrelAlignment(b: *Build, opts: Options) *Step { |
| 756 | 756 | |
| 757 | 757 | { |
| 758 | 758 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 759 | | exe.addObject(obj); |
| 760 | | exe.linkLibrary(c_so); |
| 761 | | exe.linkLibC(); |
| 759 | exe.root_module.addObject(obj); |
| 760 | exe.root_module.linkLibrary(c_so); |
| 761 | exe.root_module.link_libc = true; |
| 762 | 762 | exe.pie = false; |
| 763 | 763 | |
| 764 | 764 | const run = addRunArtifact(exe); |
| ... | ... | @@ -793,7 +793,7 @@ fn testDsoPlt(b: *Build, opts: Options) *Step { |
| 793 | 793 | \\ real_hello(); |
| 794 | 794 | \\} |
| 795 | 795 | , &.{}); |
| 796 | | dso.linkLibC(); |
| 796 | dso.root_module.link_libc = true; |
| 797 | 797 | |
| 798 | 798 | const exe = addExecutable(b, opts, .{ .name = "test" }); |
| 799 | 799 | addCSourceBytes(exe, |
| ... | ... | @@ -806,8 +806,8 @@ fn testDsoPlt(b: *Build, opts: Options) *Step { |
| 806 | 806 | \\ hello(); |
| 807 | 807 | \\} |
| 808 | 808 | , &.{}); |
| 809 | | exe.linkLibrary(dso); |
| 810 | | exe.linkLibC(); |
| 809 | exe.root_module.linkLibrary(dso); |
| 810 | exe.root_module.link_libc = true; |
| 811 | 811 | |
| 812 | 812 | const run = addRunArtifact(exe); |
| 813 | 813 | run.expectStdOutEqual("Hello WORLD\n"); |
| ... | ... | @@ -825,7 +825,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step { |
| 825 | 825 | \\int bar = 5; |
| 826 | 826 | \\int baz() { return foo; } |
| 827 | 827 | , &.{}); |
| 828 | | dso.linkLibC(); |
| 828 | dso.root_module.link_libc = true; |
| 829 | 829 | |
| 830 | 830 | const obj = addObject(b, opts, .{ |
| 831 | 831 | .name = "obj", |
| ... | ... | @@ -833,18 +833,18 @@ fn testDsoUndef(b: *Build, opts: Options) *Step { |
| 833 | 833 | }); |
| 834 | 834 | |
| 835 | 835 | const lib = addStaticLibrary(b, opts, .{ .name = "lib" }); |
| 836 | | lib.addObject(obj); |
| 836 | lib.root_module.addObject(obj); |
| 837 | 837 | |
| 838 | 838 | const exe = addExecutable(b, opts, .{ .name = "test" }); |
| 839 | | exe.linkLibrary(dso); |
| 840 | | exe.linkLibrary(lib); |
| 839 | exe.root_module.linkLibrary(dso); |
| 840 | exe.root_module.linkLibrary(lib); |
| 841 | 841 | addCSourceBytes(exe, |
| 842 | 842 | \\extern int bar; |
| 843 | 843 | \\int main() { |
| 844 | 844 | \\ return bar - 5; |
| 845 | 845 | \\} |
| 846 | 846 | , &.{}); |
| 847 | | exe.linkLibC(); |
| 847 | exe.root_module.link_libc = true; |
| 848 | 848 | |
| 849 | 849 | const run = addRunArtifact(exe); |
| 850 | 850 | run.expectExitCode(0); |
| ... | ... | @@ -871,7 +871,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step { |
| 871 | 871 | \\ std.debug.print("foo={d}\n", .{foo()}); |
| 872 | 872 | \\} |
| 873 | 873 | }); |
| 874 | | a_o.linkLibC(); |
| 874 | a_o.root_module.link_libc = true; |
| 875 | 875 | |
| 876 | 876 | const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes = |
| 877 | 877 | \\#include <stdio.h> |
| ... | ... | @@ -880,11 +880,11 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step { |
| 880 | 880 | \\ fprintf(stderr, "bar=%d\n", bar); |
| 881 | 881 | \\} |
| 882 | 882 | }); |
| 883 | | b_o.linkLibC(); |
| 883 | b_o.root_module.link_libc = true; |
| 884 | 884 | |
| 885 | 885 | const c_o = addObject(b, opts, .{ .name = "c" }); |
| 886 | | c_o.addObject(a_o); |
| 887 | | c_o.addObject(b_o); |
| 886 | c_o.root_module.addObject(a_o); |
| 887 | c_o.root_module.addObject(b_o); |
| 888 | 888 | |
| 889 | 889 | const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes = |
| 890 | 890 | \\const std = @import("std"); |
| ... | ... | @@ -895,8 +895,8 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step { |
| 895 | 895 | \\ printBar(); |
| 896 | 896 | \\} |
| 897 | 897 | }); |
| 898 | | exe.addObject(c_o); |
| 899 | | exe.linkLibC(); |
| 898 | exe.root_module.addObject(c_o); |
| 899 | exe.root_module.link_libc = true; |
| 900 | 900 | |
| 901 | 901 | const run = addRunArtifact(exe); |
| 902 | 902 | run.expectStdErrEqual( |
| ... | ... | @@ -944,9 +944,9 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step { |
| 944 | 944 | }); |
| 945 | 945 | |
| 946 | 946 | const lib = addStaticLibrary(b, opts, .{ .name = "lib" }); |
| 947 | | lib.addObject(obj1); |
| 948 | | lib.addObject(obj2); |
| 949 | | lib.addObject(obj3); |
| 947 | lib.root_module.addObject(obj1); |
| 948 | lib.root_module.addObject(obj2); |
| 949 | lib.root_module.addObject(obj3); |
| 950 | 950 | |
| 951 | 951 | const check = lib.checkObject(); |
| 952 | 952 | check.checkInArchiveSymtab(); |
| ... | ... | @@ -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); |
| 1000 | 1000 | |
| 1001 | 1001 | const exe = addExecutable(b, opts, .{ |
| 1002 | 1002 | .name = "test", |
| ... | ... | @@ -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); |
| 1012 | 1012 | |
| 1013 | 1013 | const run = addRunArtifact(exe); |
| 1014 | 1014 | run.expectStdErrEqual("44"); |
| ... | ... | @@ -1023,7 +1023,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step { |
| 1023 | 1023 | const exe = addExecutable(b, opts, .{ .name = "test" }); |
| 1024 | 1024 | addCSourceBytes(exe, "int main() { return 0; }", &.{}); |
| 1025 | 1025 | addCSourceBytes(exe, "", &.{}); |
| 1026 | | exe.linkLibC(); |
| 1026 | exe.root_module.link_libc = true; |
| 1027 | 1027 | |
| 1028 | 1028 | const run = addRunArtifact(exe); |
| 1029 | 1029 | run.expectExitCode(0); |
| ... | ... | @@ -1052,8 +1052,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { |
| 1052 | 1052 | |
| 1053 | 1053 | { |
| 1054 | 1054 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 1055 | | exe.addObject(a_o); |
| 1056 | | exe.addObject(b_o); |
| 1055 | exe.root_module.addObject(a_o); |
| 1056 | exe.root_module.addObject(b_o); |
| 1057 | 1057 | exe.entry = .{ .symbol_name = "foo" }; |
| 1058 | 1058 | |
| 1059 | 1059 | const check = exe.checkObject(); |
| ... | ... | @@ -1068,8 +1068,8 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { |
| 1068 | 1068 | // cause an artifact collision taking the cached executable from the above |
| 1069 | 1069 | // step instead of generating a new one. |
| 1070 | 1070 | const exe = addExecutable(b, opts, .{ .name = "other" }); |
| 1071 | | exe.addObject(a_o); |
| 1072 | | exe.addObject(b_o); |
| 1071 | exe.root_module.addObject(a_o); |
| 1072 | exe.root_module.addObject(b_o); |
| 1073 | 1073 | exe.entry = .{ .symbol_name = "bar" }; |
| 1074 | 1074 | |
| 1075 | 1075 | const check = exe.checkObject(); |
| ... | ... | @@ -1113,8 +1113,8 @@ fn testExportDynamic(b: *Build, opts: Options) *Step { |
| 1113 | 1113 | \\ return baz; |
| 1114 | 1114 | \\} |
| 1115 | 1115 | , &.{}); |
| 1116 | | exe.addObject(obj); |
| 1117 | | exe.linkLibrary(dso); |
| 1116 | exe.root_module.addObject(obj); |
| 1117 | exe.root_module.linkLibrary(dso); |
| 1118 | 1118 | exe.rdynamic = true; |
| 1119 | 1119 | |
| 1120 | 1120 | const check = exe.checkObject(); |
| ... | ... | @@ -1152,8 +1152,8 @@ fn testExportSymbolsFromExe(b: *Build, opts: Options) *Step { |
| 1152 | 1152 | \\ foo(); |
| 1153 | 1153 | \\} |
| 1154 | 1154 | , &.{}); |
| 1155 | | exe.linkLibrary(dso); |
| 1156 | | exe.linkLibC(); |
| 1155 | exe.root_module.linkLibrary(dso); |
| 1156 | exe.root_module.link_libc = true; |
| 1157 | 1157 | |
| 1158 | 1158 | const check = exe.checkObject(); |
| 1159 | 1159 | check.checkInDynamicSymtab(); |
| ... | ... | @@ -1181,7 +1181,7 @@ fn testFuncAddress(b: *Build, opts: Options) *Step { |
| 1181 | 1181 | \\ assert(fn == ptr); |
| 1182 | 1182 | \\} |
| 1183 | 1183 | , &.{}); |
| 1184 | | exe.linkLibrary(dso); |
| 1184 | exe.root_module.linkLibrary(dso); |
| 1185 | 1185 | exe.root_module.pic = false; |
| 1186 | 1186 | exe.pie = false; |
| 1187 | 1187 | |
| ... | ... | @@ -1216,15 +1216,15 @@ fn testGcSections(b: *Build, opts: Options) *Step { |
| 1216 | 1216 | }); |
| 1217 | 1217 | obj.link_function_sections = true; |
| 1218 | 1218 | obj.link_data_sections = true; |
| 1219 | | obj.linkLibC(); |
| 1220 | | obj.linkLibCpp(); |
| 1219 | obj.root_module.link_libc = true; |
| 1220 | obj.root_module.link_libcpp = true; |
| 1221 | 1221 | |
| 1222 | 1222 | { |
| 1223 | 1223 | const exe = addExecutable(b, opts, .{ .name = "test" }); |
| 1224 | | exe.addObject(obj); |
| 1224 | exe.root_module.addObject(obj); |
| 1225 | 1225 | exe.link_gc_sections = false; |
| 1226 | | exe.linkLibC(); |
| 1227 | | exe.linkLibCpp(); |
| 1226 | exe.root_module.link_libc = true; |
| 1227 | exe.root_module.link_libcpp = true; |
| 1228 | 1228 | |
| 1229 | 1229 | const run = addRunArtifact(exe); |
| 1230 | 1230 | run.expectStdOutEqual("1 2\n"); |
| ... | ... | @@ -1252,10 +1252,10 @@ fn testGcSections(b: *Build, opts: Options) *Step { |
| 1252 | 1252 | |
| 1253 | 1253 | { |
| 1254 | 1254 | const exe = addExecutable(b, opts, .{ .name = "test" }); |
| 1255 | | exe.addObject(obj); |
| 1255 | exe.root_module.addObject(obj); |
| 1256 | 1256 | exe.link_gc_sections = true; |
| 1257 | | exe.linkLibC(); |
| 1258 | | exe.linkLibCpp(); |
| 1257 | exe.root_module.link_libc = true; |
| 1258 | exe.root_module.link_libcpp = true; |
| 1259 | 1259 | |
| 1260 | 1260 | const run = addRunArtifact(exe); |
| 1261 | 1261 | run.expectStdOutEqual("1 2\n"); |
| ... | ... | @@ -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 | 1325 | exe.link_gc_sections = false; |
| 1326 | 1326 | |
| 1327 | 1327 | const run = addRunArtifact(exe); |
| ... | ... | @@ -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 | 1367 | exe.link_gc_sections = true; |
| 1368 | 1368 | |
| 1369 | 1369 | const run = addRunArtifact(exe); |
| ... | ... | @@ -1427,7 +1427,7 @@ fn testIFuncAlias(b: *Build, opts: Options) *Step { |
| 1427 | 1427 | \\} |
| 1428 | 1428 | , &.{}); |
| 1429 | 1429 | exe.root_module.pic = true; |
| 1430 | | exe.linkLibC(); |
| 1430 | exe.root_module.link_libc = true; |
| 1431 | 1431 | |
| 1432 | 1432 | const run = addRunArtifact(exe); |
| 1433 | 1433 | run.expectExitCode(0); |
| ... | ... | @@ -1467,9 +1467,9 @@ fn testIFuncDlopen(b: *Build, opts: Options) *Step { |
| 1467 | 1467 | \\ assert(foo == p); |
| 1468 | 1468 | \\} |
| 1469 | 1469 | , &.{}); |
| 1470 | | exe.linkLibrary(dso); |
| 1471 | | exe.linkLibC(); |
| 1472 | | exe.linkSystemLibrary2("dl", .{}); |
| 1470 | exe.root_module.linkLibrary(dso); |
| 1471 | exe.root_module.link_libc = true; |
| 1472 | exe.root_module.linkSystemLibrary("dl", .{}); |
| 1473 | 1473 | exe.root_module.pic = false; |
| 1474 | 1474 | exe.pie = false; |
| 1475 | 1475 | |
| ... | ... | @@ -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; |
| 1502 | 1502 | |
| 1503 | 1503 | const exe = addExecutable(b, opts, .{ |
| 1504 | 1504 | .name = "main", |
| ... | ... | @@ -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); |
| 1513 | 1513 | |
| 1514 | 1514 | const run = addRunArtifact(exe); |
| 1515 | 1515 | run.expectStdOutEqual("Hello world\n"); |
| ... | ... | @@ -1540,7 +1540,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step { |
| 1540 | 1540 | { |
| 1541 | 1541 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 1542 | 1542 | addCSourceBytes(exe, main_c, &.{}); |
| 1543 | | exe.linkLibC(); |
| 1543 | exe.root_module.link_libc = true; |
| 1544 | 1544 | exe.link_z_lazy = true; |
| 1545 | 1545 | |
| 1546 | 1546 | const run = addRunArtifact(exe); |
| ... | ... | @@ -1550,7 +1550,7 @@ fn testIFuncDynamic(b: *Build, opts: Options) *Step { |
| 1550 | 1550 | { |
| 1551 | 1551 | const exe = addExecutable(b, opts, .{ .name = "other" }); |
| 1552 | 1552 | addCSourceBytes(exe, main_c, &.{}); |
| 1553 | | exe.linkLibC(); |
| 1553 | exe.root_module.link_libc = true; |
| 1554 | 1554 | |
| 1555 | 1555 | const run = addRunArtifact(exe); |
| 1556 | 1556 | run.expectStdOutEqual("Hello world\n"); |
| ... | ... | @@ -1576,7 +1576,7 @@ fn testIFuncExport(b: *Build, opts: Options) *Step { |
| 1576 | 1576 | \\ return real_foobar; |
| 1577 | 1577 | \\} |
| 1578 | 1578 | , &.{}); |
| 1579 | | dso.linkLibC(); |
| 1579 | dso.root_module.link_libc = true; |
| 1580 | 1580 | |
| 1581 | 1581 | const check = dso.checkObject(); |
| 1582 | 1582 | check.checkInDynamicSymtab(); |
| ... | ... | @@ -1613,7 +1613,7 @@ fn testIFuncFuncPtr(b: *Build, opts: Options) *Step { |
| 1613 | 1613 | \\} |
| 1614 | 1614 | , &.{}); |
| 1615 | 1615 | exe.root_module.pic = true; |
| 1616 | | exe.linkLibC(); |
| 1616 | exe.root_module.link_libc = true; |
| 1617 | 1617 | |
| 1618 | 1618 | const run = addRunArtifact(exe); |
| 1619 | 1619 | run.expectStdOutEqual("3\n"); |
| ... | ... | @@ -1642,7 +1642,7 @@ fn testIFuncNoPlt(b: *Build, opts: Options) *Step { |
| 1642 | 1642 | \\} |
| 1643 | 1643 | , &.{"-fno-plt"}); |
| 1644 | 1644 | exe.root_module.pic = true; |
| 1645 | | exe.linkLibC(); |
| 1645 | exe.root_module.link_libc = true; |
| 1646 | 1646 | |
| 1647 | 1647 | const run = addRunArtifact(exe); |
| 1648 | 1648 | run.expectStdOutEqual("Hello world\n"); |
| ... | ... | @@ -1669,7 +1669,7 @@ fn testIFuncStatic(b: *Build, opts: Options) *Step { |
| 1669 | 1669 | \\ return 0; |
| 1670 | 1670 | \\} |
| 1671 | 1671 | , &.{}); |
| 1672 | | exe.linkLibC(); |
| 1672 | exe.root_module.link_libc = true; |
| 1673 | 1673 | exe.linkage = .static; |
| 1674 | 1674 | |
| 1675 | 1675 | const run = addRunArtifact(exe); |
| ... | ... | @@ -1700,7 +1700,7 @@ fn testIFuncStaticPie(b: *Build, opts: Options) *Step { |
| 1700 | 1700 | exe.linkage = .static; |
| 1701 | 1701 | exe.root_module.pic = true; |
| 1702 | 1702 | exe.pie = true; |
| 1703 | | exe.linkLibC(); |
| 1703 | exe.root_module.link_libc = true; |
| 1704 | 1704 | |
| 1705 | 1705 | const run = addRunArtifact(exe); |
| 1706 | 1706 | run.expectStdOutEqual("Hello world\n"); |
| ... | ... | @@ -1733,7 +1733,7 @@ fn testImageBase(b: *Build, opts: Options) *Step { |
| 1733 | 1733 | \\ return 0; |
| 1734 | 1734 | \\} |
| 1735 | 1735 | , &.{}); |
| 1736 | | exe.linkLibC(); |
| 1736 | exe.root_module.link_libc = true; |
| 1737 | 1737 | exe.image_base = 0x8000000; |
| 1738 | 1738 | |
| 1739 | 1739 | const run = addRunArtifact(exe); |
| ... | ... | @@ -1779,7 +1779,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step { |
| 1779 | 1779 | \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); } |
| 1780 | 1780 | , |
| 1781 | 1781 | }); |
| 1782 | | dso.linkLibC(); |
| 1782 | dso.root_module.link_libc = true; |
| 1783 | 1783 | |
| 1784 | 1784 | const main = addExecutable(b, opts, .{ |
| 1785 | 1785 | .name = "main", |
| ... | ... | @@ -1798,7 +1798,7 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step { |
| 1798 | 1798 | .strip = true, // TODO temp hack |
| 1799 | 1799 | }); |
| 1800 | 1800 | main.pie = true; |
| 1801 | | main.linkLibrary(dso); |
| 1801 | main.root_module.linkLibrary(dso); |
| 1802 | 1802 | |
| 1803 | 1803 | const run = addRunArtifact(main); |
| 1804 | 1804 | run.expectStdErrEqual( |
| ... | ... | @@ -1832,7 +1832,7 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step { |
| 1832 | 1832 | }, .{ |
| 1833 | 1833 | .name = "a", |
| 1834 | 1834 | }); |
| 1835 | | lib.addObject(obj); |
| 1835 | lib.root_module.addObject(obj); |
| 1836 | 1836 | |
| 1837 | 1837 | const main = addExecutable(b, opts, .{ |
| 1838 | 1838 | .name = "main", |
| ... | ... | @@ -1844,8 +1844,8 @@ fn testImportingDataStatic(b: *Build, opts: Options) *Step { |
| 1844 | 1844 | , |
| 1845 | 1845 | .strip = true, // TODO temp hack |
| 1846 | 1846 | }); |
| 1847 | | main.linkLibrary(lib); |
| 1848 | | main.linkLibC(); |
| 1847 | main.root_module.linkLibrary(lib); |
| 1848 | main.root_module.link_libc = true; |
| 1849 | 1849 | |
| 1850 | 1850 | const run = addRunArtifact(main); |
| 1851 | 1851 | run.expectStdErrEqual("42\n"); |
| ... | ... | @@ -1864,7 +1864,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1864 | 1864 | \\__attribute__((constructor(10000))) void init4() { printf("1"); } |
| 1865 | 1865 | , |
| 1866 | 1866 | }); |
| 1867 | | a_o.linkLibC(); |
| 1867 | a_o.root_module.link_libc = true; |
| 1868 | 1868 | |
| 1869 | 1869 | const b_o = addObject(b, opts, .{ |
| 1870 | 1870 | .name = "b", |
| ... | ... | @@ -1873,7 +1873,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1873 | 1873 | \\__attribute__((constructor(1000))) void init3() { printf("2"); } |
| 1874 | 1874 | , |
| 1875 | 1875 | }); |
| 1876 | | b_o.linkLibC(); |
| 1876 | b_o.root_module.link_libc = true; |
| 1877 | 1877 | |
| 1878 | 1878 | const c_o = addObject(b, opts, .{ |
| 1879 | 1879 | .name = "c", |
| ... | ... | @@ -1882,7 +1882,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1882 | 1882 | \\__attribute__((constructor)) void init1() { printf("3"); } |
| 1883 | 1883 | , |
| 1884 | 1884 | }); |
| 1885 | | c_o.linkLibC(); |
| 1885 | c_o.root_module.link_libc = true; |
| 1886 | 1886 | |
| 1887 | 1887 | const d_o = addObject(b, opts, .{ |
| 1888 | 1888 | .name = "d", |
| ... | ... | @@ -1891,7 +1891,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1891 | 1891 | \\__attribute__((constructor)) void init2() { printf("4"); } |
| 1892 | 1892 | , |
| 1893 | 1893 | }); |
| 1894 | | d_o.linkLibC(); |
| 1894 | d_o.root_module.link_libc = true; |
| 1895 | 1895 | |
| 1896 | 1896 | const e_o = addObject(b, opts, .{ |
| 1897 | 1897 | .name = "e", |
| ... | ... | @@ -1900,7 +1900,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1900 | 1900 | \\__attribute__((destructor(10000))) void fini4() { printf("5"); } |
| 1901 | 1901 | , |
| 1902 | 1902 | }); |
| 1903 | | e_o.linkLibC(); |
| 1903 | e_o.root_module.link_libc = true; |
| 1904 | 1904 | |
| 1905 | 1905 | const f_o = addObject(b, opts, .{ |
| 1906 | 1906 | .name = "f", |
| ... | ... | @@ -1909,7 +1909,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1909 | 1909 | \\__attribute__((destructor(1000))) void fini3() { printf("6"); } |
| 1910 | 1910 | , |
| 1911 | 1911 | }); |
| 1912 | | f_o.linkLibC(); |
| 1912 | f_o.root_module.link_libc = true; |
| 1913 | 1913 | |
| 1914 | 1914 | const g_o = addObject(b, opts, .{ |
| 1915 | 1915 | .name = "g", |
| ... | ... | @@ -1918,24 +1918,24 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step { |
| 1918 | 1918 | \\__attribute__((destructor)) void fini1() { printf("7"); } |
| 1919 | 1919 | , |
| 1920 | 1920 | }); |
| 1921 | | g_o.linkLibC(); |
| 1921 | g_o.root_module.link_libc = true; |
| 1922 | 1922 | |
| 1923 | 1923 | const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes = |
| 1924 | 1924 | \\#include <stdio.h> |
| 1925 | 1925 | \\__attribute__((destructor)) void fini2() { printf("8"); } |
| 1926 | 1926 | }); |
| 1927 | | h_o.linkLibC(); |
| 1927 | h_o.root_module.link_libc = true; |
| 1928 | 1928 | |
| 1929 | 1929 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 1930 | 1930 | addCSourceBytes(exe, "int main() { return 0; }", &.{}); |
| 1931 | | exe.addObject(a_o); |
| 1932 | | exe.addObject(b_o); |
| 1933 | | exe.addObject(c_o); |
| 1934 | | exe.addObject(d_o); |
| 1935 | | exe.addObject(e_o); |
| 1936 | | exe.addObject(f_o); |
| 1937 | | exe.addObject(g_o); |
| 1938 | | exe.addObject(h_o); |
| 1931 | exe.root_module.addObject(a_o); |
| 1932 | exe.root_module.addObject(b_o); |
| 1933 | exe.root_module.addObject(c_o); |
| 1934 | exe.root_module.addObject(d_o); |
| 1935 | exe.root_module.addObject(e_o); |
| 1936 | exe.root_module.addObject(f_o); |
| 1937 | exe.root_module.addObject(g_o); |
| 1938 | exe.root_module.addObject(h_o); |
| 1939 | 1939 | |
| 1940 | 1940 | if (opts.target.result.isGnuLibC()) { |
| 1941 | 1941 | // 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 | 1970 | \\} |
| 1971 | 1971 | , &.{}); |
| 1972 | 1972 | dso.link_function_sections = true; |
| 1973 | | dso.linkLibC(); |
| 1973 | dso.root_module.link_libc = true; |
| 1974 | 1974 | |
| 1975 | 1975 | const check = dso.checkObject(); |
| 1976 | 1976 | check.checkInSymtab(); |
| ... | ... | @@ -1986,8 +1986,8 @@ fn testLargeAlignmentDso(b: *Build, opts: Options) *Step { |
| 1986 | 1986 | \\void greet(); |
| 1987 | 1987 | \\int main() { greet(); } |
| 1988 | 1988 | , &.{}); |
| 1989 | | exe.linkLibrary(dso); |
| 1990 | | exe.linkLibC(); |
| 1989 | exe.root_module.linkLibrary(dso); |
| 1990 | exe.root_module.link_libc = true; |
| 1991 | 1991 | |
| 1992 | 1992 | const run = addRunArtifact(exe); |
| 1993 | 1993 | run.expectStdOutEqual("Hello world"); |
| ... | ... | @@ -2021,7 +2021,7 @@ fn testLargeAlignmentExe(b: *Build, opts: Options) *Step { |
| 2021 | 2021 | \\} |
| 2022 | 2022 | , &.{}); |
| 2023 | 2023 | exe.link_function_sections = true; |
| 2024 | | exe.linkLibC(); |
| 2024 | exe.root_module.link_libc = true; |
| 2025 | 2025 | |
| 2026 | 2026 | const check = exe.checkObject(); |
| 2027 | 2027 | check.checkInSymtab(); |
| ... | ... | @@ -2049,7 +2049,7 @@ fn testLargeBss(b: *Build, opts: Options) *Step { |
| 2049 | 2049 | \\ return arr[2000]; |
| 2050 | 2050 | \\} |
| 2051 | 2051 | , &.{}); |
| 2052 | | exe.linkLibC(); |
| 2052 | exe.root_module.link_libc = true; |
| 2053 | 2053 | // Disabled to work around the ELF linker crashing. |
| 2054 | 2054 | // Can be reproduced on a x86_64-linux host by commenting out the line below. |
| 2055 | 2055 | exe.root_module.sanitize_c = .off; |
| ... | ... | @@ -2071,10 +2071,10 @@ fn testLinkOrder(b: *Build, opts: Options) *Step { |
| 2071 | 2071 | }); |
| 2072 | 2072 | |
| 2073 | 2073 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 2074 | | dso.addObject(obj); |
| 2074 | dso.root_module.addObject(obj); |
| 2075 | 2075 | |
| 2076 | 2076 | const lib = addStaticLibrary(b, opts, .{ .name = "b" }); |
| 2077 | | lib.addObject(obj); |
| 2077 | lib.root_module.addObject(obj); |
| 2078 | 2078 | |
| 2079 | 2079 | const main_o = addObject(b, opts, .{ |
| 2080 | 2080 | .name = "main", |
| ... | ... | @@ -2089,14 +2089,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step { |
| 2089 | 2089 | // https://github.com/ziglang/zig/issues/17450 |
| 2090 | 2090 | // { |
| 2091 | 2091 | // const exe = addExecutable(b, opts, .{ .name = "main1"}); |
| 2092 | | // exe.addObject(main_o); |
| 2093 | | // exe.linkSystemLibrary2("a", .{}); |
| 2094 | | // exe.addLibraryPath(dso.getEmittedBinDirectory()); |
| 2095 | | // exe.addRPath(dso.getEmittedBinDirectory()); |
| 2096 | | // exe.linkSystemLibrary2("b", .{}); |
| 2097 | | // exe.addLibraryPath(lib.getEmittedBinDirectory()); |
| 2098 | | // exe.addRPath(lib.getEmittedBinDirectory()); |
| 2099 | | // exe.linkLibC(); |
| 2092 | // exe.root_module.addObject(main_o); |
| 2093 | // exe.root_module.linkSystemLibrary("a", .{}); |
| 2094 | // exe.root_module.addLibraryPath(dso.getEmittedBinDirectory()); |
| 2095 | // exe.root_module.addRPath(dso.getEmittedBinDirectory()); |
| 2096 | // exe.root_module.linkSystemLibrary("b", .{}); |
| 2097 | // exe.root_module.addLibraryPath(lib.getEmittedBinDirectory()); |
| 2098 | // exe.root_module.addRPath(lib.getEmittedBinDirectory()); |
| 2099 | // exe.root_module.link_libc = true; |
| 2100 | 2100 | |
| 2101 | 2101 | // const check = exe.checkObject(); |
| 2102 | 2102 | // check.checkInDynamicSection(); |
| ... | ... | @@ -2106,14 +2106,14 @@ fn testLinkOrder(b: *Build, opts: Options) *Step { |
| 2106 | 2106 | |
| 2107 | 2107 | { |
| 2108 | 2108 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 2109 | | exe.addObject(main_o); |
| 2110 | | exe.linkSystemLibrary2("b", .{}); |
| 2111 | | exe.addLibraryPath(lib.getEmittedBinDirectory()); |
| 2112 | | exe.addRPath(lib.getEmittedBinDirectory()); |
| 2113 | | exe.linkSystemLibrary2("a", .{}); |
| 2114 | | exe.addLibraryPath(dso.getEmittedBinDirectory()); |
| 2115 | | exe.addRPath(dso.getEmittedBinDirectory()); |
| 2116 | | exe.linkLibC(); |
| 2109 | exe.root_module.addObject(main_o); |
| 2110 | exe.root_module.linkSystemLibrary("b", .{}); |
| 2111 | exe.root_module.addLibraryPath(lib.getEmittedBinDirectory()); |
| 2112 | exe.root_module.addRPath(lib.getEmittedBinDirectory()); |
| 2113 | exe.root_module.linkSystemLibrary("a", .{}); |
| 2114 | exe.root_module.addLibraryPath(dso.getEmittedBinDirectory()); |
| 2115 | exe.root_module.addRPath(dso.getEmittedBinDirectory()); |
| 2116 | exe.root_module.link_libc = true; |
| 2117 | 2117 | |
| 2118 | 2118 | const check = exe.checkObject(); |
| 2119 | 2119 | check.checkInDynamicSection(); |
| ... | ... | @@ -2149,14 +2149,14 @@ fn testLdScript(b: *Build, opts: Options) *Step { |
| 2149 | 2149 | \\ return bar() - baz(); |
| 2150 | 2150 | \\} |
| 2151 | 2151 | , &.{}); |
| 2152 | | exe.linkSystemLibrary2("a", .{}); |
| 2153 | | exe.addLibraryPath(scripts.getDirectory()); |
| 2154 | | exe.addLibraryPath(scripts2.getDirectory()); |
| 2155 | | exe.addLibraryPath(bar.getEmittedBinDirectory()); |
| 2156 | | exe.addLibraryPath(baz.getEmittedBinDirectory()); |
| 2157 | | exe.addRPath(bar.getEmittedBinDirectory()); |
| 2158 | | exe.addRPath(baz.getEmittedBinDirectory()); |
| 2159 | | exe.linkLibC(); |
| 2152 | exe.root_module.linkSystemLibrary("a", .{}); |
| 2153 | exe.root_module.addLibraryPath(scripts.getDirectory()); |
| 2154 | exe.root_module.addLibraryPath(scripts2.getDirectory()); |
| 2155 | exe.root_module.addLibraryPath(bar.getEmittedBinDirectory()); |
| 2156 | exe.root_module.addLibraryPath(baz.getEmittedBinDirectory()); |
| 2157 | exe.root_module.addRPath(bar.getEmittedBinDirectory()); |
| 2158 | exe.root_module.addRPath(baz.getEmittedBinDirectory()); |
| 2159 | exe.root_module.link_libc = true; |
| 2160 | 2160 | exe.allow_so_scripts = true; |
| 2161 | 2161 | |
| 2162 | 2162 | const run = addRunArtifact(exe); |
| ... | ... | @@ -2174,9 +2174,9 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step { |
| 2174 | 2174 | |
| 2175 | 2175 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 2176 | 2176 | addCSourceBytes(exe, "int main() { return 0; }", &.{}); |
| 2177 | | exe.linkSystemLibrary2("a", .{}); |
| 2178 | | exe.addLibraryPath(scripts.getDirectory()); |
| 2179 | | exe.linkLibC(); |
| 2177 | exe.root_module.linkSystemLibrary("a", .{}); |
| 2178 | exe.root_module.addLibraryPath(scripts.getDirectory()); |
| 2179 | exe.root_module.link_libc = true; |
| 2180 | 2180 | exe.allow_so_scripts = true; |
| 2181 | 2181 | |
| 2182 | 2182 | // TODO: A future enhancement could make this error message also mention |
| ... | ... | @@ -2213,8 +2213,8 @@ fn testLdScriptAllowUndefinedVersion(b: *Build, opts: Options) *Step { |
| 2213 | 2213 | \\} |
| 2214 | 2214 | , |
| 2215 | 2215 | }); |
| 2216 | | exe.linkLibrary(so); |
| 2217 | | exe.linkLibC(); |
| 2216 | exe.root_module.linkLibrary(so); |
| 2217 | exe.root_module.link_libc = true; |
| 2218 | 2218 | exe.allow_so_scripts = true; |
| 2219 | 2219 | |
| 2220 | 2220 | const run = addRunArtifact(exe); |
| ... | ... | @@ -2269,8 +2269,8 @@ fn testMismatchedCpuArchitectureError(b: *Build, opts: Options) *Step { |
| 2269 | 2269 | \\ return foo; |
| 2270 | 2270 | \\} |
| 2271 | 2271 | , &.{}); |
| 2272 | | exe.addObject(obj); |
| 2273 | | exe.linkLibC(); |
| 2272 | exe.root_module.addObject(obj); |
| 2273 | exe.root_module.link_libc = true; |
| 2274 | 2274 | |
| 2275 | 2275 | expectLinkErrors(exe, test_step, .{ .exact = &.{ |
| 2276 | 2276 | "invalid ELF machine type: AARCH64", |
| ... | ... | @@ -2291,7 +2291,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step { |
| 2291 | 2291 | \\ return 0; |
| 2292 | 2292 | \\} |
| 2293 | 2293 | , &.{}); |
| 2294 | | exe.linkLibC(); |
| 2294 | exe.root_module.link_libc = true; |
| 2295 | 2295 | |
| 2296 | 2296 | const run = addRunArtifact(exe); |
| 2297 | 2297 | run.expectStdOutEqual("Hello World!\n"); |
| ... | ... | @@ -2320,8 +2320,8 @@ fn testLinkingCpp(b: *Build, opts: Options) *Step { |
| 2320 | 2320 | \\ return 0; |
| 2321 | 2321 | \\} |
| 2322 | 2322 | , &.{}); |
| 2323 | | exe.linkLibC(); |
| 2324 | | exe.linkLibCpp(); |
| 2323 | exe.root_module.link_libc = true; |
| 2324 | exe.root_module.link_libcpp = true; |
| 2325 | 2325 | |
| 2326 | 2326 | const run = addRunArtifact(exe); |
| 2327 | 2327 | run.expectStdOutEqual("Hello World!\n"); |
| ... | ... | @@ -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); |
| 2368 | 2368 | |
| 2369 | 2369 | const run = addRunArtifact(exe); |
| 2370 | 2370 | run.expectStdErrEqual("84\n"); |
| ... | ... | @@ -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); |
| 2393 | 2393 | |
| 2394 | 2394 | const exe = addExecutable(b, opts, .{ |
| 2395 | 2395 | .name = "testlib", |
| ... | ... | @@ -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); |
| 2406 | 2406 | |
| 2407 | 2407 | const run = addRunArtifact(exe); |
| 2408 | 2408 | run.expectStdErrEqual("0\n"); |
| ... | ... | @@ -2452,7 +2452,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step { |
| 2452 | 2452 | \\char16_t *utf16_1 = u"foo"; |
| 2453 | 2453 | \\char32_t *utf32_1 = U"foo"; |
| 2454 | 2454 | , &.{"-O2"}); |
| 2455 | | obj1.linkLibC(); |
| 2455 | obj1.root_module.link_libc = true; |
| 2456 | 2456 | |
| 2457 | 2457 | const obj2 = addObject(b, opts, .{ .name = "b.o" }); |
| 2458 | 2458 | addCSourceBytes(obj2, |
| ... | ... | @@ -2481,12 +2481,12 @@ fn testMergeStrings(b: *Build, opts: Options) *Step { |
| 2481 | 2481 | \\ assert((void*)wide1 != (void*)utf16_1); |
| 2482 | 2482 | \\} |
| 2483 | 2483 | , &.{"-O2"}); |
| 2484 | | obj2.linkLibC(); |
| 2484 | obj2.root_module.link_libc = true; |
| 2485 | 2485 | |
| 2486 | 2486 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 2487 | | exe.addObject(obj1); |
| 2488 | | exe.addObject(obj2); |
| 2489 | | exe.linkLibC(); |
| 2487 | exe.root_module.addObject(obj1); |
| 2488 | exe.root_module.addObject(obj2); |
| 2489 | exe.root_module.link_libc = true; |
| 2490 | 2490 | |
| 2491 | 2491 | const run = addRunArtifact(exe); |
| 2492 | 2492 | run.expectExitCode(0); |
| ... | ... | @@ -2520,8 +2520,8 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step { |
| 2520 | 2520 | |
| 2521 | 2521 | { |
| 2522 | 2522 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 2523 | | exe.addObject(obj1); |
| 2524 | | exe.addObject(obj2); |
| 2523 | exe.root_module.addObject(obj1); |
| 2524 | exe.root_module.addObject(obj2); |
| 2525 | 2525 | |
| 2526 | 2526 | const run = addRunArtifact(exe); |
| 2527 | 2527 | run.expectExitCode(0); |
| ... | ... | @@ -2537,11 +2537,11 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step { |
| 2537 | 2537 | |
| 2538 | 2538 | { |
| 2539 | 2539 | const obj3 = addObject(b, opts, .{ .name = "c" }); |
| 2540 | | obj3.addObject(obj1); |
| 2541 | | obj3.addObject(obj2); |
| 2540 | obj3.root_module.addObject(obj1); |
| 2541 | obj3.root_module.addObject(obj2); |
| 2542 | 2542 | |
| 2543 | 2543 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 2544 | | exe.addObject(obj3); |
| 2544 | exe.root_module.addObject(obj3); |
| 2545 | 2545 | |
| 2546 | 2546 | const run = addRunArtifact(exe); |
| 2547 | 2547 | run.expectExitCode(0); |
| ... | ... | @@ -2564,7 +2564,7 @@ fn testNoEhFrameHdr(b: *Build, opts: Options) *Step { |
| 2564 | 2564 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 2565 | 2565 | addCSourceBytes(exe, "int main() { return 0; }", &.{}); |
| 2566 | 2566 | exe.link_eh_frame_hdr = false; |
| 2567 | | exe.linkLibC(); |
| 2567 | exe.root_module.link_libc = true; |
| 2568 | 2568 | |
| 2569 | 2569 | const check = exe.checkObject(); |
| 2570 | 2570 | check.checkInHeaders(); |
| ... | ... | @@ -2586,7 +2586,7 @@ fn testPie(b: *Build, opts: Options) *Step { |
| 2586 | 2586 | \\ return 0; |
| 2587 | 2587 | \\} |
| 2588 | 2588 | , &.{}); |
| 2589 | | exe.linkLibC(); |
| 2589 | exe.root_module.link_libc = true; |
| 2590 | 2590 | exe.root_module.pic = true; |
| 2591 | 2591 | exe.pie = true; |
| 2592 | 2592 | |
| ... | ... | @@ -2617,7 +2617,7 @@ fn testPltGot(b: *Build, opts: Options) *Step { |
| 2617 | 2617 | \\ printf("Hello world\n"); |
| 2618 | 2618 | \\} |
| 2619 | 2619 | , &.{}); |
| 2620 | | dso.linkLibC(); |
| 2620 | dso.root_module.link_libc = true; |
| 2621 | 2621 | |
| 2622 | 2622 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 2623 | 2623 | addCSourceBytes(exe, |
| ... | ... | @@ -2626,9 +2626,9 @@ fn testPltGot(b: *Build, opts: Options) *Step { |
| 2626 | 2626 | \\void foo() { ignore(hello); } |
| 2627 | 2627 | \\int main() { hello(); } |
| 2628 | 2628 | , &.{}); |
| 2629 | | exe.linkLibrary(dso); |
| 2629 | exe.root_module.linkLibrary(dso); |
| 2630 | 2630 | exe.root_module.pic = true; |
| 2631 | | exe.linkLibC(); |
| 2631 | exe.root_module.link_libc = true; |
| 2632 | 2632 | |
| 2633 | 2633 | const run = addRunArtifact(exe); |
| 2634 | 2634 | run.expectStdOutEqual("Hello world\n"); |
| ... | ... | @@ -2647,7 +2647,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 2647 | 2647 | }); |
| 2648 | 2648 | |
| 2649 | 2649 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 2650 | | exe.addObject(obj); |
| 2650 | exe.root_module.addObject(obj); |
| 2651 | 2651 | |
| 2652 | 2652 | const check = exe.checkObject(); |
| 2653 | 2653 | check.checkInDynamicSection(); |
| ... | ... | @@ -2662,7 +2662,7 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 2662 | 2662 | \\__attribute__((section(".preinit_array"))) |
| 2663 | 2663 | \\void *preinit[] = { preinit_fn }; |
| 2664 | 2664 | , &.{}); |
| 2665 | | exe.linkLibC(); |
| 2665 | exe.root_module.link_libc = true; |
| 2666 | 2666 | |
| 2667 | 2667 | const check = exe.checkObject(); |
| 2668 | 2668 | check.checkInDynamicSection(); |
| ... | ... | @@ -2710,15 +2710,15 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step { |
| 2710 | 2710 | }); |
| 2711 | 2711 | |
| 2712 | 2712 | const lib = addStaticLibrary(b, opts, .{ .name = "lib" }); |
| 2713 | | lib.addObject(obj1); |
| 2714 | | lib.addObject(obj2); |
| 2715 | | lib.addObject(obj3); |
| 2713 | lib.root_module.addObject(obj1); |
| 2714 | lib.root_module.addObject(obj2); |
| 2715 | lib.root_module.addObject(obj3); |
| 2716 | 2716 | |
| 2717 | 2717 | const obj5 = addObject(b, opts, .{ |
| 2718 | 2718 | .name = "obj5", |
| 2719 | 2719 | }); |
| 2720 | | obj5.addObject(obj4); |
| 2721 | | obj5.linkLibrary(lib); |
| 2720 | obj5.root_module.addObject(obj4); |
| 2721 | obj5.root_module.linkLibrary(lib); |
| 2722 | 2722 | |
| 2723 | 2723 | const check = obj5.checkObject(); |
| 2724 | 2724 | check.checkInSymtab(); |
| ... | ... | @@ -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 | 2748 | const obj2 = addObject(b, opts, .{ |
| 2749 | 2749 | .name = "obj2", |
| 2750 | 2750 | .cpp_source_bytes = |
| ... | ... | @@ -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 | 2758 | const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes = |
| 2759 | 2759 | \\#include <iostream> |
| 2760 | 2760 | \\#include <stdexcept> |
| ... | ... | @@ -2768,18 +2768,18 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2768 | 2768 | \\ return 0; |
| 2769 | 2769 | \\} |
| 2770 | 2770 | }); |
| 2771 | | obj3.linkLibCpp(); |
| 2771 | obj3.root_module.link_libcpp = true; |
| 2772 | 2772 | |
| 2773 | 2773 | { |
| 2774 | 2774 | const obj = addObject(b, opts, .{ .name = "obj" }); |
| 2775 | | obj.addObject(obj1); |
| 2776 | | obj.addObject(obj2); |
| 2777 | | obj.linkLibCpp(); |
| 2775 | obj.root_module.addObject(obj1); |
| 2776 | obj.root_module.addObject(obj2); |
| 2777 | obj.root_module.link_libcpp = true; |
| 2778 | 2778 | |
| 2779 | 2779 | const exe = addExecutable(b, opts, .{ .name = "test1" }); |
| 2780 | | exe.addObject(obj3); |
| 2781 | | exe.addObject(obj); |
| 2782 | | exe.linkLibCpp(); |
| 2780 | exe.root_module.addObject(obj3); |
| 2781 | exe.root_module.addObject(obj); |
| 2782 | exe.root_module.link_libcpp = true; |
| 2783 | 2783 | |
| 2784 | 2784 | const run = addRunArtifact(exe); |
| 2785 | 2785 | run.expectStdOutEqual("exception=Oh no!"); |
| ... | ... | @@ -2788,14 +2788,14 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2788 | 2788 | { |
| 2789 | 2789 | // Flipping the order should not influence the end result. |
| 2790 | 2790 | const obj = addObject(b, opts, .{ .name = "obj" }); |
| 2791 | | obj.addObject(obj2); |
| 2792 | | obj.addObject(obj1); |
| 2793 | | obj.linkLibCpp(); |
| 2791 | obj.root_module.addObject(obj2); |
| 2792 | obj.root_module.addObject(obj1); |
| 2793 | obj.root_module.link_libcpp = true; |
| 2794 | 2794 | |
| 2795 | 2795 | const exe = addExecutable(b, opts, .{ .name = "test2" }); |
| 2796 | | exe.addObject(obj3); |
| 2797 | | exe.addObject(obj); |
| 2798 | | exe.linkLibCpp(); |
| 2796 | exe.root_module.addObject(obj3); |
| 2797 | exe.root_module.addObject(obj); |
| 2798 | exe.root_module.link_libcpp = true; |
| 2799 | 2799 | |
| 2800 | 2800 | const run = addRunArtifact(exe); |
| 2801 | 2801 | run.expectStdOutEqual("exception=Oh no!"); |
| ... | ... | @@ -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 | 2821 | const obj2 = addObject(b, opts, .{ |
| 2822 | 2822 | .name = "obj2", |
| 2823 | 2823 | .cpp_source_bytes = |
| ... | ... | @@ -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 | 2831 | const obj3 = addObject(b, opts, .{ |
| 2832 | 2832 | .name = "obj3", |
| 2833 | 2833 | .cpp_source_bytes = |
| ... | ... | @@ -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; |
| 2848 | 2848 | |
| 2849 | 2849 | const obj = addObject(b, opts, .{ .name = "obj" }); |
| 2850 | | obj.addObject(obj1); |
| 2851 | | obj.addObject(obj2); |
| 2852 | | obj.addObject(obj3); |
| 2853 | | obj.linkLibCpp(); |
| 2850 | obj.root_module.addObject(obj1); |
| 2851 | obj.root_module.addObject(obj2); |
| 2852 | obj.root_module.addObject(obj3); |
| 2853 | obj.root_module.link_libcpp = true; |
| 2854 | 2854 | |
| 2855 | 2855 | const exe = addExecutable(b, opts, .{ .name = "test2" }); |
| 2856 | | exe.addObject(obj); |
| 2857 | | exe.linkLibCpp(); |
| 2856 | exe.root_module.addObject(obj); |
| 2857 | exe.root_module.link_libcpp = true; |
| 2858 | 2858 | |
| 2859 | 2859 | const run = addRunArtifact(exe); |
| 2860 | 2860 | run.expectStdOutEqual("exception=Oh no!"); |
| ... | ... | @@ -2880,7 +2880,7 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step { |
| 2880 | 2880 | }); |
| 2881 | 2881 | |
| 2882 | 2882 | const obj2 = addObject(b, opts, .{ .name = "b" }); |
| 2883 | | obj2.addObject(obj1); |
| 2883 | obj2.root_module.addObject(obj1); |
| 2884 | 2884 | |
| 2885 | 2885 | const check = obj2.checkObject(); |
| 2886 | 2886 | check.dumpSection(".rodata.str1.1"); |
| ... | ... | @@ -2905,7 +2905,7 @@ fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step { |
| 2905 | 2905 | const obj2 = addObject(b, opts, .{ |
| 2906 | 2906 | .name = "obj2", |
| 2907 | 2907 | }); |
| 2908 | | obj2.addObject(obj1); |
| 2908 | obj2.root_module.addObject(obj1); |
| 2909 | 2909 | |
| 2910 | 2910 | const check1 = obj1.checkObject(); |
| 2911 | 2911 | check1.checkInHeaders(); |
| ... | ... | @@ -2940,12 +2940,12 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step { |
| 2940 | 2940 | , |
| 2941 | 2941 | .pic = true, |
| 2942 | 2942 | }); |
| 2943 | | obj.linkLibC(); |
| 2943 | obj.root_module.link_libc = true; |
| 2944 | 2944 | |
| 2945 | 2945 | { |
| 2946 | 2946 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 2947 | | exe.addObject(obj); |
| 2948 | | exe.linkLibrary(dso); |
| 2947 | exe.root_module.addObject(obj); |
| 2948 | exe.root_module.linkLibrary(dso); |
| 2949 | 2949 | exe.pie = true; |
| 2950 | 2950 | |
| 2951 | 2951 | const run = addRunArtifact(exe); |
| ... | ... | @@ -2965,8 +2965,8 @@ fn testSharedAbsSymbol(b: *Build, opts: Options) *Step { |
| 2965 | 2965 | // https://github.com/ziglang/zig/issues/17430 |
| 2966 | 2966 | // { |
| 2967 | 2967 | // const exe = addExecutable(b, opts, .{ .name = "main2"}); |
| 2968 | | // exe.addObject(obj); |
| 2969 | | // exe.linkLibrary(dso); |
| 2968 | // exe.root_module.addObject(obj); |
| 2969 | // exe.root_module.linkLibrary(dso); |
| 2970 | 2970 | // exe.pie = false; |
| 2971 | 2971 | |
| 2972 | 2972 | // const run = addRunArtifact(exe); |
| ... | ... | @@ -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; |
| 3003 | 3003 | |
| 3004 | 3004 | { |
| 3005 | 3005 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3006 | | exe.addObject(obj); |
| 3006 | exe.root_module.addObject(obj); |
| 3007 | 3007 | exe.root_module.strip = false; |
| 3008 | | exe.linkLibC(); |
| 3008 | exe.root_module.link_libc = true; |
| 3009 | 3009 | |
| 3010 | 3010 | const check = exe.checkObject(); |
| 3011 | 3011 | check.checkInHeaders(); |
| ... | ... | @@ -3016,9 +3016,9 @@ fn testStrip(b: *Build, opts: Options) *Step { |
| 3016 | 3016 | |
| 3017 | 3017 | { |
| 3018 | 3018 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3019 | | exe.addObject(obj); |
| 3019 | exe.root_module.addObject(obj); |
| 3020 | 3020 | exe.root_module.strip = true; |
| 3021 | | exe.linkLibC(); |
| 3021 | exe.root_module.link_libc = true; |
| 3022 | 3022 | |
| 3023 | 3023 | const check = exe.checkObject(); |
| 3024 | 3024 | check.checkInHeaders(); |
| ... | ... | @@ -3074,7 +3074,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step { |
| 3074 | 3074 | |
| 3075 | 3075 | { |
| 3076 | 3076 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 3077 | | dso.addObject(obj); |
| 3077 | dso.root_module.addObject(obj); |
| 3078 | 3078 | // dso.link_relax = true; |
| 3079 | 3079 | |
| 3080 | 3080 | const check = dso.checkObject(); |
| ... | ... | @@ -3086,7 +3086,7 @@ fn testTlsDfStaticTls(b: *Build, opts: Options) *Step { |
| 3086 | 3086 | // TODO add -Wl,--no-relax |
| 3087 | 3087 | // { |
| 3088 | 3088 | // const dso = addSharedLibrary(b, opts, .{ .name = "a"}); |
| 3089 | | // dso.addObject(obj); |
| 3089 | // dso.root_module.addObject(obj); |
| 3090 | 3090 | // dso.link_relax = false; |
| 3091 | 3091 | |
| 3092 | 3092 | // const check = dso.checkObject(); |
| ... | ... | @@ -3128,8 +3128,8 @@ fn testTlsDso(b: *Build, opts: Options) *Step { |
| 3128 | 3128 | \\ return 0; |
| 3129 | 3129 | \\} |
| 3130 | 3130 | , &.{}); |
| 3131 | | exe.linkLibrary(dso); |
| 3132 | | exe.linkLibC(); |
| 3131 | exe.root_module.linkLibrary(dso); |
| 3132 | exe.root_module.link_libc = true; |
| 3133 | 3133 | |
| 3134 | 3134 | const run = addRunArtifact(exe); |
| 3135 | 3135 | run.expectStdOutEqual("5 3 5 3 5 3\n"); |
| ... | ... | @@ -3159,7 +3159,7 @@ fn testTlsGd(b: *Build, opts: Options) *Step { |
| 3159 | 3159 | , |
| 3160 | 3160 | .pic = true, |
| 3161 | 3161 | }); |
| 3162 | | main_o.linkLibC(); |
| 3162 | main_o.root_module.link_libc = true; |
| 3163 | 3163 | |
| 3164 | 3164 | const a_o = addObject(b, opts, .{ |
| 3165 | 3165 | .name = "a", |
| ... | ... | @@ -3184,17 +3184,17 @@ fn testTlsGd(b: *Build, opts: Options) *Step { |
| 3184 | 3184 | const exp_stdout = "1 2 3 4 5 6\n"; |
| 3185 | 3185 | |
| 3186 | 3186 | const dso1 = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 3187 | | dso1.addObject(a_o); |
| 3187 | dso1.root_module.addObject(a_o); |
| 3188 | 3188 | |
| 3189 | 3189 | const dso2 = addSharedLibrary(b, opts, .{ .name = "b" }); |
| 3190 | | dso2.addObject(b_o); |
| 3190 | dso2.root_module.addObject(b_o); |
| 3191 | 3191 | // dso2.link_relax = false; // TODO |
| 3192 | 3192 | |
| 3193 | 3193 | { |
| 3194 | 3194 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3195 | | exe.addObject(main_o); |
| 3196 | | exe.linkLibrary(dso1); |
| 3197 | | exe.linkLibrary(dso2); |
| 3195 | exe.root_module.addObject(main_o); |
| 3196 | exe.root_module.linkLibrary(dso1); |
| 3197 | exe.root_module.linkLibrary(dso2); |
| 3198 | 3198 | |
| 3199 | 3199 | const run = addRunArtifact(exe); |
| 3200 | 3200 | run.expectStdOutEqual(exp_stdout); |
| ... | ... | @@ -3203,10 +3203,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step { |
| 3203 | 3203 | |
| 3204 | 3204 | { |
| 3205 | 3205 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3206 | | exe.addObject(main_o); |
| 3206 | exe.root_module.addObject(main_o); |
| 3207 | 3207 | // exe.link_relax = false; // TODO |
| 3208 | | exe.linkLibrary(dso1); |
| 3209 | | exe.linkLibrary(dso2); |
| 3208 | exe.root_module.linkLibrary(dso1); |
| 3209 | exe.root_module.linkLibrary(dso2); |
| 3210 | 3210 | |
| 3211 | 3211 | const run = addRunArtifact(exe); |
| 3212 | 3212 | run.expectStdOutEqual(exp_stdout); |
| ... | ... | @@ -3216,9 +3216,9 @@ fn testTlsGd(b: *Build, opts: Options) *Step { |
| 3216 | 3216 | // https://github.com/ziglang/zig/issues/17430 ?? |
| 3217 | 3217 | // { |
| 3218 | 3218 | // const exe = addExecutable(b, opts, .{ .name = "main3"}); |
| 3219 | | // exe.addObject(main_o); |
| 3220 | | // exe.linkLibrary(dso1); |
| 3221 | | // exe.linkLibrary(dso2); |
| 3219 | // exe.root_module.addObject(main_o); |
| 3220 | // exe.root_module.linkLibrary(dso1); |
| 3221 | // exe.root_module.linkLibrary(dso2); |
| 3222 | 3222 | // exe.linkage = .static; |
| 3223 | 3223 | |
| 3224 | 3224 | // const run = addRunArtifact(exe); |
| ... | ... | @@ -3228,10 +3228,10 @@ fn testTlsGd(b: *Build, opts: Options) *Step { |
| 3228 | 3228 | |
| 3229 | 3229 | // { |
| 3230 | 3230 | // const exe = addExecutable(b, opts, .{ .name = "main4"}); |
| 3231 | | // exe.addObject(main_o); |
| 3231 | // exe.root_module.addObject(main_o); |
| 3232 | 3232 | // // exe.link_relax = false; // TODO |
| 3233 | | // exe.linkLibrary(dso1); |
| 3234 | | // exe.linkLibrary(dso2); |
| 3233 | // exe.root_module.linkLibrary(dso1); |
| 3234 | // exe.root_module.linkLibrary(dso2); |
| 3235 | 3235 | // exe.linkage = .static; |
| 3236 | 3236 | |
| 3237 | 3237 | // const run = addRunArtifact(exe); |
| ... | ... | @@ -3265,7 +3265,7 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step { |
| 3265 | 3265 | .c_source_flags = &.{"-fno-plt"}, |
| 3266 | 3266 | .pic = true, |
| 3267 | 3267 | }); |
| 3268 | | obj.linkLibC(); |
| 3268 | obj.root_module.link_libc = true; |
| 3269 | 3269 | |
| 3270 | 3270 | const a_so = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 3271 | 3271 | addCSourceBytes(a_so, |
| ... | ... | @@ -3284,10 +3284,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step { |
| 3284 | 3284 | |
| 3285 | 3285 | { |
| 3286 | 3286 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3287 | | exe.addObject(obj); |
| 3288 | | exe.linkLibrary(a_so); |
| 3289 | | exe.linkLibrary(b_so); |
| 3290 | | exe.linkLibC(); |
| 3287 | exe.root_module.addObject(obj); |
| 3288 | exe.root_module.linkLibrary(a_so); |
| 3289 | exe.root_module.linkLibrary(b_so); |
| 3290 | exe.root_module.link_libc = true; |
| 3291 | 3291 | |
| 3292 | 3292 | const run = addRunArtifact(exe); |
| 3293 | 3293 | run.expectStdOutEqual("1 2 3 4 5 6\n"); |
| ... | ... | @@ -3296,10 +3296,10 @@ fn testTlsGdNoPlt(b: *Build, opts: Options) *Step { |
| 3296 | 3296 | |
| 3297 | 3297 | { |
| 3298 | 3298 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3299 | | exe.addObject(obj); |
| 3300 | | exe.linkLibrary(a_so); |
| 3301 | | exe.linkLibrary(b_so); |
| 3302 | | exe.linkLibC(); |
| 3299 | exe.root_module.addObject(obj); |
| 3300 | exe.root_module.linkLibrary(a_so); |
| 3301 | exe.root_module.linkLibrary(b_so); |
| 3302 | exe.root_module.link_libc = true; |
| 3303 | 3303 | // exe.link_relax = false; // TODO |
| 3304 | 3304 | |
| 3305 | 3305 | const run = addRunArtifact(exe); |
| ... | ... | @@ -3329,7 +3329,7 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step { |
| 3329 | 3329 | , |
| 3330 | 3330 | .pic = true, |
| 3331 | 3331 | }); |
| 3332 | | a_o.linkLibC(); |
| 3332 | a_o.root_module.link_libc = true; |
| 3333 | 3333 | |
| 3334 | 3334 | const b_o = addObject(b, opts, .{ |
| 3335 | 3335 | .name = "b", |
| ... | ... | @@ -3342,12 +3342,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step { |
| 3342 | 3342 | |
| 3343 | 3343 | { |
| 3344 | 3344 | const dso = addSharedLibrary(b, opts, .{ .name = "a1" }); |
| 3345 | | dso.addObject(a_o); |
| 3345 | dso.root_module.addObject(a_o); |
| 3346 | 3346 | |
| 3347 | 3347 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3348 | | exe.addObject(b_o); |
| 3349 | | exe.linkLibrary(dso); |
| 3350 | | exe.linkLibC(); |
| 3348 | exe.root_module.addObject(b_o); |
| 3349 | exe.root_module.linkLibrary(dso); |
| 3350 | exe.root_module.link_libc = true; |
| 3351 | 3351 | |
| 3352 | 3352 | const run = addRunArtifact(exe); |
| 3353 | 3353 | run.expectStdOutEqual("1 2 3\n"); |
| ... | ... | @@ -3356,13 +3356,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step { |
| 3356 | 3356 | |
| 3357 | 3357 | { |
| 3358 | 3358 | const dso = addSharedLibrary(b, opts, .{ .name = "a2" }); |
| 3359 | | dso.addObject(a_o); |
| 3359 | dso.root_module.addObject(a_o); |
| 3360 | 3360 | // dso.link_relax = false; // TODO |
| 3361 | 3361 | |
| 3362 | 3362 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3363 | | exe.addObject(b_o); |
| 3364 | | exe.linkLibrary(dso); |
| 3365 | | exe.linkLibC(); |
| 3363 | exe.root_module.addObject(b_o); |
| 3364 | exe.root_module.linkLibrary(dso); |
| 3365 | exe.root_module.link_libc = true; |
| 3366 | 3366 | |
| 3367 | 3367 | const run = addRunArtifact(exe); |
| 3368 | 3368 | run.expectStdOutEqual("1 2 3\n"); |
| ... | ... | @@ -3371,12 +3371,12 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step { |
| 3371 | 3371 | |
| 3372 | 3372 | // { |
| 3373 | 3373 | // const dso = addSharedLibrary(b, opts, .{ .name = "a"}); |
| 3374 | | // dso.addObject(a_o); |
| 3374 | // dso.root_module.addObject(a_o); |
| 3375 | 3375 | // dso.link_z_nodlopen = true; |
| 3376 | 3376 | |
| 3377 | 3377 | // const exe = addExecutable(b, opts, .{ .name = "main"}); |
| 3378 | | // exe.addObject(b_o); |
| 3379 | | // exe.linkLibrary(dso); |
| 3378 | // exe.root_module.addObject(b_o); |
| 3379 | // exe.root_module.linkLibrary(dso); |
| 3380 | 3380 | |
| 3381 | 3381 | // const run = addRunArtifact(exe); |
| 3382 | 3382 | // run.expectStdOutEqual("1 2 3\n"); |
| ... | ... | @@ -3385,13 +3385,13 @@ fn testTlsGdToIe(b: *Build, opts: Options) *Step { |
| 3385 | 3385 | |
| 3386 | 3386 | // { |
| 3387 | 3387 | // const dso = addSharedLibrary(b, opts, .{ .name = "a"}); |
| 3388 | | // dso.addObject(a_o); |
| 3388 | // dso.root_module.addObject(a_o); |
| 3389 | 3389 | // dso.link_relax = false; |
| 3390 | 3390 | // dso.link_z_nodlopen = true; |
| 3391 | 3391 | |
| 3392 | 3392 | // const exe = addExecutable(b, opts, .{ .name = "main"}); |
| 3393 | | // exe.addObject(b_o); |
| 3394 | | // exe.linkLibrary(dso); |
| 3393 | // exe.root_module.addObject(b_o); |
| 3394 | // exe.root_module.linkLibrary(dso); |
| 3395 | 3395 | |
| 3396 | 3396 | // const run = addRunArtifact(exe); |
| 3397 | 3397 | // run.expectStdOutEqual("1 2 3\n"); |
| ... | ... | @@ -3417,7 +3417,7 @@ fn testTlsIe(b: *Build, opts: Options) *Step { |
| 3417 | 3417 | \\ printf("%d %d ", foo, bar); |
| 3418 | 3418 | \\} |
| 3419 | 3419 | , &.{}); |
| 3420 | | dso.linkLibC(); |
| 3420 | dso.root_module.link_libc = true; |
| 3421 | 3421 | |
| 3422 | 3422 | const main_o = addObject(b, opts, .{ |
| 3423 | 3423 | .name = "main", |
| ... | ... | @@ -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; |
| 3439 | 3439 | |
| 3440 | 3440 | const exp_stdout = "0 0 3 5 7\n"; |
| 3441 | 3441 | |
| 3442 | 3442 | { |
| 3443 | 3443 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3444 | | exe.addObject(main_o); |
| 3445 | | exe.linkLibrary(dso); |
| 3446 | | exe.linkLibC(); |
| 3444 | exe.root_module.addObject(main_o); |
| 3445 | exe.root_module.linkLibrary(dso); |
| 3446 | exe.root_module.link_libc = true; |
| 3447 | 3447 | |
| 3448 | 3448 | const run = addRunArtifact(exe); |
| 3449 | 3449 | run.expectStdOutEqual(exp_stdout); |
| ... | ... | @@ -3452,9 +3452,9 @@ fn testTlsIe(b: *Build, opts: Options) *Step { |
| 3452 | 3452 | |
| 3453 | 3453 | { |
| 3454 | 3454 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3455 | | exe.addObject(main_o); |
| 3456 | | exe.linkLibrary(dso); |
| 3457 | | exe.linkLibC(); |
| 3455 | exe.root_module.addObject(main_o); |
| 3456 | exe.root_module.linkLibrary(dso); |
| 3457 | exe.root_module.link_libc = true; |
| 3458 | 3458 | // exe.link_relax = false; // TODO |
| 3459 | 3459 | |
| 3460 | 3460 | const run = addRunArtifact(exe); |
| ... | ... | @@ -3500,17 +3500,17 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step { |
| 3500 | 3500 | , |
| 3501 | 3501 | .pic = true, |
| 3502 | 3502 | }); |
| 3503 | | c_o.linkLibC(); |
| 3503 | c_o.root_module.link_libc = true; |
| 3504 | 3504 | |
| 3505 | 3505 | { |
| 3506 | 3506 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 3507 | | dso.addObject(a_o); |
| 3508 | | dso.addObject(b_o); |
| 3507 | dso.root_module.addObject(a_o); |
| 3508 | dso.root_module.addObject(b_o); |
| 3509 | 3509 | |
| 3510 | 3510 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3511 | | exe.addObject(c_o); |
| 3512 | | exe.linkLibrary(dso); |
| 3513 | | exe.linkLibC(); |
| 3511 | exe.root_module.addObject(c_o); |
| 3512 | exe.root_module.linkLibrary(dso); |
| 3513 | exe.root_module.link_libc = true; |
| 3514 | 3514 | |
| 3515 | 3515 | const run = addRunArtifact(exe); |
| 3516 | 3516 | run.expectStdOutEqual("42 1 2 3\n"); |
| ... | ... | @@ -3519,10 +3519,10 @@ fn testTlsLargeAlignment(b: *Build, opts: Options) *Step { |
| 3519 | 3519 | |
| 3520 | 3520 | { |
| 3521 | 3521 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3522 | | exe.addObject(a_o); |
| 3523 | | exe.addObject(b_o); |
| 3524 | | exe.addObject(c_o); |
| 3525 | | exe.linkLibC(); |
| 3522 | exe.root_module.addObject(a_o); |
| 3523 | exe.root_module.addObject(b_o); |
| 3524 | exe.root_module.addObject(c_o); |
| 3525 | exe.root_module.link_libc = true; |
| 3526 | 3526 | |
| 3527 | 3527 | const run = addRunArtifact(exe); |
| 3528 | 3528 | run.expectStdOutEqual("42 1 2 3\n"); |
| ... | ... | @@ -3555,7 +3555,7 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step { |
| 3555 | 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 | 3559 | // Disabled to work around the ELF linker crashing. |
| 3560 | 3560 | // Can be reproduced on a x86_64-linux host by commenting out the line below. |
| 3561 | 3561 | exe.root_module.sanitize_c = .off; |
| ... | ... | @@ -3580,7 +3580,7 @@ fn testTlsLargeStaticImage(b: *Build, opts: Options) *Step { |
| 3580 | 3580 | \\} |
| 3581 | 3581 | , &.{}); |
| 3582 | 3582 | exe.root_module.pic = true; |
| 3583 | | exe.linkLibC(); |
| 3583 | exe.root_module.link_libc = true; |
| 3584 | 3584 | |
| 3585 | 3585 | const run = addRunArtifact(exe); |
| 3586 | 3586 | run.expectStdOutEqual("1 2 3 0 5\n"); |
| ... | ... | @@ -3609,7 +3609,7 @@ fn testTlsLd(b: *Build, opts: Options) *Step { |
| 3609 | 3609 | .c_source_flags = &.{"-ftls-model=local-dynamic"}, |
| 3610 | 3610 | .pic = true, |
| 3611 | 3611 | }); |
| 3612 | | main_o.linkLibC(); |
| 3612 | main_o.root_module.link_libc = true; |
| 3613 | 3613 | |
| 3614 | 3614 | const a_o = addObject(b, opts, .{ |
| 3615 | 3615 | .name = "a", |
| ... | ... | @@ -3622,9 +3622,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step { |
| 3622 | 3622 | |
| 3623 | 3623 | { |
| 3624 | 3624 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3625 | | exe.addObject(main_o); |
| 3626 | | exe.addObject(a_o); |
| 3627 | | exe.linkLibC(); |
| 3625 | exe.root_module.addObject(main_o); |
| 3626 | exe.root_module.addObject(a_o); |
| 3627 | exe.root_module.link_libc = true; |
| 3628 | 3628 | |
| 3629 | 3629 | const run = addRunArtifact(exe); |
| 3630 | 3630 | run.expectStdOutEqual(exp_stdout); |
| ... | ... | @@ -3633,9 +3633,9 @@ fn testTlsLd(b: *Build, opts: Options) *Step { |
| 3633 | 3633 | |
| 3634 | 3634 | { |
| 3635 | 3635 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3636 | | exe.addObject(main_o); |
| 3637 | | exe.addObject(a_o); |
| 3638 | | exe.linkLibC(); |
| 3636 | exe.root_module.addObject(main_o); |
| 3637 | exe.root_module.addObject(a_o); |
| 3638 | exe.root_module.link_libc = true; |
| 3639 | 3639 | // exe.link_relax = false; // TODO |
| 3640 | 3640 | |
| 3641 | 3641 | const run = addRunArtifact(exe); |
| ... | ... | @@ -3668,8 +3668,8 @@ fn testTlsLdDso(b: *Build, opts: Options) *Step { |
| 3668 | 3668 | \\ return 0; |
| 3669 | 3669 | \\} |
| 3670 | 3670 | , &.{}); |
| 3671 | | exe.linkLibrary(dso); |
| 3672 | | exe.linkLibC(); |
| 3671 | exe.root_module.linkLibrary(dso); |
| 3672 | exe.root_module.link_libc = true; |
| 3673 | 3673 | |
| 3674 | 3674 | const run = addRunArtifact(exe); |
| 3675 | 3675 | run.expectStdOutEqual("1 2\n"); |
| ... | ... | @@ -3699,7 +3699,7 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step { |
| 3699 | 3699 | .c_source_flags = &.{ "-ftls-model=local-dynamic", "-fno-plt" }, |
| 3700 | 3700 | .pic = true, |
| 3701 | 3701 | }); |
| 3702 | | a_o.linkLibC(); |
| 3702 | a_o.root_module.link_libc = true; |
| 3703 | 3703 | |
| 3704 | 3704 | const b_o = addObject(b, opts, .{ |
| 3705 | 3705 | .name = "b", |
| ... | ... | @@ -3710,9 +3710,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step { |
| 3710 | 3710 | |
| 3711 | 3711 | { |
| 3712 | 3712 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 3713 | | exe.addObject(a_o); |
| 3714 | | exe.addObject(b_o); |
| 3715 | | exe.linkLibC(); |
| 3713 | exe.root_module.addObject(a_o); |
| 3714 | exe.root_module.addObject(b_o); |
| 3715 | exe.root_module.link_libc = true; |
| 3716 | 3716 | |
| 3717 | 3717 | const run = addRunArtifact(exe); |
| 3718 | 3718 | run.expectStdOutEqual("3 5 3 5\n"); |
| ... | ... | @@ -3721,9 +3721,9 @@ fn testTlsLdNoPlt(b: *Build, opts: Options) *Step { |
| 3721 | 3721 | |
| 3722 | 3722 | { |
| 3723 | 3723 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 3724 | | exe.addObject(a_o); |
| 3725 | | exe.addObject(b_o); |
| 3726 | | exe.linkLibC(); |
| 3724 | exe.root_module.addObject(a_o); |
| 3725 | exe.root_module.addObject(b_o); |
| 3726 | exe.root_module.link_libc = true; |
| 3727 | 3727 | // exe.link_relax = false; // TODO |
| 3728 | 3728 | |
| 3729 | 3729 | const run = addRunArtifact(exe); |
| ... | ... | @@ -3756,7 +3756,7 @@ fn testTlsNoPic(b: *Build, opts: Options) *Step { |
| 3756 | 3756 | \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo; |
| 3757 | 3757 | , &.{}); |
| 3758 | 3758 | exe.root_module.pic = false; |
| 3759 | | exe.linkLibC(); |
| 3759 | exe.root_module.link_libc = true; |
| 3760 | 3760 | |
| 3761 | 3761 | const run = addRunArtifact(exe); |
| 3762 | 3762 | run.expectStdOutEqual("3 5 3 5\n"); |
| ... | ... | @@ -3784,7 +3784,7 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step { |
| 3784 | 3784 | \\ return NULL; |
| 3785 | 3785 | \\} |
| 3786 | 3786 | , &.{}); |
| 3787 | | dso.linkLibC(); |
| 3787 | dso.root_module.link_libc = true; |
| 3788 | 3788 | |
| 3789 | 3789 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3790 | 3790 | addCSourceBytes(exe, |
| ... | ... | @@ -3811,8 +3811,8 @@ fn testTlsOffsetAlignment(b: *Build, opts: Options) *Step { |
| 3811 | 3811 | \\ pthread_join(thread, NULL); |
| 3812 | 3812 | \\} |
| 3813 | 3813 | , &.{}); |
| 3814 | | exe.addRPath(dso.getEmittedBinDirectory()); |
| 3815 | | exe.linkLibC(); |
| 3814 | exe.root_module.addRPath(dso.getEmittedBinDirectory()); |
| 3815 | exe.root_module.link_libc = true; |
| 3816 | 3816 | exe.root_module.pic = true; |
| 3817 | 3817 | |
| 3818 | 3818 | const run = addRunArtifact(exe); |
| ... | ... | @@ -3842,14 +3842,14 @@ fn testTlsPic(b: *Build, opts: Options) *Step { |
| 3842 | 3842 | , |
| 3843 | 3843 | .pic = true, |
| 3844 | 3844 | }); |
| 3845 | | obj.linkLibC(); |
| 3845 | obj.root_module.link_libc = true; |
| 3846 | 3846 | |
| 3847 | 3847 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3848 | 3848 | addCSourceBytes(exe, |
| 3849 | 3849 | \\__attribute__((tls_model("global-dynamic"))) _Thread_local int foo = 3; |
| 3850 | 3850 | , &.{}); |
| 3851 | | exe.addObject(obj); |
| 3852 | | exe.linkLibC(); |
| 3851 | exe.root_module.addObject(obj); |
| 3852 | exe.root_module.link_libc = true; |
| 3853 | 3853 | |
| 3854 | 3854 | const run = addRunArtifact(exe); |
| 3855 | 3855 | run.expectStdOutEqual("3 5 3 5\n"); |
| ... | ... | @@ -3889,14 +3889,14 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step { |
| 3889 | 3889 | , |
| 3890 | 3890 | .pic = true, |
| 3891 | 3891 | }); |
| 3892 | | c_o.linkLibC(); |
| 3892 | c_o.root_module.link_libc = true; |
| 3893 | 3893 | |
| 3894 | 3894 | { |
| 3895 | 3895 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3896 | | exe.addObject(a_o); |
| 3897 | | exe.addObject(b_o); |
| 3898 | | exe.addObject(c_o); |
| 3899 | | exe.linkLibC(); |
| 3896 | exe.root_module.addObject(a_o); |
| 3897 | exe.root_module.addObject(b_o); |
| 3898 | exe.root_module.addObject(c_o); |
| 3899 | exe.root_module.link_libc = true; |
| 3900 | 3900 | |
| 3901 | 3901 | const run = addRunArtifact(exe); |
| 3902 | 3902 | run.expectStdOutEqual("42\n"); |
| ... | ... | @@ -3905,13 +3905,13 @@ fn testTlsSmallAlignment(b: *Build, opts: Options) *Step { |
| 3905 | 3905 | |
| 3906 | 3906 | { |
| 3907 | 3907 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 3908 | | dso.addObject(a_o); |
| 3909 | | dso.addObject(b_o); |
| 3908 | dso.root_module.addObject(a_o); |
| 3909 | dso.root_module.addObject(b_o); |
| 3910 | 3910 | |
| 3911 | 3911 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 3912 | | exe.addObject(c_o); |
| 3913 | | exe.linkLibrary(dso); |
| 3914 | | exe.linkLibC(); |
| 3912 | exe.root_module.addObject(c_o); |
| 3913 | exe.root_module.linkLibrary(dso); |
| 3914 | exe.root_module.link_libc = true; |
| 3915 | 3915 | |
| 3916 | 3916 | const run = addRunArtifact(exe); |
| 3917 | 3917 | run.expectStdOutEqual("42\n"); |
| ... | ... | @@ -3939,7 +3939,7 @@ fn testTlsStatic(b: *Build, opts: Options) *Step { |
| 3939 | 3939 | \\ return 0; |
| 3940 | 3940 | \\} |
| 3941 | 3941 | , &.{}); |
| 3942 | | exe.linkLibC(); |
| 3942 | exe.root_module.link_libc = true; |
| 3943 | 3943 | |
| 3944 | 3944 | const run = addRunArtifact(exe); |
| 3945 | 3945 | run.expectStdOutEqual( |
| ... | ... | @@ -3969,8 +3969,8 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step { |
| 3969 | 3969 | \\ return foo; |
| 3970 | 3970 | \\} |
| 3971 | 3971 | , &.{}); |
| 3972 | | exe.linkLibrary(dylib); |
| 3973 | | exe.linkLibC(); |
| 3972 | exe.root_module.linkLibrary(dylib); |
| 3973 | exe.root_module.link_libc = true; |
| 3974 | 3974 | |
| 3975 | 3975 | expectLinkErrors(exe, test_step, .{ |
| 3976 | 3976 | .contains = "error: failed to parse shared library: BadMagic", |
| ... | ... | @@ -3993,7 +3993,7 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step { |
| 3993 | 3993 | , |
| 3994 | 3994 | .c_source_flags = &.{"-ffunction-sections"}, |
| 3995 | 3995 | }); |
| 3996 | | obj1.linkLibC(); |
| 3996 | obj1.root_module.link_libc = true; |
| 3997 | 3997 | |
| 3998 | 3998 | const obj2 = addObject(b, opts, .{ |
| 3999 | 3999 | .name = "b", |
| ... | ... | @@ -4007,12 +4007,12 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step { |
| 4007 | 4007 | , |
| 4008 | 4008 | .c_source_flags = &.{"-ffunction-sections"}, |
| 4009 | 4009 | }); |
| 4010 | | obj2.linkLibC(); |
| 4010 | obj2.root_module.link_libc = true; |
| 4011 | 4011 | |
| 4012 | 4012 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 4013 | | exe.addObject(obj1); |
| 4014 | | exe.addObject(obj2); |
| 4015 | | exe.linkLibC(); |
| 4013 | exe.root_module.addObject(obj1); |
| 4014 | exe.root_module.addObject(obj2); |
| 4015 | exe.root_module.link_libc = true; |
| 4016 | 4016 | |
| 4017 | 4017 | expectLinkErrors(exe, test_step, .{ .exact = &.{ |
| 4018 | 4018 | "error: undefined symbol: foo", |
| ... | ... | @@ -4037,12 +4037,12 @@ fn testWeakExports(b: *Build, opts: Options) *Step { |
| 4037 | 4037 | , |
| 4038 | 4038 | .pic = true, |
| 4039 | 4039 | }); |
| 4040 | | obj.linkLibC(); |
| 4040 | obj.root_module.link_libc = true; |
| 4041 | 4041 | |
| 4042 | 4042 | { |
| 4043 | 4043 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 4044 | | dso.addObject(obj); |
| 4045 | | dso.linkLibC(); |
| 4044 | dso.root_module.addObject(obj); |
| 4045 | dso.root_module.link_libc = true; |
| 4046 | 4046 | |
| 4047 | 4047 | const check = dso.checkObject(); |
| 4048 | 4048 | check.checkInDynamicSymtab(); |
| ... | ... | @@ -4052,8 +4052,8 @@ fn testWeakExports(b: *Build, opts: Options) *Step { |
| 4052 | 4052 | |
| 4053 | 4053 | { |
| 4054 | 4054 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 4055 | | exe.addObject(obj); |
| 4056 | | exe.linkLibC(); |
| 4055 | exe.root_module.addObject(obj); |
| 4056 | exe.root_module.link_libc = true; |
| 4057 | 4057 | |
| 4058 | 4058 | const check = exe.checkObject(); |
| 4059 | 4059 | check.checkInDynamicSymtab(); |
| ... | ... | @@ -4084,8 +4084,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step { |
| 4084 | 4084 | \\int bar(); |
| 4085 | 4085 | \\int main() { printf("bar=%d\n", bar()); } |
| 4086 | 4086 | , &.{}); |
| 4087 | | exe.linkLibrary(dso); |
| 4088 | | exe.linkLibC(); |
| 4087 | exe.root_module.linkLibrary(dso); |
| 4088 | exe.root_module.link_libc = true; |
| 4089 | 4089 | |
| 4090 | 4090 | const run = addRunArtifact(exe); |
| 4091 | 4091 | run.expectStdOutEqual("bar=-1\n"); |
| ... | ... | @@ -4100,8 +4100,8 @@ fn testWeakUndefsDso(b: *Build, opts: Options) *Step { |
| 4100 | 4100 | \\int bar(); |
| 4101 | 4101 | \\int main() { printf("bar=%d\n", bar()); } |
| 4102 | 4102 | , &.{}); |
| 4103 | | exe.linkLibrary(dso); |
| 4104 | | exe.linkLibC(); |
| 4103 | exe.root_module.linkLibrary(dso); |
| 4104 | exe.root_module.link_libc = true; |
| 4105 | 4105 | |
| 4106 | 4106 | const run = addRunArtifact(exe); |
| 4107 | 4107 | run.expectStdOutEqual("bar=5\n"); |
| ... | ... | @@ -4122,7 +4122,7 @@ fn testZNow(b: *Build, opts: Options) *Step { |
| 4122 | 4122 | |
| 4123 | 4123 | { |
| 4124 | 4124 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 4125 | | dso.addObject(obj); |
| 4125 | dso.root_module.addObject(obj); |
| 4126 | 4126 | |
| 4127 | 4127 | const check = dso.checkObject(); |
| 4128 | 4128 | check.checkInDynamicSection(); |
| ... | ... | @@ -4132,7 +4132,7 @@ fn testZNow(b: *Build, opts: Options) *Step { |
| 4132 | 4132 | |
| 4133 | 4133 | { |
| 4134 | 4134 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 4135 | | dso.addObject(obj); |
| 4135 | dso.root_module.addObject(obj); |
| 4136 | 4136 | dso.link_z_lazy = true; |
| 4137 | 4137 | |
| 4138 | 4138 | const check = dso.checkObject(); |
| ... | ... | @@ -4150,7 +4150,7 @@ fn testZStackSize(b: *Build, opts: Options) *Step { |
| 4150 | 4150 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| 4151 | 4151 | addCSourceBytes(exe, "int main() { return 0; }", &.{}); |
| 4152 | 4152 | exe.stack_size = 0x800000; |
| 4153 | | exe.linkLibC(); |
| 4153 | exe.root_module.link_libc = true; |
| 4154 | 4154 | |
| 4155 | 4155 | const check = exe.checkObject(); |
| 4156 | 4156 | check.checkInHeaders(); |
| ... | ... | @@ -4202,8 +4202,8 @@ fn testZText(b: *Build, opts: Options) *Step { |
| 4202 | 4202 | }); |
| 4203 | 4203 | |
| 4204 | 4204 | const dso = addSharedLibrary(b, opts, .{ .name = "a" }); |
| 4205 | | dso.addObject(a_o); |
| 4206 | | dso.addObject(b_o); |
| 4205 | dso.root_module.addObject(a_o); |
| 4206 | dso.root_module.addObject(b_o); |
| 4207 | 4207 | dso.link_z_notext = true; |
| 4208 | 4208 | |
| 4209 | 4209 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| ... | ... | @@ -4214,8 +4214,8 @@ fn testZText(b: *Build, opts: Options) *Step { |
| 4214 | 4214 | \\ printf("%d\n", fnn()); |
| 4215 | 4215 | \\} |
| 4216 | 4216 | , &.{}); |
| 4217 | | exe.linkLibrary(dso); |
| 4218 | | exe.linkLibC(); |
| 4217 | exe.root_module.linkLibrary(dso); |
| 4218 | exe.root_module.link_libc = true; |
| 4219 | 4219 | |
| 4220 | 4220 | const run = addRunArtifact(exe); |
| 4221 | 4221 | run.expectStdOutEqual("3\n"); |