authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-21 21:05:46-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-23 16:27:39-07:00
logf2efe051558cb7cfac6f489eb4e3adbfcbb44e4f
tree59c090aab5e61fb4ed8dd9597db517428b881c55
parent3deb9ab30abcc418758b0365d2c0596a610555b4

use deterministic order in relocatable-eh-frame tests

This test does not pass in master branch either if you flip the object order around.

2 files changed, 33 insertions(+), 10 deletions(-)

src/Compilation.zig+1-1
...@@ -6059,7 +6059,7 @@ test "classifyFileExt" {...@@ -6059,7 +6059,7 @@ test "classifyFileExt" {
6059 try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));6059 try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
6060}6060}
60616061
6062pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8) !Path {6062fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8) !Path {
6063 return (try crtFilePath(&comp.crt_files, basename)) orelse {6063 return (try crtFilePath(&comp.crt_files, basename)) orelse {
6064 const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable;6064 const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable;
6065 const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir;6065 const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir;
test/link/elf.zig+32-9
...@@ -2724,7 +2724,7 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {...@@ -2724,7 +2724,7 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {
2724fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {2724fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2725 const test_step = addTestStep(b, "relocatable-eh-frame", opts);2725 const test_step = addTestStep(b, "relocatable-eh-frame", opts);
27262726
2727 const obj = addObject(b, opts, .{2727 const obj1 = addObject(b, opts, .{
2728 .name = "obj1",2728 .name = "obj1",
2729 .cpp_source_bytes =2729 .cpp_source_bytes =
2730 \\#include <stdexcept>2730 \\#include <stdexcept>
...@@ -2733,12 +2733,21 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2733,12 +2733,21 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2733 \\}2733 \\}
2734 ,2734 ,
2735 });2735 });
2736 addCppSourceBytes(obj,2736 obj1.linkLibCpp();
2737 const obj2 = addObject(b, opts, .{
2738 .name = "obj2",
2739 .cpp_source_bytes =
2737 \\extern int try_me();2740 \\extern int try_me();
2738 \\int try_again() {2741 \\int try_again() {
2739 \\ return try_me();2742 \\ return try_me();
2740 \\}2743 \\}
2741 , &.{});2744 ,
2745 });
2746 obj2.linkLibCpp();
2747
2748 const obj = addObject(b, opts, .{ .name = "obj" });
2749 obj.addObject(obj1);
2750 obj.addObject(obj2);
2742 obj.linkLibCpp();2751 obj.linkLibCpp();
27432752
2744 const exe = addExecutable(b, opts, .{ .name = "test1" });2753 const exe = addExecutable(b, opts, .{ .name = "test1" });
...@@ -2768,8 +2777,8 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {...@@ -2768,8 +2777,8 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2768fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {2777fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2769 const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts);2778 const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts);
27702779
2771 const obj = addObject(b, opts, .{2780 const obj1 = addObject(b, opts, .{
2772 .name = "obj2",2781 .name = "obj1",
2773 .cpp_source_bytes =2782 .cpp_source_bytes =
2774 \\#include <stdexcept>2783 \\#include <stdexcept>
2775 \\int try_me() {2784 \\int try_me() {
...@@ -2777,13 +2786,20 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {...@@ -2777,13 +2786,20 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2777 \\}2786 \\}
2778 ,2787 ,
2779 });2788 });
2780 addCppSourceBytes(obj,2789 obj1.linkLibCpp();
2790 const obj2 = addObject(b, opts, .{
2791 .name = "obj2",
2792 .cpp_source_bytes =
2781 \\extern int try_me();2793 \\extern int try_me();
2782 \\int try_again() {2794 \\int try_again() {
2783 \\ return try_me();2795 \\ return try_me();
2784 \\}2796 \\}
2785 , &.{});2797 ,
2786 addCppSourceBytes(obj,2798 });
2799 obj2.linkLibCpp();
2800 const obj3 = addObject(b, opts, .{
2801 .name = "obj3",
2802 .cpp_source_bytes =
2787 \\#include <iostream>2803 \\#include <iostream>
2788 \\#include <stdexcept>2804 \\#include <stdexcept>
2789 \\extern int try_again();2805 \\extern int try_again();
...@@ -2795,7 +2811,14 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {...@@ -2795,7 +2811,14 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2795 \\ }2811 \\ }
2796 \\ return 0;2812 \\ return 0;
2797 \\}2813 \\}
2798 , &.{});2814 ,
2815 });
2816 obj3.linkLibCpp();
2817
2818 const obj = addObject(b, opts, .{ .name = "obj" });
2819 obj.addObject(obj1);
2820 obj.addObject(obj2);
2821 obj.addObject(obj3);
2799 obj.linkLibCpp();2822 obj.linkLibCpp();
28002823
2801 const exe = addExecutable(b, opts, .{ .name = "test2" });2824 const exe = addExecutable(b, opts, .{ .name = "test2" });