[libcxx-commits] [libcxx] 690a469 - [runtimes] Don't link against compiler-rt when we don't find it

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 24 07:33:23 PDT 2022


Author: Louis Dionne
Date: 2022-08-24T10:33:10-04:00
New Revision: 690a4692d1f34bd410f987acc9afcffd8c79bfa8

URL: https://github.com/llvm/llvm-project/commit/690a4692d1f34bd410f987acc9afcffd8c79bfa8
DIFF: https://github.com/llvm/llvm-project/commit/690a4692d1f34bd410f987acc9afcffd8c79bfa8.diff

LOG: [runtimes] Don't link against compiler-rt when we don't find it

Otherwise, we would end up passing `-lNOTFOUND` to the compiler, which
caused various compiler checks to fail and ended up breaking the build
in the most obscure ways. For example, checks for -faligned-allocation
would fail because the compiler would complain about an unknown library
called NOTFOUND, and we would end up not passing -faligned-allocation
anywhere in our build. This is madness.

An even better alternative would be to simply FATAL_ERROR if we don't
find the builtins library. However, it seems like our build has been
working fine without finding it for a while, so instead of making a
bunch of builds fail, we can figure out why linking against compiler-rt
doesn't actually seem to be required in a follow-up, and perhaps
relax that.

Added: 
    

Modified: 
    libcxx/cmake/config-ix.cmake
    libcxxabi/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 209e6214a4718..a5ce4745a5f6a 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -61,7 +61,11 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
     include(HandleCompilerRT)
     find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
                              FLAGS ${LIBCXX_COMPILE_FLAGS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXX_BUILTINS_LIBRARY}")
+    if (LIBCXX_BUILTINS_LIBRARY)
+      list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXX_BUILTINS_LIBRARY}")
+    else()
+      message(WARNING "Could not find builtins library from libc++")
+    endif()
   elseif (LIBCXX_HAS_GCC_LIB)
     list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
   elseif (LIBCXX_HAS_GCC_S_LIB)

diff  --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
index 079cabf25da5a..ff9a1bf349e52 100644
--- a/libcxxabi/cmake/config-ix.cmake
+++ b/libcxxabi/cmake/config-ix.cmake
@@ -41,7 +41,11 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
     include(HandleCompilerRT)
     find_compiler_rt_library(builtins LIBCXXABI_BUILTINS_LIBRARY
                              FLAGS "${LIBCXXABI_COMPILE_FLAGS}")
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXXABI_BUILTINS_LIBRARY}")
+    if (LIBCXXABI_BUILTINS_LIBRARY)
+      list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXXABI_BUILTINS_LIBRARY}")
+    else()
+      message(WARNING "Could not find builtins library from libc++abi")
+    endif()
   else ()
     if (LIBCXXABI_HAS_GCC_S_LIB)
       list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)


        


More information about the libcxx-commits mailing list