compiling cuda-sdk 3.0 with gcc 4.4

In working to update the cuda support on Arch Linux I’ve run across the following problem. Our approach so far has been to patch the common.mk file using the workaround proposed for cuda sdk 2.3. So first we apply the following patch to common.mk.

[codebox]

— pkg/sdk/C/common/common.mk 2010-03-03 22:14:46.000000000 +0900

+++ pkg/sdk/C/common/common.mk.fix 2010-03-29 20:39:15.000000000 +0900

@@ -55,7 +55,7 @@

SHAREDDIR := $(ROOTDIR)/…/…/shared/

Compilers

-NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc

+NVCC := nvcc

CXX := g++

CC := gcc

LINK := g++ -fPIC

@@ -89,7 +89,7 @@

architecture flag for nvcc and gcc compilers build

CUBIN_ARCH_FLAG :=

CXX_ARCH_FLAGS :=

-NVCCFLAGS :=

+NVCCFLAGS := --compiler-options -fno-inline

LIB_ARCH := $(OSARCH)

Determining the necessary Cross-Compilation Flags

[/codebox]

Next we perform make in the /sdk/C directory. When building gcc / nvcc errors out while compiling postProcessGL. An error log follows:

[codebox]make[1]: Entering directory `/home/XXXXX/build/cuda-sdk/src/pkg/sdk/C/src/postProcessGL’

main.cpp:158: note: #pragma message: Note: Using Texture fmt GL_RGBA16F_ARB

…/…/…/shared//inc/shrUtils.h:55: warning: ‘nGpuArchCoresPerSM’ defined but not used

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/…/…/…/…/include/c++/4.4.3/x86_64-unknown-linux-gnu/bits/c++locale.h: In function ‘int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, …)’:

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/…/…/…/…/include/c++/4.4.3/x86_64-unknown-linux-gnu/bits/c++locale.h:86: error: ‘__builtin_stdarg_start’ was not declared in this scope

make[1]: *** [obj/x86_64/release/postProcessGL.cu.o] Error 1

make[1]: Leaving directory `/home/XXXXX/build/cuda-sdk/src/pkg/sdk/C/src/postProcessGL’

make: *** [src/postProcessGL/Makefile.ph_build] Error 2

[/codebox]

This build error was produce on Arch Linux 2.6.32, 64 bit, gcc 4.4.3, and cuda-toolkit 3.0.

Has anyone else built cuda-sdk 3.0 using gcc 4.4? How did you patch sdk/C/common/common.mk?

I’ve got exactly the same issue. If I include any file in my code that calls (directly or indirectly) c++locale.h, I’ve got the error showing up.

I’m building cuda 3.0 using gcc 4.4.1, under ubuntu 9.10 64bits. I did use the workaround too, in order to build with gcc 4.4

Hi,

I found a workaround for that problem that might interest you. Basically, the problem is coming from the version of gcc (4.4) that is not supported. ThereforeI did install, in addition to the 4.4, the version 4.3 (I can do that in the package manager from Ubuntu). The default version of gcc for the version stays 4.4 however.

Then, I modified the common.mk and made the following additions:

  • I changed everywhere that said gcc to gcc-4.3
  • I added –compiler-bindir=/usr/bin/g+±4.3 to the NVCCFLAGS

This way I use gcc4.3 for nvcc compilation, but I also keep gcc4.4 as the default compiler; and I don’t have the error message anymore.

I hope this helps!

Alright, I’ve managed to get a build using gcc 4.3 thanks to Indydk’s advice. Below is the patch filed currently used.

[codebox]— pkg/sdk/C/common/common.mk 2010-04-19 17:34:25.000000000 +0900

+++ pkg/sdk/C/common/common.mk.fix 2010-04-19 17:26:14.000000000 +0900

@@ -55,7 +55,7 @@

SHAREDDIR := $(ROOTDIR)/…/…/shared/

Compilers

-NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc

+NVCC := nvcc

CXX := g++

CC := gcc

LINK := g++ -fPIC

@@ -89,7 +89,7 @@

architecture flag for nvcc and gcc compilers build

CUBIN_ARCH_FLAG :=

CXX_ARCH_FLAGS :=

-NVCCFLAGS :=

+NVCCFLAGS := --compiler-options -fno-inline --compiler-bindir=/opt/gcc-4.3

LIB_ARCH := $(OSARCH)

Determining the necessary Cross-Compilation Flags

[/codebox]

Note that I am making an /opt/gcc-4.3 directory and making use of it in the NVCC flags. Just renaminh to g+±4.3 and gcc-4.3 was not effective. It looks like I’ll be using this until gcc-4.4 works.

Thank you for this - I was pulling my hair out until I found your post. I am running Ubuntu 10.04LTS 64bit, and had to do the following steps to get this all to work:

sudo apt-get install gcc-4.3 g+±4.3 libXmu-dev libXi-dev

With this version of Ubuntu, the nvidia drivers are pre-installed, but it doesn’t actually link in the ld.so.conf file for them, so things trying to link against -lcuda can’t find it…

sudo ln -s /usr/lib/nvidia-current/ld.so.conf /etc/ld.so.conf.d/nvidia-current.conf

Then I modified my common.mk just as you pointed out, changing just the four lines for CC, CXX, LINK and NVCCFLAGS to include the -4.3 stuff.

It’s a joy to see everything actually compile and install in one pass. Now if we could just get the nice folks at Nvidia to clean up their code so it doesn’t spew thousands of lines of compiler warnings all over the place!

Oh - another quick point: if you edit the C/Makefile so that all of the command references to make use the recommended notation $(MAKE), then you can use make’s jobserver (-j parameter) to speed up your compilation on SMP systems, in my case it goes from taking 2m20.480s down to 0m34.425s. Speed matters, right?

I’ve attempted to replicate exactly what you’ve done, with a fresh install of Ubuntu 10.04 LTS 64-bit, and the Ubuntu-installed NVIDIA driver. I’ve made all of the changes, including this link, but I still get the same message (though several of the SDK examples, like smokeparticles, compile and run just fine):

make -C src/ptxjit/

make[1]: Entering directory `/home/plu/NVIDIA_GPU_Computing_SDK/C/src/ptxjit’

/usr/bin/ld: cannot find -lcuda

collect2: ld returned 1 exit status

make[1]: *** […/…/bin/linux/release/ptxjit] Error 1

Any idea what I’m doing wrong? I presume it shouldn’t link to /usr/lib64/nvidia-current… , right?

Two further stupid questions, since I’m not great with makefiles:

  1. in the Makefile, I should change every instance of “make” to “$(MAKE)” and “@make” to “@$(MAKE)”?

  2. where do I add the “-j” parameter?

Many thanks in advance.