| 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,7 +365,7 @@ if(ZIG_STATIC) |
| 365 | endif() | 365 | endif() |
| 366 | else() | 366 | else() |
| 367 | if(MINGW) | 367 | if(MINGW) |
| 368 | set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3") | 368 | set(EXE_LDFLAGS "${EXE_LDFLAGS}") |
| 369 | endif() | 369 | endif() |
| 370 | endif() | 370 | endif() |
| 371 | 371 | ||
| ... | @@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") | ... | @@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 429 | else() | 429 | else() |
| 430 | set(LIBSTAGE2_RELEASE_ARG --release-fast --strip) | 430 | set(LIBSTAGE2_RELEASE_ARG --release-fast --strip) |
| 431 | endif() | 431 | endif() |
| 432 | if(WIN32) | ||
| 433 | set(LIBSTAGE2_WINDOWS_ARGS "-lntdll") | ||
| 434 | else() | ||
| 435 | set(LIBSTAGE2_WINDOWS_ARGS "") | ||
| 436 | endif() | ||
| 437 | 432 | ||
| 438 | set(BUILD_LIBSTAGE2_ARGS "build-lib" | 433 | set(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-rt | 442 | --bundle-compiler-rt |
| 448 | -fPIC | 443 | -fPIC |
| 449 | -lc | 444 | -lc |
| 450 | ${LIBSTAGE2_WINDOWS_ARGS} | ||
| 451 | ) | 445 | ) |
| 452 | 446 | ||
| 453 | if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") | 447 | if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") |
cmake/Findllvm.cmake+1-4| ... | @@ -144,9 +144,7 @@ else() | ... | @@ -144,9 +144,7 @@ else() |
| 144 | /mingw64/lib | 144 | /mingw64/lib |
| 145 | /c/msys64/mingw64/lib | 145 | /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) |
| 151 | 149 | ||
| 152 | # This list can be re-generated with `llvm-config --libfiles` and then | 150 | # 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) |
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,6 +2259,7 @@ struct CodeGen { |
| 2259 | size_t version_minor; | 2259 | size_t version_minor; |
| 2260 | size_t version_patch; | 2260 | size_t version_patch; |
| 2261 | const char *linker_script; | 2261 | const char *linker_script; |
| 2262 | size_t stack_size_override; | ||
| 2262 | 2263 | ||
| 2263 | BuildMode build_mode; | 2264 | BuildMode build_mode; |
| 2264 | OutType out_type; | 2265 | OutType out_type; |
src/codegen.cpp+1| ... | @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { | ... | @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10597 | cache_int(ch, g->linker_allow_shlib_undefined); | 10597 | cache_int(ch, g->linker_allow_shlib_undefined); |
| 10598 | cache_bool(ch, g->linker_z_nodelete); | 10598 | cache_bool(ch, g->linker_z_nodelete); |
| 10599 | cache_bool(ch, g->linker_z_defs); | 10599 | cache_bool(ch, g->linker_z_defs); |
| 10600 | cache_usize(ch, g->stack_size_override); | ||
| 10600 | 10601 | ||
| 10601 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash | 10602 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash |
| 10602 | gen_c_objects(g); | 10603 | gen_c_objects(g); |
src/link.cpp+5-3| ... | @@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = { | ... | @@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = { |
| 72 | 72 | ||
| 73 | static const char *msvcrt_i386_src[] = { | 73 | static const char *msvcrt_i386_src[] = { |
| 74 | "misc" OS_SEP "lc_locale_func.c", | 74 | "misc" OS_SEP "lc_locale_func.c", |
| 75 | 75 | "misc" OS_SEP "___mb_cur_max_func.c", | |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | static const char *msvcrt_other_src[] = { | 78 | static const char *msvcrt_other_src[] = { |
| ... | @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 1840 | 1840 | ||
| 1841 | if (g->out_type == OutTypeExe) { | 1841 | if (g->out_type == OutTypeExe) { |
| 1842 | lj->args.append("-z"); | 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 | if (g->linker_script) { | 1847 | if (g->linker_script) { |
| ... | @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 2479 | 2480 | ||
| 2480 | if (g->out_type == OutTypeExe) { | 2481 | if (g->out_type == OutTypeExe) { |
| 2481 | // TODO compile time stack upper bound detection | 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 | coff_append_machine_arg(g, &lj->args); | 2487 | coff_append_machine_arg(g, &lj->args); |
src/main.cpp+23| ... | @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { | ... | @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { |
| 453 | OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; | 453 | OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; |
| 454 | bool linker_z_nodelete = false; | 454 | bool linker_z_nodelete = false; |
| 455 | bool linker_z_defs = false; | 455 | bool linker_z_defs = false; |
| 456 | size_t stack_size_override = 0; | ||
| 456 | 457 | ||
| 457 | ZigList<const char *> llvm_argv = {0}; | 458 | ZigList<const char *> llvm_argv = {0}; |
| 458 | llvm_argv.append("zig (LLVM option parsing)"); | 459 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { | ... | @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { |
| 848 | } else { | 849 | } else { |
| 849 | fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg)); | 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 | } else { | 873 | } else { |
| 852 | fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg)); | 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,6 +1595,7 @@ static int main0(int argc, char **argv) { |
| 1573 | g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; | 1595 | g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; |
| 1574 | g->linker_z_nodelete = linker_z_nodelete; | 1596 | g->linker_z_nodelete = linker_z_nodelete; |
| 1575 | g->linker_z_defs = linker_z_defs; | 1597 | g->linker_z_defs = linker_z_defs; |
| 1598 | g->stack_size_override = stack_size_override; | ||
| 1576 | 1599 | ||
| 1577 | if (override_soname) { | 1600 | if (override_soname) { |
| 1578 | g->override_soname = buf_create_from_str(override_soname); | 1601 | g->override_soname = buf_create_from_str(override_soname); |
src/os.cpp+2| ... | @@ -37,7 +37,9 @@ | ... | @@ -37,7 +37,9 @@ |
| 37 | #include <fcntl.h> | 37 | #include <fcntl.h> |
| 38 | #include <ntsecapi.h> | 38 | #include <ntsecapi.h> |
| 39 | 39 | ||
| 40 | #if defined(_MSC_VER) | ||
| 40 | typedef SSIZE_T ssize_t; | 41 | typedef SSIZE_T ssize_t; |
| 42 | #endif | ||
| 41 | #else | 43 | #else |
| 42 | #define ZIG_OS_POSIX | 44 | #define ZIG_OS_POSIX |
| 43 | 45 |
src/zig_clang.h+3-1| ... | @@ -50,7 +50,9 @@ enum ZigClangAPValueKind { | ... | @@ -50,7 +50,9 @@ enum ZigClangAPValueKind { |
| 50 | struct ZigClangAPValue { | 50 | struct ZigClangAPValue { |
| 51 | enum ZigClangAPValueKind Kind; | 51 | enum ZigClangAPValueKind Kind; |
| 52 | // experimentally-derived size of clang::APValue::DataType | 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 | char Data[52]; | 56 | char Data[52]; |
| 55 | #elif defined(__i386__) | 57 | #elif defined(__i386__) |
| 56 | char Data[48]; | 58 | char Data[48]; |