nbodyx/Nbody6

Build fails: relocation R_X86_64_32 against `.bss' can not be used when making a shared object

Opened this issue · 1 comments

shrx commented
$ make avx
...
gfortran -lstdc++ -fopenmp -fPIC -B /usr/share/libhugetlbfs -Wl,--hugetlbfs-link=B -Wall -O3 -ffast-math -march=core2 -mavx adjust.o [...] cxvpred.o -o nbody6
ld.hugetlbfs: --hugetlbfs-link is deprecated. Migrate to --hugetlbfs-align.
/usr/bin/ld: gpuirr.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
/home/shrx/fortran/testi/Nbody6/GPU2/Makefile.build:152: recipe for target 'sse' failed
make[1]: *** [sse] Error 1
make[1]: Leaving directory '/home/shrx/fortran/testi/Nbody6/GPU2/Build'
Makefile:68: recipe for target 'avx' failed
make: *** [avx] Error 2

I tried modifying the relevant code in Makefile:

ifeq ($(avx), enable)
gpuirr.o: gpuirr.s
	$(CXX) -fPIC -c $^ -o $@

But it results in the same error.
Here is the full build log: https://gist.github.com/shrx/19f45946ccd938edf68280cc77b06cca

gfortran --version 
GNU Fortran (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This issue is related to the SIMD library AVX and SSE.
First please check your computer enviroment. Whether your CPU support AVX and SSE.
The following steps help you to identify:

  1. in terminal shell:
    egrep avx /proc/cpuinfo
  2. if it return any lines. Thus means your CPU support AVX. You can use the same way to check SSE

IF the avx/sse are detected but the compiling still failed, then please check your gcc version by
gcc --version
if the gcc version is too low, the avx and sse may not be supported. The suggestion is to use version >= 4.4

If these cannot help, please let me know