| ... | ... | @@ -51,6 +51,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 51 | 51 | elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target })); |
| 52 | 52 | elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target })); |
| 53 | 53 | elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target })); |
| 54 | elf_step.dependOn(testRelocatableEhFrameComdatHeavy(b, .{ .target = musl_target })); |
| 54 | 55 | elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target })); |
| 55 | 56 | |
| 56 | 57 | // Exercise linker in ar mode |
| ... | ... | @@ -2723,86 +2724,87 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step { |
| 2723 | 2724 | fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2724 | 2725 | const test_step = addTestStep(b, "relocatable-eh-frame", opts); |
| 2725 | 2726 | |
| 2726 | | { |
| 2727 | | const obj = addObject(b, opts, .{ |
| 2728 | | .name = "obj1", |
| 2729 | | .cpp_source_bytes = |
| 2730 | | \\#include <stdexcept> |
| 2731 | | \\int try_me() { |
| 2732 | | \\ throw std::runtime_error("Oh no!"); |
| 2733 | | \\} |
| 2734 | | , |
| 2735 | | }); |
| 2736 | | addCppSourceBytes(obj, |
| 2737 | | \\extern int try_me(); |
| 2738 | | \\int try_again() { |
| 2739 | | \\ return try_me(); |
| 2740 | | \\} |
| 2741 | | , &.{}); |
| 2742 | | obj.linkLibCpp(); |
| 2727 | const obj = addObject(b, opts, .{ |
| 2728 | .name = "obj1", |
| 2729 | .cpp_source_bytes = |
| 2730 | \\#include <stdexcept> |
| 2731 | \\int try_me() { |
| 2732 | \\ throw std::runtime_error("Oh no!"); |
| 2733 | \\} |
| 2734 | , |
| 2735 | }); |
| 2736 | addCppSourceBytes(obj, |
| 2737 | \\extern int try_me(); |
| 2738 | \\int try_again() { |
| 2739 | \\ return try_me(); |
| 2740 | \\} |
| 2741 | , &.{}); |
| 2742 | obj.linkLibCpp(); |
| 2743 | 2743 | |
| 2744 | | const exe = addExecutable(b, opts, .{ .name = "test1" }); |
| 2745 | | addCppSourceBytes(exe, |
| 2746 | | \\#include <iostream> |
| 2747 | | \\#include <stdexcept> |
| 2748 | | \\extern int try_again(); |
| 2749 | | \\int main() { |
| 2750 | | \\ try { |
| 2751 | | \\ try_again(); |
| 2752 | | \\ } catch (const std::exception &e) { |
| 2753 | | \\ std::cout << "exception=" << e.what(); |
| 2754 | | \\ } |
| 2755 | | \\ return 0; |
| 2756 | | \\} |
| 2757 | | , &.{}); |
| 2758 | | exe.addObject(obj); |
| 2759 | | exe.linkLibCpp(); |
| 2744 | const exe = addExecutable(b, opts, .{ .name = "test1" }); |
| 2745 | addCppSourceBytes(exe, |
| 2746 | \\#include <iostream> |
| 2747 | \\#include <stdexcept> |
| 2748 | \\extern int try_again(); |
| 2749 | \\int main() { |
| 2750 | \\ try { |
| 2751 | \\ try_again(); |
| 2752 | \\ } catch (const std::exception &e) { |
| 2753 | \\ std::cout << "exception=" << e.what(); |
| 2754 | \\ } |
| 2755 | \\ return 0; |
| 2756 | \\} |
| 2757 | , &.{}); |
| 2758 | exe.addObject(obj); |
| 2759 | exe.linkLibCpp(); |
| 2760 | 2760 | |
| 2761 | | const run = addRunArtifact(exe); |
| 2762 | | run.expectStdOutEqual("exception=Oh no!"); |
| 2763 | | test_step.dependOn(&run.step); |
| 2764 | | } |
| 2761 | const run = addRunArtifact(exe); |
| 2762 | run.expectStdOutEqual("exception=Oh no!"); |
| 2763 | test_step.dependOn(&run.step); |
| 2765 | 2764 | |
| 2766 | | { |
| 2767 | | // Let's make the object file COMDAT group heavy! |
| 2768 | | const obj = addObject(b, opts, .{ |
| 2769 | | .name = "obj2", |
| 2770 | | .cpp_source_bytes = |
| 2771 | | \\#include <stdexcept> |
| 2772 | | \\int try_me() { |
| 2773 | | \\ throw std::runtime_error("Oh no!"); |
| 2774 | | \\} |
| 2775 | | , |
| 2776 | | }); |
| 2777 | | addCppSourceBytes(obj, |
| 2778 | | \\extern int try_me(); |
| 2779 | | \\int try_again() { |
| 2780 | | \\ return try_me(); |
| 2781 | | \\} |
| 2782 | | , &.{}); |
| 2783 | | addCppSourceBytes(obj, |
| 2784 | | \\#include <iostream> |
| 2785 | | \\#include <stdexcept> |
| 2786 | | \\extern int try_again(); |
| 2787 | | \\int main() { |
| 2788 | | \\ try { |
| 2789 | | \\ try_again(); |
| 2790 | | \\ } catch (const std::exception &e) { |
| 2791 | | \\ std::cout << "exception=" << e.what(); |
| 2792 | | \\ } |
| 2793 | | \\ return 0; |
| 2794 | | \\} |
| 2795 | | , &.{}); |
| 2796 | | obj.linkLibCpp(); |
| 2765 | return test_step; |
| 2766 | } |
| 2797 | 2767 | |
| 2798 | | const exe = addExecutable(b, opts, .{ .name = "test2" }); |
| 2799 | | exe.addObject(obj); |
| 2800 | | exe.linkLibCpp(); |
| 2768 | fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step { |
| 2769 | const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts); |
| 2801 | 2770 | |
| 2802 | | const run = addRunArtifact(exe); |
| 2803 | | run.expectStdOutEqual("exception=Oh no!"); |
| 2804 | | test_step.dependOn(&run.step); |
| 2805 | | } |
| 2771 | const obj = addObject(b, opts, .{ |
| 2772 | .name = "obj2", |
| 2773 | .cpp_source_bytes = |
| 2774 | \\#include <stdexcept> |
| 2775 | \\int try_me() { |
| 2776 | \\ throw std::runtime_error("Oh no!"); |
| 2777 | \\} |
| 2778 | , |
| 2779 | }); |
| 2780 | addCppSourceBytes(obj, |
| 2781 | \\extern int try_me(); |
| 2782 | \\int try_again() { |
| 2783 | \\ return try_me(); |
| 2784 | \\} |
| 2785 | , &.{}); |
| 2786 | addCppSourceBytes(obj, |
| 2787 | \\#include <iostream> |
| 2788 | \\#include <stdexcept> |
| 2789 | \\extern int try_again(); |
| 2790 | \\int main() { |
| 2791 | \\ try { |
| 2792 | \\ try_again(); |
| 2793 | \\ } catch (const std::exception &e) { |
| 2794 | \\ std::cout << "exception=" << e.what(); |
| 2795 | \\ } |
| 2796 | \\ return 0; |
| 2797 | \\} |
| 2798 | , &.{}); |
| 2799 | obj.linkLibCpp(); |
| 2800 | |
| 2801 | const exe = addExecutable(b, opts, .{ .name = "test2" }); |
| 2802 | exe.addObject(obj); |
| 2803 | exe.linkLibCpp(); |
| 2804 | |
| 2805 | const run = addRunArtifact(exe); |
| 2806 | run.expectStdOutEqual("exception=Oh no!"); |
| 2807 | test_step.dependOn(&run.step); |
| 2806 | 2808 | |
| 2807 | 2809 | return test_step; |
| 2808 | 2810 | } |