giaf / blasfeo

Basic linear algebra subroutines for embedded optimization
Other
323 stars 88 forks source link

Shared library target fails on old gcc #69

Closed tmmsartor closed 6 years ago

tmmsartor commented 6 years ago

/usr/bin/x86_64-linux-gnu-ld: CMakeFiles/blasfeo.dir/kernel/avx2/kernel_dgemm_12x4_lib4.S.o: relocation R_X86_64_PC32 against symbol `inner_kernel_dgemm_add_nt_12x4_lib4' can not be used when making a shared object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: final link failed: Bad value collect2: error: ld returned 1 exit status

BLASFEO fails to compile as shared library both with make and Cmake for some gcc version/configuration, (tested and failing on ubuntu with gcc 4.9, 4.8 and 6)

Broken since 62d64013, with this commit some x86 internal assembly "functions" are exported as global symbols, before this change the shared library compilation is working.

Error message is bogus when linking hand written assembly code. Most relevant reference: stackoverflow 1, 2, 3 and PR #68 .

Using MACROS_LEVEL=2 solve the issue. In this case the global symbol is not even defined.

giaf commented 6 years ago

This https://github.com/giaf/blasfeo/commit/be91a08e23aec688455d9c592d6841a3bc1ce172 should fix the issue, at least on make.

As usual, I don't know what is the portable way of doing that in cmake.

giaf commented 6 years ago

Apparently it is a bit brute force as a fix, as ALL symbols are searched in the shared library, but this is anyway what we do in BLASFEO, so it should make the job.

If you have a more delicate fix, let me know ;)

giaf commented 6 years ago

This fixes the issue https://github.com/giaf/blasfeo/commit/c4eb38129941c872e643d63b29956022bdac0d2b