From c945ad4df0d6b81d49d3dff6f42d34a97c755265 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 5 Dec 2017 19:32:49 +0000 Subject: [PATCH] Enable auto-linking on Windows The MSVC driver and clang do not link against the C++ runtime explicitly. Instead, they rely on the auto-linking via the pragma (through `use_ansi.h`) to link against the correct version of the C++ runtime. Attempt to do something similar here so that linking real C++ code on Windows does not require the user to explicitly specify `c++.lib` when using libc++ as a C++ runtime on windows. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319816 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/__config b/include/__config index c3c92af32..0d933f806 100644 --- a/include/__config +++ b/include/__config @@ -1265,6 +1265,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( # endif #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) +#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) +# if defined(_DLL) +# pragma(lib, "c++.lib") +# else +# pragma(lib, "libc++.lib") +# endif +#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) #endif // __cplusplus