mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
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.
This commit is contained in:
parent
afa24ccd99
commit
15ab61b2a0
@ -365,7 +365,7 @@ if(ZIG_STATIC)
|
|||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")
|
set(EXE_LDFLAGS "${EXE_LDFLAGS}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
|||||||
else()
|
else()
|
||||||
set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)
|
set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)
|
||||||
endif()
|
endif()
|
||||||
if(WIN32)
|
|
||||||
set(LIBSTAGE2_WINDOWS_ARGS "-lntdll")
|
|
||||||
else()
|
|
||||||
set(LIBSTAGE2_WINDOWS_ARGS "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(BUILD_LIBSTAGE2_ARGS "build-lib"
|
set(BUILD_LIBSTAGE2_ARGS "build-lib"
|
||||||
"src-self-hosted/stage2.zig"
|
"src-self-hosted/stage2.zig"
|
||||||
@ -447,7 +442,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"
|
|||||||
--bundle-compiler-rt
|
--bundle-compiler-rt
|
||||||
-fPIC
|
-fPIC
|
||||||
-lc
|
-lc
|
||||||
${LIBSTAGE2_WINDOWS_ARGS}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
|
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
|
||||||
|
|||||||
@ -144,9 +144,7 @@ else()
|
|||||||
/mingw64/lib
|
/mingw64/lib
|
||||||
/c/msys64/mingw64/lib
|
/c/msys64/mingw64/lib
|
||||||
c:\\msys64\\mingw64\\lib)
|
c:\\msys64\\mingw64\\lib)
|
||||||
if(LLVM_${_prettylibname_}_LIB)
|
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
|
||||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
|
|
||||||
endif()
|
|
||||||
endmacro(FIND_AND_ADD_LLVM_LIB)
|
endmacro(FIND_AND_ADD_LLVM_LIB)
|
||||||
|
|
||||||
# This list can be re-generated with `llvm-config --libfiles` and then
|
# This list can be re-generated with `llvm-config --libfiles` and then
|
||||||
@ -154,7 +152,6 @@ else()
|
|||||||
# `llvm-config` here because we are cross compiling.
|
# `llvm-config` here because we are cross compiling.
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMXRay)
|
FIND_AND_ADD_LLVM_LIB(LLVMXRay)
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
|
FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMTableGen)
|
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
||||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)
|
FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user