Author Topic: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC  (Read 2732 times)

belegdol

  • Newbie
  • *
  • Posts: 3
    • View Profile
Hi,

I maintain yabause RPM package for RPM fusion. When I tried to update it to 0.9.11 yesterday, I ran into a couple of issues when trying to build it on x86_64.
The first one is caused by a silly location of gdkglext-config.h. On Fedora x86_64 it is in /usr/lib64/gtkglext-1.0/include/, so when yabause looks in /usr/lib, it won't be found. This was easy to work around, though.
The second problem is related to missing -fPIC when assembling linkage_x64.s:
Quote
/usr/bin/ld: CMakeFiles/yabause.dir/sh2_dynarec/linkage_x64.s.o: relocation R_X86_64_32S against `master_ip' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/yabause.dir/sh2_dynarec/linkage_x64.s.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [src/libyabause.so] Error 1
It somehow gets added automatically to other files, but I am not familiar enough with cmake to know where to add it to assembler flags. Help would be appreciated.
Cheers.
« Last Edit: February 11, 2012, 09:47:32 AM by belegdol »

Guillaume

  • Administrator
  • Sr. Member
  • *****
  • Posts: 359
    • View Profile
    • ./confiture && cake
Re: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC
« Reply #1 on: February 11, 2012, 11:10:42 AM »
Funny... it works on debian 64 bits...
Anyways, I'll install a Fedora 64...

Guillaume

  • Administrator
  • Sr. Member
  • *****
  • Posts: 359
    • View Profile
    • ./confiture && cake
Re: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC
« Reply #2 on: February 11, 2012, 05:40:23 PM »
Ok... I'm a bit confused...
I tried adding the -fPIC flag to CMAKE_C_FLAGS (and CMAKE_CXX_FLAGS) on debian 64 and on fedora 64 and it worked in both cases...

Btw, why are you adding this flag? I thought it was only useful for libraries?

belegdol

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC
« Reply #3 on: February 21, 2012, 08:12:56 PM »
Sorry it took me so long to reply, I did not get a notice from the forum for some reason.
Anyway, you are right. It seems the problem boils down to the %cmake macro RPM uses:
Quote
$ rpm --eval %cmake

  CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic}" ; export CFLAGS ;
  CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic}" ; export CXXFLAGS ;
  FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic -I/usr/lib64/gfortran/modules}" ; export FFLAGS ;
  LDFLAGS="${LDFLAGS:--Wl,-z,relro }" ; export LDFLAGS ;
  /usr/bin/cmake \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -DCMAKE_INSTALL_PREFIX:PATH=/usr \
        -DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib64 \
        -DINCLUDE_INSTALL_DIR:PATH=/usr/include \
        -DLIB_INSTALL_DIR:PATH=/usr/lib64 \
        -DSYSCONF_INSTALL_DIR:PATH=/etc \
        -DSHARE_INSTALL_PREFIX:PATH=/usr/share \
%if "lib64" == "lib64"
        -DLIB_SUFFIX=64 \
%endif
        -DBUILD_SHARED_LIBS:BOOL=ON
I'll try to filter the -DBUILD_SHARED_LIBS:BOOL=ON out and see what happens.

ETA: Yeah, using
Quote
%cmake -DBUILD_SHARED_LIBS:BOOL=OFF .
did the trick. Sorry for the trouble.
« Last Edit: February 21, 2012, 08:17:22 PM by belegdol »

Guillaume

  • Administrator
  • Sr. Member
  • *****
  • Posts: 359
    • View Profile
    • ./confiture && cake
Re: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC
« Reply #4 on: February 22, 2012, 10:35:19 AM »
no problem :)

btw, is there some direct link to the Yabause package I could use on http://yabause.org/download/ instead of just linking to http://rpmfusion.org/ ?

belegdol

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Yabause-0.9.11 does not build on Linux/x86_64 due to missing -fPIC
« Reply #5 on: February 22, 2012, 10:51:51 AM »
Well there might be one, but given that there is a separate package for each Fedora branch and architecture, the list would quickly become ridiculously long. Users are just expected to add RPM Fusion to their repos and then install the package with yum, PackageKit or their manager of choice.