Merge pull request #2958 from emekoi/mingw-cmake

fix backtraces on mingw
master
Andrew Kelley 2019-07-29 16:27:35 -04:00 committed by GitHub
commit d694f298d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View File

@ -209,7 +209,7 @@ else()
else()
set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Wno-comment")
if(MINGW)
set(ZIG_LLD_COMPILE_FLAGS "${ZIG_LLD_COMPILE_FLAGS} -D__STDC_FORMAT_MACROS -D__USE_MINGW_ANSI_STDIO -Wno-pedantic-ms-format")
set(ZIG_LLD_COMPILE_FLAGS "${ZIG_LLD_COMPILE_FLAGS} -D__STDC_FORMAT_MACROS -D__USE_MINGW_ANSI_STDIO")
endif()
endif()
set_target_properties(embedded_lld_lib PROPERTIES
@ -511,19 +511,23 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
set(EXE_LDFLAGS " ")
if(MSVC)
set(EXE_LDFLAGS "/STACK:16777216")
set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")
elseif(MINGW)
set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")
endif()
if(ZIG_STATIC)
if(APPLE)
set(EXE_LDFLAGS "-static-libgcc -static-libstdc++")
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++")
elseif(MINGW)
set(EXE_LDFLAGS "-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -lz3 -lz -lgomp -Wl,--no-whole-archive")
else()
set(EXE_LDFLAGS "-static")
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++ -Wl,-Bstatic, -lwinpthread -lz3 -lz -lgomp")
elseif(NOT MSVC)
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static")
endif()
else()
if(MINGW)
set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")
endif()
endif()
if(ZIG_TEST_COVERAGE)
@ -559,11 +563,6 @@ if(NOT MSVC)
target_link_libraries(compiler LINK_PUBLIC ${LIBXML2})
endif()
if(MINGW)
find_library(Z3_LIBRARIES NAMES z3 z3.dll)
target_link_libraries(compiler LINK_PUBLIC ${Z3_LIBRARIES})
endif()
if(ZIG_DIA_GUIDS_LIB)
target_link_libraries(compiler LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})
endif()

View File

@ -120,7 +120,15 @@ pub const Coff = struct {
pub fn getPdbPath(self: *Coff, buffer: []u8) !usize {
try self.loadSections();
const header = (self.getSection(".rdata") orelse return error.MissingCoffSection).header;
const header = blk: {
if (self.getSection(".buildid")) |section| {
break :blk section.header;
} else if (self.getSection(".rdata")) |section| {
break :blk section.header;
} else {
return error.MissingCoffSection;
}
};
// The linker puts a chunk that contains the .pdb path right after the
// debug_directory.