cccl icon indicating copy to clipboard operation
cccl copied to clipboard

[BUG]: compile error with c++20

Open mhkim90 opened this issue 1 year ago • 1 comments

Is this a duplicate?

  • [x] I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Compile-time Error

Component

Thrust

Describe the bug

Build time failure:

In file included from /usr/local/cuda/include/cuda/std/tuple:18,
                 from /usr/local/cuda/include/thrust/tuple.h:36,
                 from /usr/local/cuda/include/thrust/detail/tuple_transform.h:21,
                 from /usr/local/cuda/include/thrust/detail/raw_reference_cast.h:23,
                 from /usr/local/cuda/include/thrust/system/cuda/detail/malloc_and_free.h:23,
                 from /usr/local/cuda/include/thrust/system/detail/adl/malloc_and_free.h:42,
                 from /usr/local/cuda/include/thrust/system/detail/generic/memory.inl:22,
                 from /usr/local/cuda/include/thrust/system/detail/generic/memory.h:69,
                 from /usr/local/cuda/include/thrust/detail/reference.h:28,
                 from /usr/local/cuda/include/thrust/memory.h:26,
                 from /usr/local/cuda/include/thrust/device_ptr.h:25,
                 from /cuda_test/test.h:3,
                 from /cuda_test/test.cpp:1:
/usr/local/cuda/include/cuda/std/detail/libcxx/include/tuple: In substitution of 'template<class ... _Tp> template<class _Tuple> template<class _Tuple2> using _PreferTupleLikeConstructor = cuda::std::__4::__tuple_constraints<_Tp>::__valid_tuple_like_constraints_rank_one<_Tuple>::_PreferTupleLikeConstructorImpl<_Tuple2> [with _Tuple2 = _Tuple; _Tuple = _Tuple; _Tp = {_Tp ...}]':
/usr/local/cuda/include/cuda/std/detail/libcxx/include/tuple:647:43:   required from here
/usr/local/cuda/include/cuda/std/detail/libcxx/include/tuple:647:43: internal compiler error: Segmentation fault
  647 |         _PreferTupleLikeConstructor<_Tuple>::value;

It happens after the commit:

commit 61c1fd043ac0942805bab97429fdf72242182314
Author: Michael Schellenberger Costa <[email protected]>
Date:   Fri Oct 20 03:57:20 2023 -0700

    Replace `thrust::tuple` implementation with `cuda::std::tuple` (#262)

The compile error occurs even though only a thrust header is included without actual code. It may be a gcc issue, but I don't know the cause right now.

How to Reproduce

Environment

System: RHEL 8.6 GCC: 10.2.1 20201112 (Red Hat 10.2.1-8) CMake: 3.23.2 CUDA: 12.6.1

CMakeList.txt

cmake_minimum_required(VERSION 3.10)

project(test)

set(CMAKE_CXX_STANDARD 20)

INCLUDE_DIRECTORIES("/usr/local/cuda/include;")

set(CUDA_TOOLKIT_ROOT_DIR "/usr/local/cuda") 
find_package(CUDA)

SET(CMAKE_CXX_FLAGS "")

add_executable(test
    test.cpp
)

find_library(cudart NAME libcudart.so HINTS "/usr/local/cuda/targets/x86_64-linux/lib")

target_link_libraries(test PRIVATE ${cudart})

test.cpp

#include "test.h"
#include <iostream>

int main(int argc, char** argv) {
    return 0;
}

test.h

#pragma once

#include <thrust/device_ptr.h>

namespace util {

}

Expected behavior

Build success

Reproduction link

No response

Operating System

RHEL 8.6

nvidia-smi output

I think the issue is not related to it.

NVCC version

I think it is not related to nvcc.

mhkim90 avatar Oct 01 '24 05:10 mhkim90

thanks for reporting. I opened an internal bug to track the issue (nvbug 4889562)

fbusato avatar Oct 01 '24 16:10 fbusato

The compiler team replied that the error is reported by GCC, not nvcc. They also tried to reproduce the bug, but without success. I've tried the same with similar configurations and can't reproduce the bug.

fbusato avatar Oct 04 '24 22:10 fbusato

Hi,

I tried it with more recent version of gcc 10 (gcc-10.3.1-1.2.0.1), it is now successfully compiled. So it seems to happen only older version of gcc 10 (gcc-10.2.1-8.2.0.1)

Feel free to close the issue.

Thanks.

mhkim90 avatar Oct 04 '24 23:10 mhkim90

To be a more specific here, we always require the latest version of a given host compiler, so for gcc-10 that would be gcc-10.5

That is due to the fact that new minor versions of compilers do not introduce breaking changes but do fix critical bugs.

miscco avatar Oct 14 '24 09:10 miscco