================
@@ -642,18 +642,8 @@ get_sanitizer_flags(SANITIZER_FLAGS 
"${LLVM_USE_SANITIZER}")
 
 # Link system libraries =======================================================
 function(cxx_link_system_libraries target)
-
-# In order to remove just libc++ from the link step
-# we need to use -nostdlib++ whenever it is supported.
-# Unfortunately this cannot be used universally because for example g++ 
supports
-# only -nodefaultlibs in which case all libraries will be removed and
-# all libraries but c++ have to be added in manually.
-  if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-    target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++")
-  else()
-    target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs")
-    target_add_compile_flags_if_supported(${target} PRIVATE "/Zl")
-    target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")
----------------
mstorsjo wrote:

Interesting; FWIW, it seems like the test for `/Zl` fails because it skips 
including the CRT glue code that takes the startup from the Windows specific 
`mainCRTStartup()` to the regular `main()`. I wonder when/if this test passed 
at some point.

As for how this works without those options: In MSVC build configs, the 
standard libraries usually aren't injected by the compiler when doing the link 
- on the contrary, in most cases, one doesn't actually do linking by invoking 
the compiler, but the build usually calls `link.exe` or `lld-link` directly. 
The info about what libraries should be linked in is conveyed via directives 
embedded in the object files. So as long as we're not using any MS STL headers 
that inject such directives, we don't automatically try to link against it.

Then secondly - in MSVC configurations, libc++ always builds on top of the MSVC 
C++ runtime for the base ABI stuff, so we actually do need it linked - and we 
pass the necessary libraries for that manually when we link our library.

https://github.com/llvm/llvm-project/pull/68832
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to