Skip to content

Commit

Permalink
Fix building with gcc-6 and make the test suite pass (NVIDIA#485)
Browse files Browse the repository at this point in the history
* Add gcc-6 image

* Avoid build breaks due to gcc-6

* Disable failing libcxx tests for gcc-6

* Make tests pass with gcc-6 and c++14

* Make tests pass with gcc-6 and c++17
  • Loading branch information
miscco authored Jun 21, 2023
1 parent 1b7898c commit 182d197
Show file tree
Hide file tree
Showing 53 changed files with 92 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ static_assert(!cuda::std::__is_implicitly_default_constructible<NonDefaultConstr
static_assert(!cuda::std::__is_implicitly_default_constructible<NonDefaultConstructible3>::value, "");
static_assert(!cuda::std::__is_implicitly_default_constructible<ProtectedDefaultConstructible>::value, "");
static_assert(!cuda::std::__is_implicitly_default_constructible<PrivateDefaultConstructible>::value, "");
#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6 // GCC 6 complains about implicit conversion
static_assert(!cuda::std::__is_implicitly_default_constructible<ProtectedDefaultConstructibleWithBase>::value, "");
static_assert(!cuda::std::__is_implicitly_default_constructible<PrivateDefaultConstructibleWithBase>::value, "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6

int main(int, char**) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
// explicit front_insert_iterator(Cont& x);

#include <cuda/std/iterator>

#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
// operator=(const Cont::value_type& value);

#include <cuda/std/iterator>

#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include <cuda/std/cassert>
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
// front_insert_iterator<Cont>& operator*();

#include <cuda/std/iterator>

#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include <cuda/std/cassert>
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// front_insert_iterator<Cont> operator++(int);

#include <cuda/std/iterator>
#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include <cuda/std/cassert>
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// front_insert_iterator<Cont>& operator++();

#include <cuda/std/iterator>
#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include <cuda/std/cassert>
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// front_inserter(Cont& x);

#include <cuda/std/iterator>
#include <cuda/std/cassert>
#if defined(_LIBCUDACXX_HAS_LIST)
#include <cuda/std/list>
#endif
#include <cuda/std/cassert>
#include "nasty_containers.h"
#endif // _LIBCUDACXX_HAS_LIST

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// The following compilers don't like "cuda::std::byte b1{1}"
// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0
// UNSUPPORTED: gcc-6

int main(int, char**) {
constexpr cuda::std::byte b{42};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ constexpr void test_sfinae() {
struct NoCopy {
NoCopy() = default;
__host__ __device__
constexpr NoCopy(const NoCopy&);
constexpr NoCopy(const NoCopy&) = delete;
__host__ __device__
constexpr cuda::std::expected<int, TestError> operator()(const NoCopy&&) { return 1; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ constexpr void test_sfinae() {
struct NoCopy {
NoCopy() = default;
__host__ __device__
constexpr NoCopy(const NoCopy&);
constexpr NoCopy(const NoCopy&) = delete;
__host__ __device__
constexpr cuda::std::expected<int, TestError> operator()(const NoCopy&&) { return 1; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ constexpr void test_sfinae() {
struct NoCopy {
NoCopy() = default;
__host__ __device__
constexpr NoCopy(const NoCopy&);
constexpr NoCopy(const NoCopy&) = delete;
__host__ __device__
constexpr int operator()(const NoCopy&&) { return 1; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ constexpr void test_sfinae() {
struct NoCopy {
NoCopy() = default;
__host__ __device__
constexpr NoCopy(const NoCopy&);
constexpr NoCopy(const NoCopy&) = delete;
__host__ __device__
constexpr int operator()(const NoCopy&&) { return 42; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: gcc-6

// Older Clangs do not support the C++20 feature to constrain destructors

// friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: gcc-7, gcc-8, gcc-9
// UNSUPPORTED: gcc-6, gcc-7, gcc-8, gcc-9

// template<class E> unexpected(E) -> unexpected<E>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: gcc-6

// Older Clangs do not support the C++20 feature to constrain destructors

// friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(swap(x,y)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: gcc-6

// functional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: gcc-6

// TODO: there's multiple failures that appear to be all about overload resolution and SFINAE,
// and they will require further debugging to pinpoint the root cause of (almost certainly a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// XFAIL: gcc-7
// XFAIL: gcc-6, gcc-7

// <functional>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: gcc-6

// <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: gcc-6

// <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: gcc-6

// <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ int main(int, char**)
#endif
test_throws();

#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
static_assert(pr38638(3) == 5, "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ int main(int, char**)
{
{
using O = optional<int>;
#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
static_assert(assign_empty(O{42}), "");
static_assert(assign_value(O{42}), "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
assert(assign_empty(O{42}));
assert(assign_value(O{42}));
}
{
using O = optional<TrivialTestTypes::TestType>;
#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
static_assert(assign_empty(O{42}), "");
static_assert(assign_value(O{42}), "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
assert(assign_empty(O{42}));
assert(assign_value(O{42}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,19 @@ int main(int, char**)
}
{
using O = optional<int>;
#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
static_assert(assign_empty(O{42}), "");
static_assert(assign_value(O{42}), "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
assert(assign_empty(O{42}));
assert(assign_value(O{42}));
}
{
using O = optional<TrivialTestTypes::TestType>;
#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
static_assert(assign_empty(O{42}), "");
static_assert(assign_value(O{42}), "");
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
assert(assign_empty(O{42}));
assert(assign_value(O{42}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// is provided explicitly instead of being deduced, it compiles the test fine.
// Given that the deduction guide is trivial, this appears to be a compiler bug,
// so just don't run this test on GCC 7.
// UNSUPPORTED: gcc-7
// UNSUPPORTED: gcc-6, gcc-7

// template<class T>
// optional(T) -> optional<T>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ int main(int, char**)
constexpr optional<X> opt(X{});
#if defined(_LIBCUDACXX_ADDRESSOF)
static_assert(opt->test() == 3, "");
#else
unused(opt);
#endif
}
{
Expand All @@ -68,6 +70,8 @@ int main(int, char**)
constexpr optional<Z> opt(Z{});
#if defined(_LIBCUDACXX_ADDRESSOF)
static_assert(opt->test() == 1, "");
#else
unused(opt);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: gcc-6

// <cuda/std/optional>

// template <class T> void swap(optional<T>& x, optional<T>& y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: nvrtc
// UNSUPPORTED: gcc-6

// <cuda/std/tuple>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: gcc-6


// <cuda/std/tuple>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: nvrtc
// UNSUPPORTED: gcc-6
// UNSUPPORTED: windows
// We run out of heap space with windows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: nvrtc
// UNSUPPORTED: gcc-6


// <cuda/std/tuple>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: gcc-6


// <cuda/std/tuple>
Expand Down
4 changes: 2 additions & 2 deletions .upstream-tests/utils/libcudacxx/test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,12 @@ def configure_default_compile_flags(self):
if self.cxx.type == 'gcc':
maj_v, _, _ = self.cxx.version
maj_v = int(maj_v)
if maj_v < 7:
if maj_v < 6:
possible_stds.remove('c++1z')
possible_stds.remove('c++17')
# FIXME: How many C++14 tests actually fail under GCC 5 and 6?
# Should we XFAIL them individually instead?
if maj_v <= 6:
if maj_v < 6:
possible_stds.remove('c++14')
for s in possible_stds:
cxx = self.cxx
Expand Down
13 changes: 13 additions & 0 deletions environments/linux/docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ services:


### Ubuntu 18.04 images:
gcc-6:
extends:
service: ubuntu18.04
image: "libcudacxx/gcc-6"
container_name: gcc-6
profiles: ["gcc-6", "all", "base"]
build:
context: ../../../
dockerfile: environments/linux/docker/ubuntu.base.Dockerfile
target: libcudacxx-configured
args:
HOST_CXX: "g++-6"

gcc-7:
extends:
service: ubuntu18.04
Expand Down
5 changes: 3 additions & 2 deletions include/cuda/std/detail/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -2126,8 +2126,9 @@ extern "C" _LIBCUDACXX_FUNC_VIS void __sanitizer_annotate_contiguous_container(
// macro is used to mark them as such, which suppresses the
// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
// with these classes.
#if _LIBCUDACXX_STD_VER >= 17
# define _LIBCUDACXX_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
#if (!defined(_LIBCUDACXX_COMPILER_GCC) || __GNUC__ > 6) \
&& _LIBCUDACXX_STD_VER >= 17
# define _LIBCUDACXX_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
template <class ..._Tag> \
_ClassName(typename _Tag::__allow_ctad...) -> _ClassName<_Tag...>
#else
Expand Down
Loading

0 comments on commit 182d197

Please sign in to comment.