| ... | ... | @@ -2143,41 +2143,82 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 2143 | 2143 | fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2144 | 2144 | const test_step = addTestStep(b, "relocatable-eh-frame", opts); |
| 2145 | 2145 | |
| 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(); |
| 2160 | 2161 | |
| 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(); |
| 2177 | 2178 | |
| 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 | } |
| 2181 | 2222 | |
| 2182 | 2223 | return test_step; |
| 2183 | 2224 | } |