[PATCH] D40660: Enable auto-linking on Windows

Saleem Abdulrasool via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 11:42:28 PST 2017


compnerd added inline comments.


================
Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
----------------
smeenai wrote:
> rnk wrote:
> > smeenai wrote:
> > > This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI thing.
> > I think if you're not using the MS ABI, you're probably using the GCC-style driver to compile and link, and that is what normally adds the C++ library to the link line.
> Yeah, that's fair.
Well, is it really a windows thing?  What about MinGW/cygwin?

The interesting thing here is that if you use the `itanium` environment, `-lc++` is added to the linker invocation (though it is the BFD linker rather than lld).  For the MSVC environment, which assumes a MS ABI style C++ library, we do not emit the `c++.lib`.  However, this would accomplish that.


================
Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+#     pragma comment(lib, "c++d.lib")
----------------
smeenai wrote:
> I guess `_DLL` is appropriate here. Ideally though I think adding the pragma should be keyed on exactly the same conditional that determines whether we annotate with dllexport/dllimport, and right now that's only conditional on `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
Its more complicated.  This is for the *user* not the library itself.  When building the shared library we need to ensure that it is not added (`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, the `_DLL` tells you about the dynamic/static behavior.


================
Comment at: include/__config:1269
+#     pragma comment(lib, "c++d.lib")
+#   else
+#     pragma comment(lib, "c++.lib")
----------------
rnk wrote:
> smeenai wrote:
> > We never create a `c++d.lib`, as far as I can see. It's always either `c++.lib` for the import library or `libc++.lib` for the static library.
> Yeah, I'd leave that out until we actually commit cmake or install scripts that make this library.
Okay, I can drop this bit of the diff.


https://reviews.llvm.org/D40660





More information about the llvm-commits mailing list