| ... | @@ -35,6 +35,7 @@ pub fn build(b: *Build) void { | ... | @@ -35,6 +35,7 @@ pub fn build(b: *Build) void { |
| 35 | elf_step.dependOn(testCommonSymbols(b, .{ .target = musl_target })); | 35 | elf_step.dependOn(testCommonSymbols(b, .{ .target = musl_target })); |
| 36 | elf_step.dependOn(testCommonSymbolsInArchive(b, .{ .target = musl_target })); | 36 | elf_step.dependOn(testCommonSymbolsInArchive(b, .{ .target = musl_target })); |
| 37 | elf_step.dependOn(testEmptyObject(b, .{ .target = musl_target })); | 37 | elf_step.dependOn(testEmptyObject(b, .{ .target = musl_target })); |
| | 38 | elf_step.dependOn(testEntryPoint(b, .{ .target = musl_target })); |
| 38 | elf_step.dependOn(testGcSections(b, .{ .target = musl_target })); | 39 | elf_step.dependOn(testGcSections(b, .{ .target = musl_target })); |
| 39 | elf_step.dependOn(testLinkingC(b, .{ .target = musl_target })); | 40 | elf_step.dependOn(testLinkingC(b, .{ .target = musl_target })); |
| 40 | elf_step.dependOn(testLinkingCpp(b, .{ .target = musl_target })); | 41 | elf_step.dependOn(testLinkingCpp(b, .{ .target = musl_target })); |
| ... | @@ -48,12 +49,9 @@ pub fn build(b: *Build) void { | ... | @@ -48,12 +49,9 @@ pub fn build(b: *Build) void { |
| 48 | elf_step.dependOn(testCopyrelAlignment(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); | 49 | elf_step.dependOn(testCopyrelAlignment(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 49 | elf_step.dependOn(testDsoPlt(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); | 50 | elf_step.dependOn(testDsoPlt(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 50 | elf_step.dependOn(testDsoUndef(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); | 51 | elf_step.dependOn(testDsoUndef(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| | 52 | elf_step.dependOn(testExportDynamic(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 51 | elf_step.dependOn(testLargeAlignmentDso(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); | 53 | elf_step.dependOn(testLargeAlignmentDso(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 52 | | 54 | elf_step.dependOn(testLargeAlignmentExe(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 53 | for (&[_]CrossTarget{ musl_target, glibc_target }) |target| { | | |
| 54 | elf_step.dependOn(testEntryPoint(b, .{ .target = target })); | | |
| 55 | elf_step.dependOn(testLargeAlignmentExe(b, .{ .target = target })); | | |
| 56 | } | | |
| 57 | } | 55 | } |
| 58 | | 56 | |
| 59 | fn testAbsSymbols(b: *Build, opts: Options) *Step { | 57 | fn testAbsSymbols(b: *Build, opts: Options) *Step { |
| ... | @@ -592,7 +590,9 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { | ... | @@ -592,7 +590,9 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { |
| 592 | } | 590 | } |
| 593 | | 591 | |
| 594 | { | 592 | { |
| 595 | // TODO if I rename this to `main` it fails | 593 | // TODO looks like not assigning a unique name to this executable will |
| | 594 | // cause an artifact collision taking the cached executable from the above |
| | 595 | // step instead of generating a new one. |
| 596 | const exe = addExecutable(b, "other", opts); | 596 | const exe = addExecutable(b, "other", opts); |
| 597 | exe.addObject(a_o); | 597 | exe.addObject(a_o); |
| 598 | exe.addObject(b_o); | 598 | exe.addObject(b_o); |
| ... | @@ -608,6 +608,48 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { | ... | @@ -608,6 +608,48 @@ fn testEntryPoint(b: *Build, opts: Options) *Step { |
| 608 | return test_step; | 608 | return test_step; |
| 609 | } | 609 | } |
| 610 | | 610 | |
| | 611 | fn testExportDynamic(b: *Build, opts: Options) *Step { |
| | 612 | const test_step = addTestStep(b, "export-dynamic", opts); |
| | 613 | |
| | 614 | const obj = addObject(b, "obj", opts); |
| | 615 | addAsmSourceBytes(obj, |
| | 616 | \\.text |
| | 617 | \\ .globl foo |
| | 618 | \\ .hidden foo |
| | 619 | \\foo: |
| | 620 | \\ nop |
| | 621 | \\ .globl bar |
| | 622 | \\bar: |
| | 623 | \\ nop |
| | 624 | \\ .globl _start |
| | 625 | \\_start: |
| | 626 | \\ nop |
| | 627 | ); |
| | 628 | |
| | 629 | const dso = addSharedLibrary(b, "a", opts); |
| | 630 | addCSourceBytes(dso, "int baz = 10;", &.{"-fPIC"}); |
| | 631 | |
| | 632 | const exe = addExecutable(b, "main", opts); |
| | 633 | addCSourceBytes(exe, |
| | 634 | \\extern int baz; |
| | 635 | \\int callBaz() { |
| | 636 | \\ return baz; |
| | 637 | \\} |
| | 638 | , &.{}); |
| | 639 | exe.addObject(obj); |
| | 640 | exe.linkLibrary(dso); |
| | 641 | exe.rdynamic = true; |
| | 642 | |
| | 643 | const check = exe.checkObject(); |
| | 644 | check.checkInDynamicSymtab(); |
| | 645 | check.checkContains("bar"); |
| | 646 | check.checkInDynamicSymtab(); |
| | 647 | check.checkContains("_start"); |
| | 648 | test_step.dependOn(&check.step); |
| | 649 | |
| | 650 | return test_step; |
| | 651 | } |
| | 652 | |
| 611 | fn testGcSections(b: *Build, opts: Options) *Step { | 653 | fn testGcSections(b: *Build, opts: Options) *Step { |
| 612 | const test_step = addTestStep(b, "gc-sections", opts); | 654 | const test_step = addTestStep(b, "gc-sections", opts); |
| 613 | | 655 | |