authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-09-16 16:51:29-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-20 01:59:25-04:00
logcfd5b81850d0234a5011c98f840d93bed47210c1
treece510a5d1eafeba3923824a6355c469a6ad98db1
parent1f61076ffb3027e043ff78995344267b39b6226f

Fix compiler builds with tracy on the mingw target


1 files changed, 18 insertions(+), 1 deletions(-)

build.zig+18-1
...@@ -112,6 +112,11 @@ pub fn build(b: *Builder) !void {...@@ -112,6 +112,11 @@ pub fn build(b: *Builder) !void {
112 b.default_step.dependOn(&exe.step);112 b.default_step.dependOn(&exe.step);
113 exe.single_threaded = single_threaded;113 exe.single_threaded = single_threaded;
114114
115 if (target.isWindows() and target.getAbi() == .gnu) {
116 // LTO is currently broken on mingw, this can be removed when it's fixed.
117 exe.want_lto = false;
118 }
119
115 const exe_options = b.addOptions();120 const exe_options = b.addOptions();
116 exe.addOptions("build_options", exe_options);121 exe.addOptions("build_options", exe_options);
117122
...@@ -239,12 +244,24 @@ pub fn build(b: *Builder) !void {...@@ -239,12 +244,24 @@ pub fn build(b: *Builder) !void {
239 b.allocator,244 b.allocator,
240 &[_][]const u8{ tracy_path, "TracyClient.cpp" },245 &[_][]const u8{ tracy_path, "TracyClient.cpp" },
241 ) catch unreachable;246 ) catch unreachable;
247
248 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
249 const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu)
250 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
251 else
252 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
253
242 exe.addIncludeDir(tracy_path);254 exe.addIncludeDir(tracy_path);
243 exe.addCSourceFile(client_cpp, &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" });255 exe.addCSourceFile(client_cpp, tracy_c_flags);
244 if (!enable_llvm) {256 if (!enable_llvm) {
245 exe.linkSystemLibraryName("c++");257 exe.linkSystemLibraryName("c++");
246 }258 }
247 exe.linkLibC();259 exe.linkLibC();
260
261 if (target.isWindows()) {
262 exe.linkSystemLibrary("dbghelp");
263 exe.linkSystemLibrary("ws2_32");
264 }
248 }265 }
249266
250 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");267 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");