sdk compilation failes 'cannot be declared weak' Archlinux cuda sdk 2.3

Hello together

I try to install CUDA on archlinux.

uname -r

2.6.30-ARCH x86_64
gcc --version

gcc (GCC) 4.4.1

After the installation of the cuda-toolkit 2.3, I tried compiling the sdk examples. After changing the cuda installation path in C/common/common.mk I run in the following problem:

make[1]: Entering directory `/opt/cuda-sdk/C/src/oceanFFT'

/opt/cuda/bin/../include/math_functions.h:412: error: inline function ‘int __signbit(double)’ cannot be declared weak

/opt/cuda/bin/../include/math_functions.h:417: error: inline function ‘int __signbitf(float)’ cannot be declared weak

/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbit(double)’ cannot be declared weak

/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitf(float)’ cannot be declared weak

/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitl(long double)’ cannot be declared weak

/usr/include/bits/mathinline.h:36: error: inline function ‘int __signbitf(float)’ cannot be declared weak

/usr/include/bits/mathinline.h:42: error: inline function ‘int __signbit(double)’ cannot be declared weak

/usr/include/bits/mathinline.h:48: error: inline function ‘int __signbitl(long double)’ cannot be declared weak

/opt/cuda/bin/../include/math_functions.h:442: error: inline function ‘int __signbitl(long double)’ cannot be declared weak

make[1]: *** [obj/emurelease/oceanFFT_kernel.cu.o] Error 255

make[1]: Leaving directory `/opt/cuda-sdk/C/src/oceanFFT'

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

By the way, I try to compile in emulation mode.

Does anybody have an idea how to solve this issues.

Thanks a lot.

analyzer

i get a similar error, but in a different place:

make[1]: Entering directory /home/timon/NVIDIA_GPU_Computing_SDK/C/src/simpleCUFFT' /usr/include/string.h:43: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak /usr/include/string.h:64: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak /usr/include/bits/string3.h:49: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak /usr/include/bits/string3.h:78: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak /usr/local/cuda/bin/../include/common_functions.h:59: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak /usr/local/cuda/bin/../include/common_functions.h:62: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak /usr/local/cuda/bin/../include/math_functions.h:412: error: inline function ‘int __signbit(double)’ cannot be declared weak /usr/local/cuda/bin/../include/math_functions.h:417: error: inline function ‘int __signbitf(float)’ cannot be declared weak /usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbit(double)’ cannot be declared weak /usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitf(float)’ cannot be declared weak /usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitl(long double)’ cannot be declared weak /usr/include/bits/mathinline.h:36: error: inline function ‘int __signbitf(float)’ cannot be declared weak /usr/include/bits/mathinline.h:42: error: inline function ‘int __signbit(double)’ cannot be declared weak /usr/include/bits/mathinline.h:48: error: inline function ‘int __signbitl(long double)’ cannot be declared weak /usr/local/cuda/bin/../include/math_functions.h:442: error: inline function ‘int __signbitl(long double)’ cannot be declared weak make[1]: *** [obj/emurelease/simpleCUFFT.cu.o] Error 255 make[1]: Leaving directory /home/timon/NVIDIA_GPU_Computing_SDK/C/src/simpleCUFFT’
make: *** [src/simpleCUFFT/Makefile.ph_build] Error 2

I’m trying to compile in emulation mode too:

$make emu=1

CUDA doesn’t presently support gcc 4.4. You will need to downgrade/install a gcc 4.3 version to compile with CUDA.

Thanks. but, how can i do that?

that’s what i’ve tried:

aptitude remove gcc-4.4

The following packages will be REMOVED:

gcc{a} gcc-4.4

aptitude install gcc-4.3

then i got this error:

gcc: No such file or directory

So i tried:

aptitude install gcc

The following NEW packages will be installed:

gcc gcc-4.4{a}

the same happens with build-essential and g+±4.4

Maybe ti’s easy, but i had never downgrade a package before.

thanks

Which distro are you using?

Ubuntu 9.10

That isn’t an officially supported version, but theoretically it might work if you install gcc-4.3 and g+±4.3. You will then have to get nvcc to pick up gcc-4.3, which is probably best done by making a local directory somewhere with symlinks to the gcc and g++ executables, modifying your cuda makefile to find them, and pass that directory to nvcc via the --compiler-bindir so that nvcc picks up the right compiler.

I’m using Ubuntu 9.10 (both 32 and 64 bit), too and managed to solve the problem. I got the “declared weak” errors and read that they are caused by missing support for gcc4.x.

gcc3 seems not to be in the Ubuntu-Karmic-Repos, so I decided to compile it, but that failed (same error as here). I managed to install it by adding a dapper repo to /etc/apt/sources.list:

deb http://ubuntuarchive.eweka.nl/ubuntu/ dapper main universe restricted multiverse

Afterwards the old gcc and g++ can be installed via apt-get

sudo apt-get install g++-3.4 gcc-3.4

sudo mkdir /opt/gcc34

sudo ln -s /usr/bin/gcc-3.4 /opt/gcc34/gcc 

sudo ln -s /usr/bin/g++-3.4 /opt/gcc34/g++

As a last step for compiling the example script, common/common.mk needs to be edited.

REPLACE

NVCCFLAGS :=

WITH

NVCCFLAGS := --compiler-bindir /opt/gcc34/

Now I am able to compile the example script with make emu=1

Except for the compiler version, that sounds exactly like what I suggested. Nice to know what theoretically should work actually does.

It does seem like an awful lot of trouble to go to rather than just running with Ubuntu 9.04 (ie. the supported version) in the first place…

Thank you. i’ll try to do that, although i’m not sure if i undesrtand it very well.

ln -s /usr/bin/gcc-4.3 gcc

ln -s /usr/bin/g+±4.3 g++

should i do this in the same directory of my project?

putting /usr/bin/gcc-4.3 instead of gcc and /usr/bin/g+±4.3 instead of g++ in my makefile?

maybe /usr/bin/gcc-4.3 instead of gcc and /usr/bin/g+±4.3 instead of g++ in my makefile?

what should i write in my makefile instead of:

/usr/local/cuda/bin/nvcc -c --device-emulation paralelLayer.cu ???

Anyway, if i waste too much time with this, I’ll probably install Ubuntu 9.04. It’s a new laptop and I’m having problems with the wifi too and i think this may be another 9.10 issue. In fact i used to have Ubuntu 8.04 in the Desktop pc and i don’t like changes too much.

It’s supported, right?

Does Ubuntu 9.04 use gcc-4.3?

Thanks a lot for your help.

You could do that, but it might be better to put it somewhere else so that you only have to do it once. Perhaps create a $(HOME)/bin and put them there.

That should work, although you don’t need the paths, so in your makefile you could have something like this

CC=	 gcc-4.3

CXX=   g++-4.3

and then use (CC) and (CXX) for the C and C++ compilers. That should be sufficient.

nvcc --compiler-bindir $(HOME)/bin .....

if you followed my instructions above.

Right now I think only 8.10 and 9.04 are supported. Both use gcc v4.3 and work fine with CUDA. CUDA 2.2 was the last version supported by 8.04 and 8.04 LTS, if my memory doesn’t fail me.

Thank you very much!!
It compiles the entire project again!! Just as it used to do in the desktop with the geforce and the 8.10.

Maybe I will leave the 9.10. The wifi seems to work in other places so maybe it’s not my problem.

You’ve answered very quickly every time, avidday, thanks a lot again.

Thanks to you too tailon, I’ll try what you did to run the SDK samples.

I have the current SDK running on Ubuntu 9.10-AMD64 with gcc-4.4, based on the fix here:

http://forums.fedoraforum.org/showthread.php?t=230090

It seems to work if you comment out the __signbit* (…bit, …bitd, …bitf, …bitl) declarations in /usr/local/cuda/include/math_functions.h
You also have to do that with the *memset and *memcpy declarations in /usr/local/cuda/include/common_functions.h

That’s a total of 6 replacements - 4 signbit and 2 memxxx

It seems these are redundant declarations on gcc-4.4 or something, since it works fine after doing that.

force create a sym link to gcc 4.3 after installing gcc4.3

sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc --force

it works fine then…

You should not do this. It can have serious consequences for the rest of your operating system install. The entire distro is built with gcc-4.4 and there is a risk that hacking the system wide compiler in this fashion will break system wide things outside of CUDA. You have been warned.

Yes I understand… your concern is justified… I meant just for sake of running the program until NVIDIA added support… and then once you are done relink to the original 4.4 compiler before you close off…

I had not any problems with the makefile “trick”. But i don’t use it for the SDK.

I’ve solved the ‘inline function cannot be declared weak’ problem by appending ‘-fno-strict-aliasing’ to NVCCFLAGS in the makefiles of the programs I’ve tried to compile.

EDIT: grrrr, the correct NVCCFLAGS are: --compiler-options -fno-inline

have you done anything else in addition to “NVCCFLAGS += --compiler-options -fno-inline”?

I commented the math_functions.h and added the flag to common/common.mk, but my installation still complains about weak for memcpy and memset …not sure your flag helped…

any ideas? (except replacing gcc 4.4 w 4.3)

make[1]: Entering directory `/home/ana/CUDASDK/C/src/simpleCUFFT'

/usr/include/string.h:43: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak

/usr/include/string.h:64: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak

/usr/include/bits/string3.h:49: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak

/usr/include/bits/string3.h:78: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak

/usr/local/cuda/bin/../include/common_functions.h:59: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak

/usr/local/cuda/bin/../include/common_functions.h:62: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak

well, at the end of the day I also switched to gcc-4.3 and batch compiled all examples in emu mode using GPUSDK/C/Makefile. works nicely!