authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-09 23:22:47+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-09 23:22:47+01:00
log73fd4ed54b639bfd4d8a142102b54762d290763e
tree537681609f8bebb380591eab96348575af958875
parent08882234d17a93dd44181323db697db993aebe3d

test/link/elf: make .eh_frame relocatable test also verify COMDATs we emit


1 files changed, 74 insertions(+), 33 deletions(-)

test/link/elf.zig+74-33
......@@ -2143,41 +2143,82 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
21432143fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
21442144 const test_step = addTestStep(b, "relocatable-eh-frame", opts);
21452145
2146 const obj = addObject(b, "obj", opts);
2147 addCppSourceBytes(obj,
2148 \\#include <stdexcept>
2149 \\int try_me() {
2150 \\ throw std::runtime_error("Oh no!");
2151 \\}
2152 , &.{});
2153 addCppSourceBytes(obj,
2154 \\extern int try_me();
2155 \\int try_again() {
2156 \\ return try_me();
2157 \\}
2158 , &.{});
2159 obj.linkLibCpp();
2146 {
2147 const obj = addObject(b, "obj1", opts);
2148 addCppSourceBytes(obj,
2149 \\#include <stdexcept>
2150 \\int try_me() {
2151 \\ throw std::runtime_error("Oh no!");
2152 \\}
2153 , &.{});
2154 addCppSourceBytes(obj,
2155 \\extern int try_me();
2156 \\int try_again() {
2157 \\ return try_me();
2158 \\}
2159 , &.{});
2160 obj.linkLibCpp();
21602161
2161 const exe = addExecutable(b, "test", opts);
2162 addCppSourceBytes(exe,
2163 \\#include <iostream>
2164 \\#include <stdexcept>
2165 \\extern int try_again();
2166 \\int main() {
2167 \\ try {
2168 \\ try_again();
2169 \\ } catch (const std::exception &e) {
2170 \\ std::cout << "exception=" << e.what();
2171 \\ }
2172 \\ return 0;
2173 \\}
2174 , &.{});
2175 exe.addObject(obj);
2176 exe.linkLibCpp();
2162 const exe = addExecutable(b, "test1", opts);
2163 addCppSourceBytes(exe,
2164 \\#include <iostream>
2165 \\#include <stdexcept>
2166 \\extern int try_again();
2167 \\int main() {
2168 \\ try {
2169 \\ try_again();
2170 \\ } catch (const std::exception &e) {
2171 \\ std::cout << "exception=" << e.what();
2172 \\ }
2173 \\ return 0;
2174 \\}
2175 , &.{});
2176 exe.addObject(obj);
2177 exe.linkLibCpp();
21772178
2178 const run = addRunArtifact(exe);
2179 run.expectStdOutEqual("exception=Oh no!");
2180 test_step.dependOn(&run.step);
2179 const run = addRunArtifact(exe);
2180 run.expectStdOutEqual("exception=Oh no!");
2181 test_step.dependOn(&run.step);
2182 }
2183
2184 {
2185 // Let's make the object file COMDAT group heavy!
2186 const obj = addObject(b, "obj2", opts);
2187 addCppSourceBytes(obj,
2188 \\#include <stdexcept>
2189 \\int try_me() {
2190 \\ throw std::runtime_error("Oh no!");
2191 \\}
2192 , &.{});
2193 addCppSourceBytes(obj,
2194 \\extern int try_me();
2195 \\int try_again() {
2196 \\ return try_me();
2197 \\}
2198 , &.{});
2199 addCppSourceBytes(obj,
2200 \\#include <iostream>
2201 \\#include <stdexcept>
2202 \\extern int try_again();
2203 \\int main() {
2204 \\ try {
2205 \\ try_again();
2206 \\ } catch (const std::exception &e) {
2207 \\ std::cout << "exception=" << e.what();
2208 \\ }
2209 \\ return 0;
2210 \\}
2211 , &.{});
2212 obj.linkLibCpp();
2213
2214 const exe = addExecutable(b, "test2", opts);
2215 exe.addObject(obj);
2216 exe.linkLibCpp();
2217
2218 const run = addRunArtifact(exe);
2219 run.expectStdOutEqual("exception=Oh no!");
2220 test_step.dependOn(&run.step);
2221 }
21812222
21822223 return test_step;
21832224}