Simple file fails to compile with -O2 or -O3

Bug #1589751 reported by Michael Poole
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nvidia-cuda-toolkit (Debian)
Fix Released
Unknown
nvidia-cuda-toolkit (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I have a new laptop with Ubuntu 16.06 (xenial) installed onto a new partition, plus nvidia-cuda-toolkit 7.5.18-0ubuntu1 from multiverse.

$ echo '#include <stdio.h>' > dummy.cpp
$ g++ -c -O2 dummy.cpp
$ cp dummy.cpp dummy.cu
$ nvcc -c -O2 dummy.cu
/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
   return (char *) memcpy (__dest, __src, __n) + __n;
                                          ^

nvcc can compile it at -O0 and -O1, and it is a conforming translation unit (modulo the addition of at least one definition after the #include statement; including such a definition does not affect the error).

Tags: patch
Revision history for this message
Graham Inggs (ginggs) wrote :

Please try the following workaround:

$ nvcc -c -O2 -D_FORCE_INLINES dummy.cu

Changed in nvidia-cuda-toolkit (Ubuntu):
status: New → Confirmed
Changed in nvidia-cuda-toolkit (Debian):
status: Unknown → New
Revision history for this message
Graham Inggs (ginggs) wrote :

Please also try editing /usr/include/common_functions.h and commenting out the line containing (as per the attached patch:

__cdecl memcpy(void*, const void*, size_t) __THROW;

tags: added: patch
Revision history for this message
Michael Poole (mdpoole) wrote :

The workarounds (either one separately, or both) resolve the compile issue for me. Thank you for the pointers!

Revision history for this message
Graham Inggs (ginggs) wrote :

@mdpoole: thanks for confirming!

This seems to be fixed in the CUDA 8.0 release candidate.
I can't see that Nvidia changed anything related to this in common_functions.h, so I suggest using -D_FORCE_INLINES for now.

Changed in nvidia-cuda-toolkit (Debian):
status: New → Fix Released
Graham Inggs (ginggs)
Changed in nvidia-cuda-toolkit (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.