FS#55795 - [cuda][cmake] cannot complile CUDA projects

Attached to Project: Community Packages
Opened by Sebastiaan Lokhorst (lonaowna) - Thursday, 28 September 2017, 14:17 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Wednesday, 04 October 2017, 12:02 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

When trying to compile any CMake project using CUDA, it fails with the following message:

The CUDA compiler "/opt/cuda/bin/nvcc" is not able to compile a simple test
program.

It fails with the following output:
(...)

/usr/bin/ld: CMakeFiles/cmTC_8cc96.dir/main.cu.o: relocation R_X86_64_32
against `.bss' can not be used when making a shared object; recompile with
-fPIC

(...)

Steps to reproduce:
* Create a file called "CMakeLists.txt" with the following contents:
project(testproject CUDA)
* Run "cmake ."

Tested with:
cmake 3.9.2-2 + cuda 8.0.61-3 from [extra]/[community]
cmake 3.9.3-1 + cuda 9.0.176-1 from [testing]

This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Wednesday, 04 October 2017, 12:02 GMT
Reason for closing:  Upstream
Comment by Doug Newgard (Scimmia) - Monday, 02 October 2017, 14:02 GMT
Sounds more like a settings issue. As it says, build things with -fPIC
Comment by André (aandre) - Tuesday, 03 October 2017, 16:46 GMT
CMAKE_CUDA_HOST_COMPILER needs to be set to g++-5. See https://gitlab.kitware.com/cmake/cmake/issues/17311
Comment by Sebastiaan Lokhorst (lonaowna) - Tuesday, 03 October 2017, 17:18 GMT
@aandre, thanks! Running CMake with "-DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++-5" fixes the problem.

Is this a bug in CMake, that it finds the wrong host compiler? Or is it possible to set the right default in the cuda or cmake package?
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 04 October 2017, 11:29 GMT
It should pick those up automatically because it will use the compilers close to nvcc which I symlinked from /opt/cuda/bin/gcc to /usr/bin/gcc-6. At any rate, I don't think there's anything I can do in the package here.
Comment by Sebastiaan Lokhorst (lonaowna) - Wednesday, 04 October 2017, 11:49 GMT
Yes, those are set properly. I've opened a CMake bug report, hopefully they can do something about it.
https://gitlab.kitware.com/cmake/cmake/issues/17323
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 04 October 2017, 12:02 GMT
Alright, I'm going to close this as 'upstream' for the time being. Reopen if you find something I can do in the package.

Loading...