-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zig-build improvements: MSVC & C++ #636
Conversation
maybe done for review. |
A warning is reported about korandoru: |
opened: |
Just for a reference: zig 0.12 support builds on Windows using MinGW or MS VC. Cygwin is not supported yet (ziglang/zig#751) |
PR #636 (bdwgc). * build.zig (build): Update comments (mention msvc, mention cc instead of clang). * build.zig [t.abi==.msvc] (build): Append "-D _CRT_SECURE_NO_DEPRECATE" to flags; add msvc_dbg.c to source_files; add TODO item and append "-D NO_SEH_AVAILABLE" to flags. * build.zig [build_shared_libs && t.abi==.msvc] (build): Add TODO item and append "-D DONT_USE_USER32_DLL" to flags. Co-authored-by: Ivan Maidanski <[email protected]>
Now I have pushed your code (with my modifications) to support msvc target - commit 5201e76. |
Rebased again. |
All shared msvc builds seem to hang (I've not investigated it yet) - e.g. https://github.com/ivmai/bdwgc/actions/runs/8860942283/job/24332280900 |
Windows - cpptest build issueMinGW_shared-libhttps://github.com/ivmai/bdwgc/actions/runs/8861871430/job/24334204783 +- run cpptest
+- zig build-exe cpptest Debug native 4 errors
D:\a\bdwgc\bdwgc\include/gc/gc_cpp.h:342:5: error: replacement function 'operator new[]' cannot be declared 'inline'
D:\a\bdwgc\bdwgc\tests\cpp.cc:25:10: note: in file included from D:\a\bdwgc\bdwgc\tests\cpp.cc:25:
D:\a\bdwgc\bdwgc\include/gc_cpp.h:2:10: note: in file included from D:\a\bdwgc\bdwgc\include/gc_cpp.h:2: MSVC_shared-libhttps://github.com/ivmai/bdwgc/actions/runs/8861871430/job/24334206851 test
+- run cpptest
+- zig build-exe cpptest Debug native-native-msvc 20 errors
error: lld-link: undefined symbol: __declspec(dllimport) GC_set_all_interior_pointers
note: referenced by D:\a\bdwgc\bdwgc\tests\cpp.cc:311
note: D:\a\bdwgc\bdwgc\zig-cache\o\fc2798597c3554acc98a525408f97dc1\cpp.obj:(WinMain)
error: lld-link: undefined symbol: __declspec(dllimport) GC_init
note: referenced by D:\a\bdwgc\bdwgc\tests\cpp.cc:318
note: D:\a\bdwgc\bdwgc\zig-cache\o\fc2798597c3554acc98a525408f97dc1\cpp.obj:(WinMain)
error: lld-link: undefined symbol: __declspec(dllimport) GC_enable_incremental
note: referenced by D:\a\bdwgc\bdwgc\tests\cpp.cc:321 |
PR #636 (bdwgc). This commit adds support of enable_cplusplus and enable_throw_bad_alloc_library options to Zig script (to match that of CMake script). * build.zig (build): Define enable_cplusplus and enable_throw_bad_alloc_library consts (options); remove relevant TODO items; define gccpp and gctba variables. * build.zig [enable_cplusplus && enable_werror && (build_shared_libs && t.os.tag==.windows || t.abi==.msvc)] (build): Append -Wno-inline-new-delete to flags; add comment item. * build.zig [enable_cplusplus && enable_werror && t.abi==.msvc] (build): Append -Wno-unused-command-line-argument to flags; add TODO item. * build.zig [enable_cplusplus && build_shared_libs] (build): Set gccpp to addSharedLibrary(). * build.zig [enable_cplusplus] (build): Define gccpp_src_files variable; specify source files and dependency library for gccpp using linkLibCpp(); install gccpp artifact; call addTestExt() for cpptest. * build.zig [enable_cplusplus && enable_throw_bad_alloc_library] (build): Define gctba_src_files variable; specify source files and dependency library for gctba using linkLibCpp(); install gctba artifact. * build.zig [install_headers && enable_cplusplus] (build): Install gccpp headers. * build.zig [install_headers && enable_cplusplus && enable_throw_bad_alloc_library] (build): Install gctba headers (same as for gccpp). * build.zig (linkLibCpp): New function (to workaround C++ library linking by MS VC). Co-authored-by: Ivan Maidanski <[email protected]>
I've changed your commit so that the script part which build gccpp/tba looks close to that of cmake script. Merged. |
However there issues with cross-compilation:
|
Also, shared lib build by MS VC hangs, e.g. |
Keeping this PR open because of the above 3 items. |
|
I'll test on powerpc64/debian (docker). |
zig: add build-lib c++ & tba support ci: C++ test ci: msvc enable_werror falsed zig issue - warn to error: argument unused during compilation: '-nostdinc++'
It seems it does work. It would be nice if you manage to prepare workaround. (Alternative we could turn off checking such configs for now.) |
Related: ziglang/zig-bootstrap#113 |
Yes! Unfortunately, ppc64 (not ppc64le) images with no |
Okay, I will exclude C++ shared builds on CI for these targets (mips, ppc). |
Hmm. It does not hang if -Dbuild_cord=false |
I'm closing this PR because the above mentioned issue does not depend on C++ part. |
Hmm. Some non-MSVC build for Windows also hang: issue #641 |
closes #635
Not only does this change the build for the msvc target. It also adds support for C++ libraries.
Note: CI is now using a GH-action plugin to download (faster and more manageable) zig-tarballs.
korandoru
, but you can also specify the -dev version. (no-cached)