[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 7 04:07:45 PST 2017
EricWF added inline comments.
================
Comment at: CMakeLists.txt:43
+if (WIN32 AND NOT MINGW)
+ set(LIBCXX_TARGETING_WINDOWS ON)
+else()
----------------
EricWF wrote:
> smeenai wrote:
> > Not the biggest fan of this name, since it's not obvious why MinGW shouldn't count as targeting Windows. I thought of `LIBCXX_TARGETING_NATIVE_WINDOWS` or `LIBCXX_TARGETING_MSVCRT` instead, but MinGW is also native Windows and targets MSVCRT, so those names aren't any better from that perspective either. I can't think of anything else at the moment, but I'm sure there's a better name.
> Thanks for the feedback. I'm not exactly sure how this macro should be defined either.
>
> I thought that `MinGW` provided its own C library runtime wrappers that forward to `MSVCRT`.
>
> The difference I was imagining between Native Windows builds and `MinGW` is that it's possible to use
> `pthread` with `MinGW` but not with native Windows targets.
Another distinction I would like this macro to embody is whether on not the compiler defines `_MSC_VER`. `clang-cl`, `clang++` on Windows, and MSVC `cl` all define this macro.
================
Comment at: lib/CMakeLists.txt:112
+ add_library_flags(vcruntime) # C++ runtime
+ add_library_flags(msvcrt) # C runtime startup files
+ add_library_flags(iso_stdio_wide_specifiers)
----------------
halyavin wrote:
> halyavin wrote:
> > As far as I know, applications shouldn't use msvcrt.dll ([[ https://blogs.msdn.microsoft.com/oldnewthing/20140411-00/?p=1273 | Windows is not a Microsoft Visual C/C++ Run-Time delivery channel ]]) Can we survive on ucrt only?
> Oh, it is static library that doesn't correspond to a dll.
I don't think that link suggests that applications shouldn't link `msvcrt.dll`.
Instead all of the doc I see suggests that `msvcrt.dll` is linked implicitly by `/MD`. However since libc++ removes `/MD` and adds `/nodefaultlibs` we need to manually re-create the `/MD` link without the MSVC STL. That involves manually linking `msvcrt.dll`.
https://reviews.llvm.org/D28441
More information about the cfe-commits
mailing list