authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-29 16:27:35-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-07-29 16:27:35-04:00
logd694f298d826eb44895ef29a84ee195aba627b53
tree7d1dc5848301ecc4f757ef50ce4a50c0e5606006
parentc47b75312dc39a820e9f6533be0293066d9eab3f
parent357fb4f1436fca4b68ca5adf14ba85f3b21b5dcf
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2958 from emekoi/mingw-cmake

fix backtraces on mingw

2 files changed, 19 insertions(+), 12 deletions(-)

CMakeLists.txt+10-11
......@@ -209,7 +209,7 @@ else()
209209 else()
210210 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Wno-comment")
211211 if(MINGW)
212 set(ZIG_LLD_COMPILE_FLAGS "${ZIG_LLD_COMPILE_FLAGS} -D__STDC_FORMAT_MACROS -D__USE_MINGW_ANSI_STDIO -Wno-pedantic-ms-format")
212 set(ZIG_LLD_COMPILE_FLAGS "${ZIG_LLD_COMPILE_FLAGS} -D__STDC_FORMAT_MACROS -D__USE_MINGW_ANSI_STDIO")
213213 endif()
214214 endif()
215215 set_target_properties(embedded_lld_lib PROPERTIES
......@@ -511,19 +511,23 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
511511
512512set(EXE_LDFLAGS " ")
513513if(MSVC)
514 set(EXE_LDFLAGS "/STACK:16777216")
514 set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")
515515elseif(MINGW)
516516 set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")
517517endif()
518518
519519if(ZIG_STATIC)
520520 if(APPLE)
521 set(EXE_LDFLAGS "-static-libgcc -static-libstdc++")
521 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++")
522522 elseif(MINGW)
523 set(EXE_LDFLAGS "-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -lz3 -lz -lgomp -Wl,--no-whole-archive")
524 else()
525 set(EXE_LDFLAGS "-static")
523 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++ -Wl,-Bstatic, -lwinpthread -lz3 -lz -lgomp")
524 elseif(NOT MSVC)
525 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static")
526526 endif()
527else()
528 if(MINGW)
529 set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")
530 endif()
527531endif()
528532
529533if(ZIG_TEST_COVERAGE)
......@@ -559,11 +563,6 @@ if(NOT MSVC)
559563 target_link_libraries(compiler LINK_PUBLIC ${LIBXML2})
560564endif()
561565
562if(MINGW)
563 find_library(Z3_LIBRARIES NAMES z3 z3.dll)
564 target_link_libraries(compiler LINK_PUBLIC ${Z3_LIBRARIES})
565endif()
566
567566if(ZIG_DIA_GUIDS_LIB)
568567 target_link_libraries(compiler LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})
569568endif()
std/coff.zig+9-1
......@@ -120,7 +120,15 @@ pub const Coff = struct {
120120
121121 pub fn getPdbPath(self: *Coff, buffer: []u8) !usize {
122122 try self.loadSections();
123 const header = (self.getSection(".rdata") orelse return error.MissingCoffSection).header;
123 const header = blk: {
124 if (self.getSection(".buildid")) |section| {
125 break :blk section.header;
126 } else if (self.getSection(".rdata")) |section| {
127 break :blk section.header;
128 } else {
129 return error.MissingCoffSection;
130 }
131 };
124132
125133 // The linker puts a chunk that contains the .pdb path right after the
126134 // debug_directory.