diff --git a/CMakeLists.txt b/CMakeLists.txt index d8cf0c507..998da172f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/std/coff.zig b/std/coff.zig index 9fdc36887..7c53f48f6 100644 --- a/std/coff.zig +++ b/std/coff.zig @@ -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.