diff --git a/.upstream-tests/test/host_only/CMakeLists.txt b/.upstream-tests/test/host_only/CMakeLists.txt index 33b1f74409..2efcd47d81 100644 --- a/.upstream-tests/test/host_only/CMakeLists.txt +++ b/.upstream-tests/test/host_only/CMakeLists.txt @@ -1,4 +1,13 @@ -function(libcudacxx_add_standalone_header_test test_file_output_var header_under_test) +add_custom_target(libcudacxx_tu_tests) + +set(cpp_std_versions 11 14 17 20) + +set(cpp_11_exclusions) +set(cpp_14_exclusions) +set(cpp_17_exclusions) +set(cpp_20_exclusions) + +function(libcudacxx_add_standalone_header_test test_file_output_var header_under_test version) # ex: build/.../header_tests/cuda/std/version.cpp set(test_cpp "${CMAKE_CURRENT_BINARY_DIR}/header_tests/${header_under_test}.cpp") @@ -9,22 +18,46 @@ function(libcudacxx_add_standalone_header_test test_file_output_var header_under set(${test_file_output_var} ${test_cpp} PARENT_SCOPE) # ex: cuda/std/version -> cuda_std_version - string(REPLACE "/" "_" executable_name ${header_under_test}) - add_executable(${executable_name} ${test_cpp}) - target_include_directories(${executable_name} PRIVATE ${CMAKE_SOURCE_DIR}/include) - target_compile_options(${executable_name} PRIVATE + + string(REPLACE "/" "_" executable_name "${header_under_test}-${version}") + list(FIND cpp_${version}_exclusions ${header_under_test} header_excluded) + + if ("${header_excluded}" EQUAL "-1") + add_library(${executable_name} OBJECT ${test_cpp}) + target_include_directories(${executable_name} PRIVATE ${CMAKE_SOURCE_DIR}/include) + target_compile_options(${executable_name} PRIVATE $<$,$,$>: - -Wall -Werror> + -Wall -Werror> $<$: - /W4 /WX>) - set_target_properties(${executable_name} PROPERTIES CXX_STANDARD 11) + /W4 /WX>) + set_target_properties(${executable_name} PROPERTIES CXX_STANDARD ${version}) + set_target_properties(${executable_name} PROPERTIES CXX_STANDARD_REQUIRED ON) + set_target_properties(${executable_name} PROPERTIES CXX_EXTENSIONS OFF) + add_dependencies(libcudacxx_tu_tests ${executable_name}) + endif() + endfunction() # Don't generate CUDA targets, they fail currently. # file(GLOB cuda_headers LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/cuda/*) file(GLOB cuda_std_headers LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/cuda/std/*) -foreach(header IN LISTS cuda_headers cuda_std_headers) - libcudacxx_add_standalone_header_test(test_file ${header}) - message(STATUS "Detected ${header} ... Writing ${test_file}") +foreach(version IN LISTS cpp_std_versions) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(cxx_version "/std:c++${version}") + else() + set(cxx_version "-std=c++${version}") + endif() + + try_compile( + dialect_supported + ${CMAKE_BINARY_DIR}/dialect_check_${version} "${CMAKE_CURRENT_SOURCE_DIR}/detect_dialect.cpp" + COMPILE_DEFINITIONS ${cxx_version} + ) + + if (dialect_supported) + foreach(header IN LISTS cuda_headers cuda_std_headers) + libcudacxx_add_standalone_header_test(test_file ${header} ${version}) + endforeach() + endif() endforeach() diff --git a/.upstream-tests/test/host_only/detect_dialect.cpp b/.upstream-tests/test/host_only/detect_dialect.cpp new file mode 100644 index 0000000000..cef4fc92f7 --- /dev/null +++ b/.upstream-tests/test/host_only/detect_dialect.cpp @@ -0,0 +1,7 @@ +#include +#include +#include + +int main() { + return 0; +} diff --git a/.upstream-tests/test/std/views/views.span/span.cons/deduct.pass.cpp b/.upstream-tests/test/std/views/views.span/span.cons/deduct.pass.cpp index c7ea5fe3e6..c89162dff0 100644 --- a/.upstream-tests/test/std/views/views.span/span.cons/deduct.pass.cpp +++ b/.upstream-tests/test/std/views/views.span/span.cons/deduct.pass.cpp @@ -8,6 +8,9 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// gcc-6 does not support deduction guides until 7 +// UNSUPPORTED: gcc-6 + // // template @@ -94,6 +97,6 @@ int main(int, char**) test_iterator_sentinel(); test_c_array(); test_std_array(); - + return 0; } diff --git a/environments/linux/docker/compose.yml b/environments/linux/docker/compose.yml index 7f8db363a2..5c2715b648 100644 --- a/environments/linux/docker/compose.yml +++ b/environments/linux/docker/compose.yml @@ -14,7 +14,7 @@ services: args: &ubuntu22-args BUILDKIT_INLINE_CACHE: "1" USE_LLVM_INSTALLER: "1" - ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04" + ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu22.04" COMPILERS: "g++-11 g++-12 clang-11 clang-12 clang-13 clang-14 clang-15" deploy: &deploy-template resources: @@ -38,7 +38,7 @@ services: args: &ubuntu20-args BUILDKIT_INLINE_CACHE: "1" USE_LLVM_INSTALLER: 0 - ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04" + ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu20.04" COMPILERS: "g++-8 g++-9 g++-10 clang-8 clang-9 clang-10" deploy: *deploy-template @@ -56,7 +56,7 @@ services: args: &ubuntu18-args BUILDKIT_INLINE_CACHE: "1" USE_LLVM_INSTALLER: 0 - ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu18.04" + ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu18.04" COMPILERS: "g++-6 g++-7 clang-7" deploy: *deploy-template diff --git a/environments/linux/docker/ubuntu.base.Dockerfile b/environments/linux/docker/ubuntu.base.Dockerfile index 611d67e01c..e657041cd6 100644 --- a/environments/linux/docker/ubuntu.base.Dockerfile +++ b/environments/linux/docker/ubuntu.base.Dockerfile @@ -77,6 +77,7 @@ ADD ./.upstream-tests/utils /libcudacxx/utils # Install compiler and configure project RUN cmake -S /libcudacxx -B /build \ + -G Ninja \ -DLIBCUDACXX_ENABLE_STATIC_LIBRARY=OFF \ -DLIBCUDACXX_ENABLE_LIBCUDACXX_TESTS=ON \ -DLIBCUDACXX_ENABLE_LIBCXX_TESTS=ON \ @@ -88,8 +89,8 @@ RUN cmake -S /libcudacxx -B /build \ -DCMAKE_CUDA_COMPILER=${CUDACXX_PATH} \ -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" -RUN make -j -C /build/libcxx -RUN make -j -C /build/test/host_only +RUN ninja -C /build libcudacxx_tu_tests && ninja -C /build clean +RUN ninja -C /build cxx ENV LIBCUDACXX_SITE_CONFIG=/build/test/lit.site.cfg ENV LIBCXX_SITE_CONFIG=/build/libcxx/test/lit.site.cfg diff --git a/include/cuda/std/detail/libcxx/include/span b/include/cuda/std/detail/libcxx/include/span index 595e835eaf..ac230d3534 100644 --- a/include/cuda/std/detail/libcxx/include/span +++ b/include/cuda/std/detail/libcxx/include/span @@ -226,11 +226,11 @@ public: #endif template ::value, nullptr_t> = nullptr> - _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 + _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 span( array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} template ::value, nullptr_t> = nullptr> - _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 + _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} template __as_bytes() const noexcept { return {reinterpret_cast(data()), size_bytes()}; } @@ -528,7 +528,7 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept #endif // _LIBCUDACXX_STD_VER > 11 -#if _LIBCUDACXX_STD_VER > 14 +#if _LIBCUDACXX_STD_VER > 14 && !defined(_LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES) // Deduction guides template diff --git a/include/cuda/std/detail/libcxx/include/support/win32/limits_msvc_win32.h b/include/cuda/std/detail/libcxx/include/support/win32/limits_msvc_win32.h index dc2e0e1cf7..bc5ed15152 100644 --- a/include/cuda/std/detail/libcxx/include/support/win32/limits_msvc_win32.h +++ b/include/cuda/std/detail/libcxx/include/support/win32/limits_msvc_win32.h @@ -64,8 +64,14 @@ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L // __builtin replacements/workarounds +#if _MSC_VER < 1934 #define __builtin_huge_vall() _LInf._Long_double #define __builtin_nanl(__dummmy) _LNan._Long_double #define __builtin_nansl(__dummy) _LSnan._Long_double +#else +#define __builtin_huge_vall() __builtin_huge_val() +#define __builtin_nanl(__v) __builtin_nan(__v) +#define __builtin_nansl(__v) __builtin_nans(__v) +#endif #endif // _LIBCUDACXX_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H