This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new e9bbf2928b7 libcxx: porting libcxx test.
e9bbf2928b7 is described below

commit e9bbf2928b78b46834d859af8c099be6900d62c3
Author: cuiziwei <[email protected]>
AuthorDate: Tue Nov 26 15:55:44 2024 +0800

    libcxx: porting libcxx test.
    
    porting libcxx test case to nuttx.
    
    Signed-off-by: cuiziwei <[email protected]>
---
 arch/sim/src/cmake/Toolchain.cmake |   4 +
 libs/libxx/Kconfig                 |   5 +
 libs/libxx/libcxx/CMakeLists.txt   | 196 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 202 insertions(+), 3 deletions(-)

diff --git a/arch/sim/src/cmake/Toolchain.cmake 
b/arch/sim/src/cmake/Toolchain.cmake
index fa1be1575b1..b5d87923a8c 100644
--- a/arch/sim/src/cmake/Toolchain.cmake
+++ b/arch/sim/src/cmake/Toolchain.cmake
@@ -220,6 +220,10 @@ if(CONFIG_LIBCXX)
   
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_LIBCPP_DISABLE_AVAILABILITY>)
 endif()
 
+if(CONFIG_LIBCXX_TEST)
+  add_link_options(-Wl,-latomic)
+endif()
+
 if(APPLE)
   add_link_options(-Wl,-dead_strip)
 else()
diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig
index 700a498078a..49206a4e6dd 100644
--- a/libs/libxx/Kconfig
+++ b/libs/libxx/Kconfig
@@ -137,4 +137,9 @@ config LIBCXX_VERSION
        depends on LIBCXX
        default "17.0.6"
 
+config LIBCXX_TEST
+       bool "LLVM Libcxx Library Test"
+       depends on LIBCXX && CXX_EXCEPTION
+       default n
+
 endif
diff --git a/libs/libxx/libcxx/CMakeLists.txt b/libs/libxx/libcxx/CMakeLists.txt
index 6cd63d4fc60..8f4b408c1b8 100644
--- a/libs/libxx/libcxx/CMakeLists.txt
+++ b/libs/libxx/libcxx/CMakeLists.txt
@@ -69,13 +69,17 @@ if(CONFIG_LIBCXX)
   nuttx_create_symlink(${CMAKE_CURRENT_LIST_DIR}/libcxx/include
                        ${CMAKE_BINARY_DIR}/include/libcxx)
 
-  configure_file(${CMAKE_CURRENT_LIST_DIR}/../__config_site
-                 ${CMAKE_BINARY_DIR}/include/libcxx/__config_site COPYONLY)
+  nuttx_create_symlink(${CMAKE_CURRENT_LIST_DIR}/../__config_site
+                       ${CMAKE_BINARY_DIR}/include/libcxx_config/__config_site)
 
   set_property(
     TARGET nuttx
     APPEND
-    PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/include/libcxx)
+    PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES
+             ${CMAKE_BINARY_DIR}/include/libcxx
+             ${CMAKE_BINARY_DIR}/include/libcxx_config
+             ${CMAKE_CURRENT_LIST_DIR}/libcxx/test/support
+             ${CMAKE_CURRENT_LIST_DIR}/libcxx/src)
 
   add_compile_definitions(_LIBCPP_BUILDING_LIBRARY)
   if(CONFIG_LIBSUPCXX_TOOLCHAIN)
@@ -142,4 +146,190 @@ if(CONFIG_LIBCXX)
   target_compile_options(libcxx PRIVATE ${FLAGS})
   target_include_directories(libcxx BEFORE
                              PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxx/src)
+
+  if(CONFIG_LIBCXX_TEST)
+    list(
+      APPEND
+      FLAGS
+      -Wno-array-bounds
+      -Wno-permissive
+      -Wno-unused-variable
+      -Wno-unused-but-set-variable
+      -Wno-psabi
+      -Wno-unused-local-typedefs
+      -Wno-unused-result
+      -Wno-unused-function
+      -Wno-undef
+      -Wno-return-type
+      -Wno-self-move
+      -Wno-class-memaccess
+      -Wno-tautological-compare
+      -Wno-narrowing
+      -Wno-use-after-free
+      -Wno-invalid-memory-model
+      -Wno-mismatched-new-delete)
+    add_compile_options(-UNDEBUG)
+    add_compile_definitions(
+      DISABLE_NEW_COUNT
+      _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+      _LIBCPP_ENABLE_DEBUG_MODE
+      _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+      _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+      _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
+      _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+      _LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+
+    set(i 0)
+    set(TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/libcxx/test")
+    file(GLOB_RECURSE TESTS "${TEST_DIR}/*.pass.cpp")
+    file(
+      GLOB
+      UNSUPPORTED_TESTS
+      # error: ‘_wremove’ was not declared in this scope
+      
${TEST_DIR}/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
+      
${TEST_DIR}/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
+      
${TEST_DIR}/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
+      
${TEST_DIR}/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
+      
${TEST_DIR}/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
+      # error: ‘x’ in ‘struct Foo’ does not name a type
+      
${TEST_DIR}/libcxx/selftest/compile.pass.cpp/compile-error.compile.pass.cpp
+      ${TEST_DIR}/libcxx/selftest/pass.cpp/compile-error.pass.cpp
+      ${TEST_DIR}/libcxx/selftest/link.pass.cpp/compile-error.link.pass.cpp
+      # error: ‘__sanitizer_verify_contiguous_container’ was not declared in
+      # this scope
+      ${TEST_DIR}/libcxx/containers/sequences/vector/asan.pass.cpp
+      # error: attributes are not allowed on a function-definition
+      
${TEST_DIR}/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
+      # fatal error: Block.h: No such file or directory
+      ${TEST_DIR}/libcxx/utilities/function.objects/func.blocks.pass.cpp
+      # link error
+      ${TEST_DIR}/libcxx/selftest/compile.pass.cpp/link-error.compile.pass.cpp
+      ${TEST_DIR}/libcxx/selftest/link.pass.cpp/link-error.link.pass.cpp
+      ${TEST_DIR}/libcxx/selftest/pass.cpp/link-error.pass.cpp
+      # std::views::join
+      ${TEST_DIR}/std/ranges/range.adaptors/range.join.view/adaptor.pass.cpp
+      
${TEST_DIR}/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
+      
${TEST_DIR}/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
+      
${TEST_DIR}/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
+      # no build __partition_chunks
+      ${TEST_DIR}/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp
+      # REQUIRES: c++98 || c++03 || c++11 || c++14
+      
${TEST_DIR}/std/containers/associative/multimap/multimap.value_compare/types.pass.cpp
+      
${TEST_DIR}/std/containers/associative/map/map.value_compare/types.pass.cpp
+      # std::result_of
+      
${TEST_DIR}/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
+      
${TEST_DIR}/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
+      ${TEST_DIR}/std/utilities/function.objects/func.invoke/invoke.pass.cpp
+      
${TEST_DIR}/std/utilities/function.objects/func.invoke/invoke_constexpr.pass.cpp
+      # WINT_MIN undef
+      ${TEST_DIR}/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
+      ${TEST_DIR}/std/input.output/file.streams/c.files/cinttypes.pass.cpp
+      # static assertion failed
+      ${TEST_DIR}/std/language.support/support.runtime/cstdlib.pass.cpp
+      # error: static assertion failed: Types differ unexpectedly
+      ${TEST_DIR}/std/strings/c.strings/cstring.pass.cpp
+      ${TEST_DIR}/std/strings/c.strings/cwchar.pass.cpp
+      # error: ‘is_literal_type_v’ is not a member of ‘std’
+      
${TEST_DIR}/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
+      ${TEST_DIR}/libcxx/containers/sequences/vector/asan.pass.cpp
+      # error: static assertion failed
+      
${TEST_DIR}/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
+      # unsport c++20
+      
${TEST_DIR}/std/utilities/memory/default.allocator/allocator_types.void.compile.pass.cpp
+      
${TEST_DIR}/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
+      
${TEST_DIR}/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
+      
${TEST_DIR}/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
+      
${TEST_DIR}/std/utilities/function.objects/func.require/binary_function.pass.cpp
+      
${TEST_DIR}/std/utilities/function.objects/func.require/unary_function.pass.cpp
+      ${TEST_DIR}/std/utilities/function.objects/refwrap/weak_result.pass.cpp
+      
${TEST_DIR}/std/utilities/function.objects/refwrap/binder_typedefs.compile.pass.cpp
+      
${TEST_DIR}/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
+      
${TEST_DIR}/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
+      # arm build error
+      ${TEST_DIR}/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
+      
${TEST_DIR}/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
+      
${TEST_DIR}/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
+    )
+
+    file(
+      GLOB_RECURSE
+      SKIP_TESTS
+      ${TEST_DIR}/libcxx/containers/views/mdspan/*.pass.cpp
+      ${TEST_DIR}/libcxx/input.output/iostream.format/print.fun/*.pass.cpp
+      ${TEST_DIR}/libcxx/ranges/range.factories/range.repeat.view/*.pass.cpp
+      ${TEST_DIR}/libcxx/utilities/expected/*.pass.cpp
+      # skip deprecated test
+      ${TEST_DIR}/libcxx/depr/*.pass.cpp
+      ${TEST_DIR}/std/depr/*.pass.cpp
+      
${TEST_DIR}/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/*.pass.cpp
+      # arm atomic undef
+      
${TEST_DIR}/std/atomics/atomics.types.operations/atomics.types.operations.req/*.pass.cpp
+      
${TEST_DIR}/std/atomics/atomics.types.operations/atomics.types.operations.wait/*.pass.cpp
+    )
+    list(REMOVE_ITEM TESTS ${UNSUPPORTED_TESTS} ${SKIP_TESTS})
+    foreach(TEST ${TESTS})
+      if(EXISTS ${TEST})
+        set(GREP_PATTERNS
+            "UNSUPPORTED: c++03, c++11, c++14, c++17, c++20"
+            "TEST_LIBCPP_ASSERT_FAILURE"
+            "static_assert(test"
+            "UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME"
+            "UNSUPPORTED: gcc"
+            "include <sstream>"
+            "std::ranges::join_view"
+            "std::binary_function"
+            "std::unary_function"
+            "std::binary_negate"
+            "std::not1"
+            "std::not2"
+            "std::unary_negate"
+            "std::raw_storage_iterator"
+            "void operator delete"
+            "filesystem_test_helper.h"
+            "asan_testing.h")
+
+        set(SKIP_TEST FALSE)
+
+        foreach(PATTERN IN LISTS GREP_PATTERNS)
+          execute_process(COMMAND grep -q "${PATTERN}" ${TEST}
+                          RESULT_VARIABLE grep_result)
+
+          if(grep_result EQUAL 0)
+            set(SKIP_TEST TRUE)
+            break()
+          endif()
+        endforeach()
+
+        if(SKIP_TEST)
+          continue()
+        endif()
+
+        execute_process(COMMAND grep -q "int main" ${TEST}
+                        RESULT_VARIABLE grep_result)
+        if(NOT grep_result EQUAL 0)
+          continue()
+        endif()
+
+        get_filename_component(TEST_NAME ${TEST} NAME_WE)
+        foreach(CHARACTER "+" "-" "=" "[]")
+          string(REPLACE "${CHARACTER}" "_" TEST_NAME "${TEST_NAME}")
+        endforeach()
+
+        nuttx_add_application(
+          NAME
+          ${TEST_NAME}_${i}
+          SRCS
+          ${TEST}
+          STACKSIZE
+          102400
+          COMPILE_FLAGS
+          ${FLAGS})
+        set_source_files_properties(
+          
${TEST_DIR}/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp
+          PROPERTIES COMPILE_FLAGS -fno-exceptions)
+        math(EXPR i "${i}+1")
+      endif()
+    endforeach()
+  endif()
+
 endif()

Reply via email to