| author | |
| committer | |
| log | ab05766674b88dc7715d27f7d590d6832ee005ca |
| tree | 64ed2bd23f02c8b90e1b724e6dd99ddd032b6edc |
| parent | afa24ccd993e38b56407c83160da567bc2b0ae8a |
| parent | fc662ddd54df75bf21d1be74c9d720fb8f164591 |
| signature |
cmake: improvements to cross-compiling for Windows10 files changed, 71 insertions(+), 15 deletions(-)
CMakeLists.txt+1-7| ... | ... | @@ -365,7 +365,7 @@ if(ZIG_STATIC) |
| 365 | 365 | endif() |
| 366 | 366 | else() |
| 367 | 367 | if(MINGW) |
| 368 | set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3") | |
| 368 | set(EXE_LDFLAGS "${EXE_LDFLAGS}") | |
| 369 | 369 | endif() |
| 370 | 370 | endif() |
| 371 | 371 | |
| ... | ... | @@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 429 | 429 | else() |
| 430 | 430 | set(LIBSTAGE2_RELEASE_ARG --release-fast --strip) |
| 431 | 431 | endif() |
| 432 | if(WIN32) | |
| 433 | set(LIBSTAGE2_WINDOWS_ARGS "-lntdll") | |
| 434 | else() | |
| 435 | set(LIBSTAGE2_WINDOWS_ARGS "") | |
| 436 | endif() | |
| 437 | 432 | |
| 438 | 433 | set(BUILD_LIBSTAGE2_ARGS "build-lib" |
| 439 | 434 | "src-self-hosted/stage2.zig" |
| ... | ... | @@ -447,7 +442,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib" |
| 447 | 442 | --bundle-compiler-rt |
| 448 | 443 | -fPIC |
| 449 | 444 | -lc |
| 450 | ${LIBSTAGE2_WINDOWS_ARGS} | |
| 451 | 445 | ) |
| 452 | 446 | |
| 453 | 447 | if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") |
cmake/Findllvm.cmake+1-4| ... | ... | @@ -144,9 +144,7 @@ else() |
| 144 | 144 | /mingw64/lib |
| 145 | 145 | /c/msys64/mingw64/lib |
| 146 | 146 | c:\\msys64\\mingw64\\lib) |
| 147 | if(LLVM_${_prettylibname_}_LIB) | |
| 148 | set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB}) | |
| 149 | endif() | |
| 147 | set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB}) | |
| 150 | 148 | endmacro(FIND_AND_ADD_LLVM_LIB) |
| 151 | 149 | |
| 152 | 150 | # This list can be re-generated with `llvm-config --libfiles` and then |
| ... | ... | @@ -154,7 +152,6 @@ else() |
| 154 | 152 | # `llvm-config` here because we are cross compiling. |
| 155 | 153 | FIND_AND_ADD_LLVM_LIB(LLVMXRay) |
| 156 | 154 | FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest) |
| 157 | FIND_AND_ADD_LLVM_LIB(LLVMTableGen) | |
| 158 | 155 | FIND_AND_ADD_LLVM_LIB(LLVMSymbolize) |
| 159 | 156 | FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB) |
| 160 | 157 | FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT) |
lib/libc/mingw/lib32/version.def created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | LIBRARY "VERSION.dll" | |
| 2 | EXPORTS | |
| 3 | GetFileVersionInfoA@16 | |
| 4 | GetFileVersionInfoSizeA@8 | |
| 5 | GetFileVersionInfoSizeW@8 | |
| 6 | GetFileVersionInfoW@16 | |
| 7 | VerFindFileA@32 | |
| 8 | VerFindFileW@32 | |
| 9 | VerInstallFileA@32 | |
| 10 | VerInstallFileW@32 | |
| 11 | VerLanguageNameA@12 | |
| 12 | VerLanguageNameW@12 | |
| 13 | VerQueryValueA@16 | |
| 14 | VerQueryValueIndexA@24 | |
| 15 | VerQueryValueIndexW@24 | |
| 16 | VerQueryValueW@16 |
lib/libc/mingw/misc/___mb_cur_max_func.c created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | /** | |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 | * This file is part of the mingw-w64 runtime package. | |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | |
| 5 | */ | |
| 6 | ||
| 7 | #include <_mingw.h> | |
| 8 | ||
| 9 | extern int* __MINGW_IMP_SYMBOL(__mb_cur_max); | |
| 10 | ||
| 11 | int __cdecl ___mb_cur_max_func(void); | |
| 12 | int __cdecl ___mb_cur_max_func(void) | |
| 13 | { | |
| 14 | return *__MINGW_IMP_SYMBOL(__mb_cur_max); | |
| 15 | } | |
| 16 | ||
| 17 | typedef int __cdecl (*_f___mb_cur_max_func)(void); | |
| 18 | _f___mb_cur_max_func __MINGW_IMP_SYMBOL(___mb_cur_max_func) = ___mb_cur_max_func; |
src/all_types.hpp+1| ... | ... | @@ -2259,6 +2259,7 @@ struct CodeGen { |
| 2259 | 2259 | size_t version_minor; |
| 2260 | 2260 | size_t version_patch; |
| 2261 | 2261 | const char *linker_script; |
| 2262 | size_t stack_size_override; | |
| 2262 | 2263 | |
| 2263 | 2264 | BuildMode build_mode; |
| 2264 | 2265 | OutType out_type; |
src/codegen.cpp+1| ... | ... | @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10597 | 10597 | cache_int(ch, g->linker_allow_shlib_undefined); |
| 10598 | 10598 | cache_bool(ch, g->linker_z_nodelete); |
| 10599 | 10599 | cache_bool(ch, g->linker_z_defs); |
| 10600 | cache_usize(ch, g->stack_size_override); | |
| 10600 | 10601 | |
| 10601 | 10602 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash |
| 10602 | 10603 | gen_c_objects(g); |
src/link.cpp+5-3| ... | ... | @@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = { |
| 72 | 72 | |
| 73 | 73 | static const char *msvcrt_i386_src[] = { |
| 74 | 74 | "misc" OS_SEP "lc_locale_func.c", |
| 75 | ||
| 75 | "misc" OS_SEP "___mb_cur_max_func.c", | |
| 76 | 76 | }; |
| 77 | 77 | |
| 78 | 78 | static const char *msvcrt_other_src[] = { |
| ... | ... | @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 1840 | 1840 | |
| 1841 | 1841 | if (g->out_type == OutTypeExe) { |
| 1842 | 1842 | lj->args.append("-z"); |
| 1843 | lj->args.append("stack-size=16777216"); // default to 16 MiB | |
| 1843 | size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; | |
| 1844 | lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size))); | |
| 1844 | 1845 | } |
| 1845 | 1846 | |
| 1846 | 1847 | if (g->linker_script) { |
| ... | ... | @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 2479 | 2480 | |
| 2480 | 2481 | if (g->out_type == OutTypeExe) { |
| 2481 | 2482 | // TODO compile time stack upper bound detection |
| 2482 | lj->args.append("-STACK:16777216"); | |
| 2483 | size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; | |
| 2484 | lj->args.append(buf_ptr(buf_sprintf("-STACK:%" ZIG_PRI_usize, stack_size))); | |
| 2483 | 2485 | } |
| 2484 | 2486 | |
| 2485 | 2487 | coff_append_machine_arg(g, &lj->args); |
src/main.cpp+23| ... | ... | @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { |
| 453 | 453 | OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; |
| 454 | 454 | bool linker_z_nodelete = false; |
| 455 | 455 | bool linker_z_defs = false; |
| 456 | size_t stack_size_override = 0; | |
| 456 | 457 | |
| 457 | 458 | ZigList<const char *> llvm_argv = {0}; |
| 458 | 459 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | ... | @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { |
| 848 | 849 | } else { |
| 849 | 850 | fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg)); |
| 850 | 851 | } |
| 852 | } else if (buf_eql_str(arg, "--major-image-version")) { | |
| 853 | i += 1; | |
| 854 | if (i >= linker_args.length) { | |
| 855 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | |
| 856 | return EXIT_FAILURE; | |
| 857 | } | |
| 858 | ver_major = atoi(buf_ptr(linker_args.at(i))); | |
| 859 | } else if (buf_eql_str(arg, "--minor-image-version")) { | |
| 860 | i += 1; | |
| 861 | if (i >= linker_args.length) { | |
| 862 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | |
| 863 | return EXIT_FAILURE; | |
| 864 | } | |
| 865 | ver_minor = atoi(buf_ptr(linker_args.at(i))); | |
| 866 | } else if (buf_eql_str(arg, "--stack")) { | |
| 867 | i += 1; | |
| 868 | if (i >= linker_args.length) { | |
| 869 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | |
| 870 | return EXIT_FAILURE; | |
| 871 | } | |
| 872 | stack_size_override = atoi(buf_ptr(linker_args.at(i))); | |
| 851 | 873 | } else { |
| 852 | 874 | fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg)); |
| 853 | 875 | } |
| ... | ... | @@ -1573,6 +1595,7 @@ static int main0(int argc, char **argv) { |
| 1573 | 1595 | g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; |
| 1574 | 1596 | g->linker_z_nodelete = linker_z_nodelete; |
| 1575 | 1597 | g->linker_z_defs = linker_z_defs; |
| 1598 | g->stack_size_override = stack_size_override; | |
| 1576 | 1599 | |
| 1577 | 1600 | if (override_soname) { |
| 1578 | 1601 | g->override_soname = buf_create_from_str(override_soname); |
src/os.cpp+2| ... | ... | @@ -37,7 +37,9 @@ |
| 37 | 37 | #include <fcntl.h> |
| 38 | 38 | #include <ntsecapi.h> |
| 39 | 39 | |
| 40 | #if defined(_MSC_VER) | |
| 40 | 41 | typedef SSIZE_T ssize_t; |
| 42 | #endif | |
| 41 | 43 | #else |
| 42 | 44 | #define ZIG_OS_POSIX |
| 43 | 45 |
src/zig_clang.h+3-1| ... | ... | @@ -50,7 +50,9 @@ enum ZigClangAPValueKind { |
| 50 | 50 | struct ZigClangAPValue { |
| 51 | 51 | enum ZigClangAPValueKind Kind; |
| 52 | 52 | // experimentally-derived size of clang::APValue::DataType |
| 53 | #if defined(_WIN32) && defined(_MSC_VER) | |
| 53 | #if defined(_WIN32) && defined(__i386__) | |
| 54 | char Data[68]; | |
| 55 | #elif defined(_WIN32) && defined(_MSC_VER) | |
| 54 | 56 | char Data[52]; |
| 55 | 57 | #elif defined(__i386__) |
| 56 | 58 | char Data[48]; |