Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 622256 - dev-util/nvidia-cuda-toolkit-8.0.61 doesn't work with GCC >= 6
Summary: dev-util/nvidia-cuda-toolkit-8.0.61 doesn't work with GCC >= 6
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Science Related Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: gcc-6
  Show dependency tree
 
Reported: 2017-06-19 21:23 UTC by Karl-Johan Karlsson
Modified: 2017-07-06 09:17 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl-Johan Karlsson 2017-06-19 21:23:18 UTC
Trying to build CUDA code using dev-util/nvidia-cuda-toolkit-8.0.61 (latest version currently in Portage) and sys-devel/gcc-6.3.0 results in the error (this happens to be from media-libs/opensubdiv-3.1.1[cuda]):


   In file included from /opt/cuda/include/cuda_runtime.h:78:0,
                    from <command-line>:0:
   /opt/cuda/include/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 5 are not supported!
    #error -- unsupported GNU version! gcc versions later than 5 are not supported!
     ^~~~~


Trying to use dev-util/nvidia-cuda-toolkit-8.0.61-r1::seden, which just changes that 5 to a 6, results in hundreds of error from internal GCC header files. A random sample (again from building opensubdiv):


   /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/bits/move.h(47): error: expected a ";"

   /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/type_traits(71): error: identifier "constexpr" is undefined

   /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/type_traits(71): error: template parameter "_Tp" may not be redeclared in this scope

   /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/type_traits(71): error: expected a ";"


dev-util/nvidia-cuda-toolkit-8.0.61 RDEPENDs on ">=sys-devel/gcc-4.7[cxx]". This should probably be amended to set an upper bound as well, "<sys-devel/gcc-6".
Comment 1 Peter Levine 2017-07-06 04:27:09 UTC
(In reply to Karl-Johan Karlsson from comment #0)
> Trying to use dev-util/nvidia-cuda-toolkit-8.0.61-r1::seden, which just
> changes that 5 to a 6, results in hundreds of error from internal GCC header
> files.

Does adding '-std=c++98' to CXXFLAGS fix it?
Comment 2 Peter Levine 2017-07-06 06:29:03 UTC
(In reply to Peter Levine from comment #1)
> (In reply to Karl-Johan Karlsson from comment #0)
> > Trying to use dev-util/nvidia-cuda-toolkit-8.0.61-r1::seden, which just
> > changes that 5 to a 6, results in hundreds of error from internal GCC header
> > files.
> 
> Does adding '-std=c++98' to CXXFLAGS fix it?

Actually, a better option would be to add

-DCUDA_NVCC_FLAGS="-Xcompiler \"-std=c++98\""

to mycmakeargs in src_configure() in the ebuild itself.
Comment 3 Karl-Johan Karlsson 2017-07-06 07:26:25 UTC
(In reply to Peter Levine from comment #2)
> Actually, a better option would be to add
> 
> -DCUDA_NVCC_FLAGS="-Xcompiler \"-std=c++98\""
> 
> to mycmakeargs in src_configure() in the ebuild itself.

Doing that allows me to build media-libs/opensubdiv[cuda] with dev-util/nvidia-cuda-toolkit-8.0.61-r1::seden and sys-devel/gcc-6.3.0, and media-gfx/blender- 2.78a-r1 loads it at startup without complaining.
Comment 4 Guilherme Amadio gentoo-dev 2017-07-06 07:55:51 UTC
> /opt/cuda/include/host_config.h:119:2: error: 
>   #error -- unsupported GNU version! gcc versions later than 5 are not supported!

The CUDA toolkit has many patched headers that only work for the compiler versions they tested, hence the message above. Using CUDA with other compiler versions is not supported. Please file this bug upstream if you must use GCC 6.
Comment 5 Marius Brehler 2017-07-06 08:08:01 UTC
Support for GCC 6.x is included with CUDA 9, see https://devblogs.nvidia.com/parallelforall/cuda-9-features-revealed/
Comment 6 Karl-Johan Karlsson 2017-07-06 08:11:00 UTC
(In reply to Guilherme Amadio from comment #4)
> The CUDA toolkit has many patched headers that only work for the compiler
> versions they tested, hence the message above. Using CUDA with other
> compiler versions is not supported. Please file this bug upstream if you
> must use GCC 6.

That is not what this bug is about, and I disagree that it is resolved and that it is a matter for upstream.

At issue is the fact that the Gentoo package for dev-util/nvidia-cuda-toolkit-8.0.61 claims to run on >=sys-devel/gcc-4.7[cxx], when that is clearly false, since it refuses to run on >=sys-devel/gcc-6.
Comment 7 Guilherme Amadio gentoo-dev 2017-07-06 08:58:32 UTC
(In reply to Karl-Johan Karlsson from comment #6)
> (In reply to Guilherme Amadio from comment #4)
> > The CUDA toolkit has many patched headers that only work for the compiler
> > versions they tested, hence the message above. Using CUDA with other
> > compiler versions is not supported. Please file this bug upstream if you
> > must use GCC 6.
> 
> That is not what this bug is about, and I disagree that it is resolved and
> that it is a matter for upstream.
> 
> At issue is the fact that the Gentoo package for
> dev-util/nvidia-cuda-toolkit-8.0.61 claims to run on
> >=sys-devel/gcc-4.7[cxx], when that is clearly false, since it refuses to
> run on >=sys-devel/gcc-6.

Fair enough. I've fixed the ebuilds by adding the missing dependency.
Thanks for reporting.

commit b22237d973413d2c5ce17f574269f3c3698da1b8
Author: Guilherme Amadio <amadio@gentoo.org>
Date:   Thu Jul 6 10:51:46 2017 +0200

    dev-util/nvidia-cuda-toolkit: add missing dependency, bug #622256
    
    Support for GCC 6 is only available starting with CUDA 9:
    https://devblogs.nvidia.com/parallelforall/cuda-9-features-revealed
    
    Package-Manager: Portage-2.3.6, Repoman-2.3.2
Comment 8 Guilherme Amadio gentoo-dev 2017-07-06 09:12:19 UTC
Please notice, however, that the ebuild does not (and cannot) prevent users from having the right compilers installed, but setting the system compiler to an unsupported version, in which case compiling code with CUDA support with the system compiler will not work. Please make sure to select a supported compiler with gcc-config by hand when needed, or use gcc-5.x.y instead of just gcc when compiling the specific packages. In your case, you can do

$ CC=gcc-5.4.0 CXX=g++-5.4.0 emerge -av1 opensubdiv

However, doing that, I just noticed that opensubdiv itself has problems, so please open a separate bug for it.

I see the error below:
nvcc fatal   : Stray '"' character
CMake Error at osd_static_gpu_generated_cudaKernel.cu.o.Gentoo.cmake:224 (message):
  Error generating
  /var/tmp/portage/media-libs/opensubdiv-3.1.1/work/opensubdiv-3.1.1_build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/./osd_static_gpu_generated_cudaKernel.cu.o
Comment 9 Karl-Johan Karlsson 2017-07-06 09:17:08 UTC
(In reply to Guilherme Amadio from comment #8)
> However, doing that, I just noticed that opensubdiv itself has problems, so
> please open a separate bug for it.
> 
> I see the error below:
> nvcc fatal   : Stray '"' character

That's bug 605958.