authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-06 15:42:04-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-06 18:38:09-04:00
log15ab61b2a00b56c5b15a2d5a4efbf6b7bde7a868
tree5f428ae890f41eed431234d3007ed44a56fc080c
parentafa24ccd993e38b56407c83160da567bc2b0ae8a
signaturelock-open Commit is signed but in an unrecognized format.

cmake: improvements to cross-compiling for Windows

* don't unconditionally pass -lz3 for mingw builds. If mingw builds require this then the llvm-config executable should put it as part of --system-libs. If there is a bug and it does not do that, and we need a workaround, then the workaround should be an explicit cmake option. * don't link libstage2.a against -lntdll. This causes zig to set `builtin.link_mode == .Dynamic` and include the TLS definitions, which then collide with the mingw-w64 symbols. This should probably be addressed separately, but for now this solves the problem and there is no reason to link a static library against a DLL. * Findllvm.cmake no longer treats the libraries as "optional" and will emit a cmake error if one is not found. Additionally, the not-required LLVM library LLVMTableGen is omitted.

2 files changed, 2 insertions(+), 11 deletions(-)

CMakeLists.txt+1-7
...@@ -365,7 +365,7 @@ if(ZIG_STATIC)...@@ -365,7 +365,7 @@ if(ZIG_STATIC)
365 endif()365 endif()
366else()366else()
367 if(MINGW)367 if(MINGW)
368 set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")368 set(EXE_LDFLAGS "${EXE_LDFLAGS}")
369 endif()369 endif()
370endif()370endif()
371371
...@@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")...@@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
429else()429else()
430 set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)430 set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)
431endif()431endif()
432if(WIN32)
433 set(LIBSTAGE2_WINDOWS_ARGS "-lntdll")
434else()
435 set(LIBSTAGE2_WINDOWS_ARGS "")
436endif()
437432
438set(BUILD_LIBSTAGE2_ARGS "build-lib"433set(BUILD_LIBSTAGE2_ARGS "build-lib"
439 "src-self-hosted/stage2.zig"434 "src-self-hosted/stage2.zig"
...@@ -447,7 +442,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"...@@ -447,7 +442,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"
447 --bundle-compiler-rt442 --bundle-compiler-rt
448 -fPIC443 -fPIC
449 -lc444 -lc
450 ${LIBSTAGE2_WINDOWS_ARGS}
451)445)
452446
453if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")447if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
cmake/Findllvm.cmake+1-4
...@@ -144,9 +144,7 @@ else()...@@ -144,9 +144,7 @@ else()
144 /mingw64/lib144 /mingw64/lib
145 /c/msys64/mingw64/lib145 /c/msys64/mingw64/lib
146 c:\\msys64\\mingw64\\lib)146 c:\\msys64\\mingw64\\lib)
147 if(LLVM_${_prettylibname_}_LIB)147 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
148 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
149 endif()
150 endmacro(FIND_AND_ADD_LLVM_LIB)148 endmacro(FIND_AND_ADD_LLVM_LIB)
151149
152 # This list can be re-generated with `llvm-config --libfiles` and then150 # This list can be re-generated with `llvm-config --libfiles` and then
...@@ -154,7 +152,6 @@ else()...@@ -154,7 +152,6 @@ else()
154 # `llvm-config` here because we are cross compiling.152 # `llvm-config` here because we are cross compiling.
155 FIND_AND_ADD_LLVM_LIB(LLVMXRay)153 FIND_AND_ADD_LLVM_LIB(LLVMXRay)
156 FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)154 FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
157 FIND_AND_ADD_LLVM_LIB(LLVMTableGen)
158 FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)155 FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
159 FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)156 FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
160 FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)157 FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)