Skip to content

support -lc++ on windows for the msvc ABI #5312

Open
@SpexGuy

Description

@SpexGuy

On Windows, zig c++ empty_file.cpp fails with this error:

C:\Users\Martin\Projects\Zig-ImGui>zig c++ test.cpp
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
In file included from C:\Program Files\Zig\Current\lib\zig\libcxxabi\src/cxa_aux_runtime.cpp:14:
In file included from C:\Program Files\Zig\Current\lib\zig\libcxx\include\typeinfo:72:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\vcruntime_typeinfo.h:115:10: error:
      target of using declaration conflicts with declaration already in scope
        using ::type_info;
                ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\vcruntime_typeinfo.h:65:7: note:
      target of using declaration
class type_info
      ^
C:\Program Files\Zig\Current\lib\zig\libcxxabi\include\cxxabi.h:29:27: note: conflicting declaration
class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
                          ^
1 error generated.

The following command failed:
C:\Program Files\Zig\Current\zig.exe clang -c -nostdinc -nostdinc++ -fno-spell-checking -target x86_64-unknown-windows-msvc -isystem C:\Program Files\Zig\Current\lib\zig\include -isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt -isystem C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include -isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\..\um -isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\..\shared -Xclang -target-cpu -Xclang skylake -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,+adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,+clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,-false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,+fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,+fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,+prfchw,-ptwrite,-rdpid,+rdrnd,+rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,+rtm,+sahf,+sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,+xsavec,+xsaveopt,+xsaves -MD -MV -MF C:\Users\Martin\AppData\Local\zig\stage1\tmp\mNdq4h1lx5Zr-cxa_aux_runtime.obj.d -fno-omit-frame-pointer -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -o C:\Users\Martin\AppData\Local\zig\stage1\tmp\mNdq4h1lx5Zr-cxa_aux_runtime.obj C:\Program Files\Zig\Current\lib\zig\libcxxabi\src/cxa_aux_runtime.cpp -DHAVE___CXA_THREAD_ATEXIT_IMPL -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -I C:\Program Files\Zig\Current\lib\zig\libcxxabi\include -I C:\Program Files\Zig\Current\lib\zig\libcxx\include -O3 -DNDEBUG -nostdinc++ -fstrict-aliasing -funwind-tables -D_DEBUG -UNDEBUG -std=c++11

The same error is observed when building pub fn main() void {} with zig build-exe -lc++.

Adding --target=native-native-gnu seems to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.os-windowsproposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions