[llvm-bugs] [Bug 51774] New: Attempt to build memory sanitized libc++ with compiler-rt and libunwind fails

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 6 20:07:24 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51774

            Bug ID: 51774
           Summary: Attempt to build memory sanitized libc++ with
                    compiler-rt and libunwind fails
           Product: libc++
           Version: 12.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nehaljw.kkd1 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 25235
  --> https://bugs.llvm.org/attachment.cgi?id=25235&action=edit
BugFix in CMake logic for computing CMAKE_REQUIRED_FLAGS

The following configure and build commands succeed on 12.0.1:

cmake -S llvm-project/llvm/ -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind" -DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++ -DLIBCXX_USE_COMPILER_RT=ON -DLLVM_BUILD_TESTS=OFF
-DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD=X86
-DLIBCXXABI_USE_LLVM_UNWINDER=ON

cmake --build build -- cxx

However, if I try to configure a memory sanitized build:

cmake -S llvm-project/llvm/ -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind" -DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++ -DLIBCXX_USE_COMPILER_RT=ON -DLLVM_BUILD_TESTS=OFF
-DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD=X86
-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLLVM_USE_SANITIZER=MemoryWithOrigins

And then try to build it:

cmake --build build -- cxx

It fails with:
In file included from
/spare/local/nehal/ossrepos/llvm-project/libcxx/src/condition_variable_destructor.cpp:15:
In file included from
/spare/local/nehal/ossrepos/build/include/c++/v1/__threading_support:15:
In file included from
/spare/local/nehal/ossrepos/build/include/c++/v1/chrono:830:
In file included from
/spare/local/nehal/ossrepos/build/include/c++/v1/ratio:81:
/spare/local/nehal/ossrepos/build/include/c++/v1/cstdint:152:8: error: no
member named 'int8_t' in the global namespace; did you mean '__int8_t'?
using::int8_t;
     ~~^~~~~~
       __int8_t

The primary reason behind this failure is the absence of the -nostdinc++ flag 
while compiling the file. And it isn't passed because of a bug in
llvm-project/libcxx/cmake/config-ix.cmake which generates incorrect value for
CMAKE_REQUIRED_FLAGS.

The diff below:

diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 894f637f814f..5d1c664f01ef 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -78,6 +78,8 @@ int main() { return 0; }
   cmake_pop_check_state()
 endif()

+message(FATAL_ERROR "${CMAKE_REQUIRED_FLAGS}")
+
 # Check libraries
 if(WIN32 AND NOT MINGW)
   # TODO(compnerd) do we want to support an emulation layer that allows for
the

Outputs:

-Werror=unguarded-availability-new -nodefaultlibs;-rtlib=compiler-rt
-fno-sanitize=all

Notice the flags are two separate strings (as entries of a list), but they
should actually be a single string.

This is also backed by the fact that the configure step reports many 'support'
failures as well:
...
-- Performing Test LIBCXX_SUPPORTS_FNO_OMIT_FRAME_POINTER_FLAG
-- Performing Test LIBCXX_SUPPORTS_FNO_OMIT_FRAME_POINTER_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_GLINE_TABLES_ONLY_FLAG
-- Performing Test LIBCXX_SUPPORTS_GLINE_TABLES_ONLY_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_FALIGNED_ALLOCATION_FLAG
-- Performing Test LIBCXX_SUPPORTS_FALIGNED_ALLOCATION_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_NOSTDINCXX_FLAG
-- Performing Test LIBCXX_SUPPORTS_NOSTDINCXX_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_EQ_HIDDEN_FLAG
-- Performing Test LIBCXX_SUPPORTS_FVISIBILITY_EQ_HIDDEN_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WALL_FLAG
-- Performing Test LIBCXX_SUPPORTS_WALL_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WEXTRA_FLAG
-- Performing Test LIBCXX_SUPPORTS_WEXTRA_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_W_FLAG
-- Performing Test LIBCXX_SUPPORTS_W_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WWRITE_STRINGS_FLAG
-- Performing Test LIBCXX_SUPPORTS_WWRITE_STRINGS_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_LONG_LONG_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_LONG_LONG_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG
-- Performing Test LIBCXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WEXTRA_SEMI_FLAG
-- Performing Test LIBCXX_SUPPORTS_WEXTRA_SEMI_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_USER_DEFINED_LITERALS_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_USER_DEFINED_LITERALS_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_COVERED_SWITCH_DEFAULT_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_SUGGEST_OVERRIDE_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_SUGGEST_OVERRIDE_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_IGNORED_ATTRIBUTES_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_IGNORED_ATTRIBUTES_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_WNO_ERROR_FLAG
-- Performing Test LIBCXX_SUPPORTS_WNO_ERROR_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_EHSC_FLAG
-- Performing Test LIBCXX_SUPPORTS_EHSC_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_ZL_FLAG
-- Performing Test LIBCXX_SUPPORTS_ZL_FLAG - Failed
-- Performing Test LIBCXX_SUPPORTS_NODEFAULTLIB_FLAG
-- Performing Test LIBCXX_SUPPORTS_NODEFAULTLIB_FLAG - Failed
...


The attached patch fixes the reported issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210907/9dd650d5/attachment-0001.html>


More information about the llvm-bugs mailing list