[libc-commits] [libc] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

Louis Dionne via libc-commits libc-commits at lists.llvm.org
Thu Oct 12 20:47:46 PDT 2023


================
@@ -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")
----------------
ldionne wrote:

@mstorsjo FYI, I checked a recent Clang-CL (DLL) job like https://buildkite.com/llvm-project/libcxx-ci/builds/30715#018b257a-9457-4020-a4d0-3d22d4704e25 and it seems like `/nodefaultlib` and `/Zl` are never detected as supported on Windows. Hence, we were never actually enabling those flags.

I'm not certain how the Windows build works without that but it seems like it does.

https://github.com/llvm/llvm-project/pull/68832


More information about the libc-commits mailing list