FS#29359 - [cuda-toolkit] Incompatibility with GCC 4.7

Attached to Project: Community Packages
Opened by Anonymous (Kyouko) - Monday, 09 April 2012, 17:08 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Saturday, 24 November 2012, 01:52 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 5
Private No

Details

Description:
nvcc compiler is currently incompatible with GCC 4.7. http://forums.developer.nvidia.com/devforum/discussion/6336/cuda-sdk-4-1-and-gcc-4-7-0/p1
I think the dependency gcc<=4.6.3 should be added.

Steps to reproduce:

1) Create test file:
[test.cu]
#include <iostream>
int main ()
{
std::cout<<"Hello world!";
return 0;
}
[/test.cu]

2) Try to compile it:
# nvcc test.cu

Errors:

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h(48): error: identifier "__atomic_fetch_add" is undefined

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h(52): error: identifier "__atomic_fetch_add" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_000023a4_00000000-4_main.cpp1.ii".
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Saturday, 24 November 2012, 01:52 GMT
Reason for closing:  Upstream
Additional comments about closing:  See comments.
Comment by Jelle van der Waa (jelly) - Monday, 09 April 2012, 17:30 GMT
Ewww, double compilers in our repos is bad. We need some magic patching to fix this ;)
Comment by pavan yalamanchili (pavanky) - Wednesday, 09 May 2012, 05:19 GMT
  • Field changed: Percent Complete (100% → 0%)
There is a patch that can be applied trivially. There is a suggestion made here: http://forums.developer.nvidia.com/devforum/discussion/6336/cuda-sdk-4-1-and-gcc-4-7-0/p1

Other than that, there may be other tags that we may need to undef. Currently, undefing the following in cuda.h helps

#undef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_USE_INT128

I can send in a patch (pretty trivial actually) if that helps. I think it would be nice if this is added as a comment atleast.
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 09 May 2012, 05:34 GMT
Please do send the patch.
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 13 May 2012, 22:56 GMT
pavanky, are you going to send the patch?
Comment by pavan yalamanchili (pavanky) - Monday, 14 May 2012, 01:52 GMT
sven, I had a busy week. Sorry about the delay.
The patch I thought would work isnt. The two undefs have to be included in the .cu files before any other header.
Trying to push it up to any of the header files didn't work.
Sorry about the false hopes. I am trying to hack with the cuda/bin/nvcc.profile to see if something can be done.
Can you close this for now, I will contact you directly with the patch if I can finally fix it.
Comment by Paul Hollensen (pallegro) - Wednesday, 14 November 2012, 23:54 GMT
nvcc --pre-include /usr/local/include/undef_atomics_int128.h $@
(which just contains the two undefs above) works for me. Are there pitfalls with routing calls to nvcc through a shell script?
Comment by pavan yalamanchili (pavanky) - Saturday, 17 November 2012, 00:15 GMT
Paul, Thanks for that!

I can confirm this works for me as well.

#!/bin/sh
DIR=$(dirname $0)
$DIR/nvcc.bin --pre-include /usr/local/include/gcc_cuda_compat.h $@
Comment by Sven-Hendrik Haase (Svenstaro) - Saturday, 24 November 2012, 01:52 GMT
I looked at the possible solutions and since a quick Google handily reveals the undefs required to work with gcc 4.7, I'm going to leave it at that. I'm not going to route nvcc through some shell script that will occlude this problem from our users. That is not the Arch way. As such, I'm going to close this as it is fairly easily fixable and it's definitely an upstream problem.

Loading...