clang 无法针对新的 MSVC 2019 和 Windows SDK 10.0.17763.0 构建 libc++(重新定义 nothrow_t、new、delete、new[]、delete[])
clang fails to build libc++ (redefine nothrow_t, new, delete, new[], delete[] ) against new MSVC 2019 and Windows SDK 10.0.17763.0
似乎有 5 个符号冲突:nothrow_t
、new
、delete
、new[]
、delete[]
[2/37] Building CXX object lib\CMakeFiles\cxx_shared.dir\__\src\algorithm.cpp.obj
FAILED: lib/CMakeFiles/cxx_shared.dir/__/src/algorithm.cpp.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP -DNDEBUG -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -D_ALLOW_MSC_VER_MISMATCH -D_CRTBLD -D_CRT_SECURE_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -IC:\Users\User\AppData\Roaming\libcxx-master\include -fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME -D_LIBCPP_NO_VCRUNTIME /MD /O2 /Ob2 /DNDEBUG /std:c++14 -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-compat -Wno-undef -Wno-reserved-id-macro -Wno-gnu-include-next -Wno-gcc-compat -Wno-zero-as-null-pointer-constant -Wno-deprecated-dynamic-exception-spec -Wno-sign-conversion -Wno-old-style-cast -Wno-deprecated -Wno-shift-sign-overflow -Wno-double-promotion -Wno-error -EHsc /Zl /showIncludes /Folib\CMakeFiles\cxx_shared.dir\__\src\algorithm.cpp.obj /Fdlib\CMakeFiles\cxx_shared.dir\ -c C:\Users\User\AppData\Roaming\libcxx-master\src\algorithm.cpp
In file included from C:\Users\User\AppData\Roaming\libcxx-master\src\algorithm.cpp:10:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\random:1645:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\istream:163:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\ostream:137:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\ios:215:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\__locale:23:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\support/win32/locale_win32.h:15:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\xlocinfo.h:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\yvals.h:9:
In file included from C:\Program Files (x86)\Windows Kits\Include.0.17763.0\ucrt\crtdbg.h:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\vcruntime_new_debug.h:10:
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\vcruntime_new.h(34,16): error: redefinition of 'nothrow_t'
struct nothrow_t {
^
C:\Users\User\AppData\Roaming\libcxx-master\include\new(123,25): note: previous definition is here
struct _LIBCPP_TYPE_VIS nothrow_t {};
^
这是我的 CMAKE。 (也试过 19.20)
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="C:/Program Files (x86)/Ninja/ninja.exe"
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe"
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME"
-DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe"
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME -D_LIBCPP_NO_VCRUNTIME"
-DCMAKE_C_LINK_EXECUTABLE="C:/Program Files/LLVM/bin/lld-link.exe"
-DCMAKE_CXX_LINK_EXECUTABLE="C:/Program Files/LLVM/bin/lld-link.exe"
-DLLVM_USE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe"
-DLLVM_PATH="C:/Program Files/LLVM" -DLIBCXX_ENABLE_SHARED=YES
-DLIBCXX_ENABLE_STATIC=NO -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=YES
"C:/Users/User/AppData/Roaming/libcxx-master"
这是我的SDK
set LIB=C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\lib\x64;
C:\Program Files (x86)\Windows Kits\Lib.0.17763.0\ucrt\x64;
C:\Program Files (x86)\Windows Kits\Lib.0.17763.0\um\x64
我可以让它工作吗?在哪里发送问题给谁?
我在 VS2019 上遇到了同样的问题。
我删除了 no_runtime 标志但设置了
-DCMAKE_C_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DCMAKE_CXX_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
添加 -flavor link
并成功链接。我没有测试异常,但使用 std::thread
编译和运行的测试程序与使用 cl
编译器相同。
UPD:std::exception
抛出的基本 try-catch 有效
更新:完整的 cmake 批处理(您的路径可能会有所不同!)
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="D:/Programming/ninja-build/ninja.exe" ^
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="clang-cl.exe" ^
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows" ^
-DCMAKE_CXX_COMPILER="clang-cl.exe" ^
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows " ^
-DCMAKE_C_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DCMAKE_CXX_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DLLVM_USE_LINKER="lld-link.exe" ^
-DLLVM_PATH="C:/Program Files/LLVM" -DLIBCXX_ENABLE_SHARED=YES ^
-DLIBCXX_ENABLE_STATIC=NO -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=YES ^
"D:\Programming\cpp_sandbox\libcxx-9.0.0.src"
似乎有 5 个符号冲突:nothrow_t
、new
、delete
、new[]
、delete[]
[2/37] Building CXX object lib\CMakeFiles\cxx_shared.dir\__\src\algorithm.cpp.obj
FAILED: lib/CMakeFiles/cxx_shared.dir/__/src/algorithm.cpp.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP -DNDEBUG -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -D_ALLOW_MSC_VER_MISMATCH -D_CRTBLD -D_CRT_SECURE_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -IC:\Users\User\AppData\Roaming\libcxx-master\include -fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME -D_LIBCPP_NO_VCRUNTIME /MD /O2 /Ob2 /DNDEBUG /std:c++14 -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-compat -Wno-undef -Wno-reserved-id-macro -Wno-gnu-include-next -Wno-gcc-compat -Wno-zero-as-null-pointer-constant -Wno-deprecated-dynamic-exception-spec -Wno-sign-conversion -Wno-old-style-cast -Wno-deprecated -Wno-shift-sign-overflow -Wno-double-promotion -Wno-error -EHsc /Zl /showIncludes /Folib\CMakeFiles\cxx_shared.dir\__\src\algorithm.cpp.obj /Fdlib\CMakeFiles\cxx_shared.dir\ -c C:\Users\User\AppData\Roaming\libcxx-master\src\algorithm.cpp
In file included from C:\Users\User\AppData\Roaming\libcxx-master\src\algorithm.cpp:10:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\random:1645:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\istream:163:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\ostream:137:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\ios:215:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\__locale:23:
In file included from C:\Users\User\AppData\Roaming\libcxx-master\include\support/win32/locale_win32.h:15:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\xlocinfo.h:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\yvals.h:9:
In file included from C:\Program Files (x86)\Windows Kits\Include.0.17763.0\ucrt\crtdbg.h:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\vcruntime_new_debug.h:10:
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include\vcruntime_new.h(34,16): error: redefinition of 'nothrow_t'
struct nothrow_t {
^
C:\Users\User\AppData\Roaming\libcxx-master\include\new(123,25): note: previous definition is here
struct _LIBCPP_TYPE_VIS nothrow_t {};
^
这是我的 CMAKE。 (也试过 19.20)
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="C:/Program Files (x86)/Ninja/ninja.exe"
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe"
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME"
-DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe"
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows -D_LIBC_NO_VCRUNTIME -D_LIBCPP_NO_VCRUNTIME"
-DCMAKE_C_LINK_EXECUTABLE="C:/Program Files/LLVM/bin/lld-link.exe"
-DCMAKE_CXX_LINK_EXECUTABLE="C:/Program Files/LLVM/bin/lld-link.exe"
-DLLVM_USE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe"
-DLLVM_PATH="C:/Program Files/LLVM" -DLIBCXX_ENABLE_SHARED=YES
-DLIBCXX_ENABLE_STATIC=NO -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=YES
"C:/Users/User/AppData/Roaming/libcxx-master"
这是我的SDK
set LIB=C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\lib\x64;
C:\Program Files (x86)\Windows Kits\Lib.0.17763.0\ucrt\x64;
C:\Program Files (x86)\Windows Kits\Lib.0.17763.0\um\x64
我可以让它工作吗?在哪里发送问题给谁?
我在 VS2019 上遇到了同样的问题。
我删除了 no_runtime 标志但设置了
-DCMAKE_C_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DCMAKE_CXX_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
添加 -flavor link
并成功链接。我没有测试异常,但使用 std::thread
编译和运行的测试程序与使用 cl
编译器相同。
UPD:std::exception
抛出的基本 try-catch 有效
更新:完整的 cmake 批处理(您的路径可能会有所不同!)
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="D:/Programming/ninja-build/ninja.exe" ^
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="clang-cl.exe" ^
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows" ^
-DCMAKE_CXX_COMPILER="clang-cl.exe" ^
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=x86_64--windows " ^
-DCMAKE_C_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DCMAKE_CXX_LINK_EXECUTABLE="lld-link.exe -flavor link" ^
-DLLVM_USE_LINKER="lld-link.exe" ^
-DLLVM_PATH="C:/Program Files/LLVM" -DLIBCXX_ENABLE_SHARED=YES ^
-DLIBCXX_ENABLE_STATIC=NO -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=YES ^
"D:\Programming\cpp_sandbox\libcxx-9.0.0.src"