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
signature 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()...@@ -209,7 +209,7 @@ else()
209 else()209 else()
210 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Wno-comment")210 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Wno-comment")
211 if(MINGW)211 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")
213 endif()213 endif()
214 endif()214 endif()
215 set_target_properties(embedded_lld_lib PROPERTIES215 set_target_properties(embedded_lld_lib PROPERTIES
...@@ -511,19 +511,23 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")...@@ -511,19 +511,23 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
511511
512set(EXE_LDFLAGS " ")512set(EXE_LDFLAGS " ")
513if(MSVC)513if(MSVC)
514 set(EXE_LDFLAGS "/STACK:16777216")514 set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")
515elseif(MINGW) 515elseif(MINGW)
516 set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")516 set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")
517endif()517endif()
518518
519if(ZIG_STATIC)519if(ZIG_STATIC)
520 if(APPLE)520 if(APPLE)
521 set(EXE_LDFLAGS "-static-libgcc -static-libstdc++")521 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++")
522 elseif(MINGW)522 elseif(MINGW)
523 set(EXE_LDFLAGS "-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -lz3 -lz -lgomp -Wl,--no-whole-archive")523 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++ -Wl,-Bstatic, -lwinpthread -lz3 -lz -lgomp")
524 else()524 elseif(NOT MSVC)
525 set(EXE_LDFLAGS "-static")525 set(EXE_LDFLAGS "${EXE_LDFLAGS} -static")
526 endif()526 endif()
527else()
528 if(MINGW)
529 set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")
530 endif()
527endif()531endif()
528532
529if(ZIG_TEST_COVERAGE)533if(ZIG_TEST_COVERAGE)
...@@ -559,11 +563,6 @@ if(NOT MSVC)...@@ -559,11 +563,6 @@ if(NOT MSVC)
559 target_link_libraries(compiler LINK_PUBLIC ${LIBXML2})563 target_link_libraries(compiler LINK_PUBLIC ${LIBXML2})
560endif()564endif()
561565
562if(MINGW)
563 find_library(Z3_LIBRARIES NAMES z3 z3.dll)
564 target_link_libraries(compiler LINK_PUBLIC ${Z3_LIBRARIES})
565endif()
566
567if(ZIG_DIA_GUIDS_LIB)566if(ZIG_DIA_GUIDS_LIB)
568 target_link_libraries(compiler LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})567 target_link_libraries(compiler LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})
569endif()568endif()
std/coff.zig+9-1
...@@ -120,7 +120,15 @@ pub const Coff = struct {...@@ -120,7 +120,15 @@ pub const Coff = struct {
120120
121 pub fn getPdbPath(self: *Coff, buffer: []u8) !usize {121 pub fn getPdbPath(self: *Coff, buffer: []u8) !usize {
122 try self.loadSections();122 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
125 // The linker puts a chunk that contains the .pdb path right after the133 // The linker puts a chunk that contains the .pdb path right after the
126 // debug_directory.134 // debug_directory.