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" {
60596059 try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
60606060}
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 {
60636063 return (try crtFilePath(&comp.crt_files, basename)) orelse {
60646064 const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable;
60656065 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 {
27242724fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27252725 const test_step = addTestStep(b, "relocatable-eh-frame", opts);
27262726
2727 const obj = addObject(b, opts, .{
2727 const obj1 = addObject(b, opts, .{
27282728 .name = "obj1",
27292729 .cpp_source_bytes =
27302730 \\#include <stdexcept>
......@@ -2733,12 +2733,21 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27332733 \\}
27342734 ,
27352735 });
2736 addCppSourceBytes(obj,
2736 obj1.linkLibCpp();
2737 const obj2 = addObject(b, opts, .{
2738 .name = "obj2",
2739 .cpp_source_bytes =
27372740 \\extern int try_me();
27382741 \\int try_again() {
27392742 \\ return try_me();
27402743 \\}
2741 , &.{});
2744 ,
2745 });
2746 obj2.linkLibCpp();
2747
2748 const obj = addObject(b, opts, .{ .name = "obj" });
2749 obj.addObject(obj1);
2750 obj.addObject(obj2);
27422751 obj.linkLibCpp();
27432752
27442753 const exe = addExecutable(b, opts, .{ .name = "test1" });
......@@ -2768,8 +2777,8 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27682777fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
27692778 const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts);
27702779
2771 const obj = addObject(b, opts, .{
2772 .name = "obj2",
2780 const obj1 = addObject(b, opts, .{
2781 .name = "obj1",
27732782 .cpp_source_bytes =
27742783 \\#include <stdexcept>
27752784 \\int try_me() {
......@@ -2777,13 +2786,20 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
27772786 \\}
27782787 ,
27792788 });
2780 addCppSourceBytes(obj,
2789 obj1.linkLibCpp();
2790 const obj2 = addObject(b, opts, .{
2791 .name = "obj2",
2792 .cpp_source_bytes =
27812793 \\extern int try_me();
27822794 \\int try_again() {
27832795 \\ return try_me();
27842796 \\}
2785 , &.{});
2786 addCppSourceBytes(obj,
2797 ,
2798 });
2799 obj2.linkLibCpp();
2800 const obj3 = addObject(b, opts, .{
2801 .name = "obj3",
2802 .cpp_source_bytes =
27872803 \\#include <iostream>
27882804 \\#include <stdexcept>
27892805 \\extern int try_again();
......@@ -2795,7 +2811,14 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
27952811 \\ }
27962812 \\ return 0;
27972813 \\}
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);
27992822 obj.linkLibCpp();
28002823
28012824 const exe = addExecutable(b, opts, .{ .name = "test2" });