JayDDee / cpuminer-opt

Optimized multi algo CPU miner
Other
773 stars 545 forks source link

Fix linking with gcc 9.3.0 #297

Closed thentenaar closed 3 years ago

thentenaar commented 3 years ago

When linking I get undefined reference errors related to libstdc++, libm, and various n-way implementations as automake winds up using CXXLD to link, and CXXFLAGS doesn't get the same options as specified in CFLAGS.

This patch adds the requisite options to smooth out linking. I'm using gcc 9.3.0 with automake 1.16.2.

JayDDee commented 3 years ago

I've never seen this problem and no one has reported it before. I currently use gcc-9.3.0 and automake-1.16.1 on Ubuntu 20.04. I'll need a lot more info.

thentenaar commented 3 years ago

I was getting undefined reference errors like these:

shavite.c:(.text+0x36): undefined reference to `sph_shavite512_aesni_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x49): undefined reference to `sph_shavite512_aesni'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x54): undefined reference to `sph_shavite512_aesni_close'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x5c): undefined reference to `sph_shavite512_aesni_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x6c): undefined reference to `sph_shavite512_aesni'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x77): undefined reference to `sph_shavite512_aesni_close'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: algo/shavite/cpuminer-shavite.o: in function `scanhash_ink':
shavite.c:(.text+0x321): undefined reference to `sph_shavite512_aesni_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x331): undefined reference to `sph_shavite512_aesni'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: shavite.c:(.text+0x33c): undefined reference to `sph_shavite512_aesni_close'

despite these object being present on the link line:

algo/shavite/cpuminer-sph_shavite.o algo/shavite/cpuminer-sph-shavite-aesni.o algo/shavite/cpuminer-shavite-hash-2way.o algo/shavite/cpuminer-shavite-hash-4way.o algo/shavite/cpuminer-shavite.o 

but now I'm left scratching my head as I'm unable to reproduce it further, even on a fresh checkout.

JayDDee commented 3 years ago

I have no idea what could cause that. It couldn't find symbols that were defined in source files that should have just been been compiled. Possibly a corrupt download? Glad it's now working for you.

thentenaar commented 3 years ago

I was scratching my head too. It was a fresh clone of the git repo.