[asterisk-dev] dahdi-tools 2.11.1 : fix for relocation error on build
sean darcy
seandarcy2 at gmail.com
Sat Mar 5 17:07:48 CST 2016
On 03/03/2016 04:34 PM, Oron Peled wrote:
> Hi,
>
> On Wednesday 02 March 2016 15:14:11 sean darcy wrote:
>> Building dahdi-tools 2.11.1:
>>
>> gcc -DHAVE_CONFIG_H -I. -g -Wall -O2
>> -I/home/asterisk/rpmbuild/BUILD/dahdi-tools-2.11.1/include -c -o
>> fxstest.o fxstest.c
>> /bin/sh ./libtool --tag=CC --mode=link gcc -g -Wall -O2
>> -I/home/asterisk/rpmbuild/BUILD/dahdi-tools-2.11.1/include
>> -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o fxstest
>> fxstest.o libtonezone.la -lpthread -lm
>> libtool: link: gcc -g -Wall -O2
>> -I/home/asterisk/rpmbuild/BUILD/dahdi-tools-2.11.1/include -Wl,-z
>> -Wl,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o .libs/fxstest
>> fxstest.o ./.libs/libtonezone.so -lpthread -lm -Wl,-rpath -Wl,/usr/lib64
>> /usr/bin/ld: fxstest.o: relocation R_X86_64_32 against `.rodata.str1.1'
>> can not be used when making a shared object; recompile with -fPIC
>>
>> Even though:
>>
>> + CFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
>> -fPIC'
>> + export CFLAGS
>> + CXXFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
>> -fPIC'
>> + export CXXFLAGS
>>
>> because CFLAGS doesn't override the Makefile CFLAGS. Notice no -fPIC above.
>
> OK, this is my bad:
> * The fix to Makefile.am is to replace the first CFLAGS assignment from "=" to "+="
> * Also note that CFLAGS should be passed to ./configure and not make (as "./configure --help" nicely mention).
>
> Here is a patch:
>
> diff --git a/Makefile.am b/Makefile.am
> index d43ce91..9dd64b2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -5,7 +5,7 @@ LEGACY_MAKE = \
> top_srcdir=$(top_srcdir) \
> srcdir=$(srcdir)
>
> -CFLAGS = -g -Wall -O2 $(DAHDI_INCLUDE)
> +CFLAGS += -g -Wall -O2 $(DAHDI_INCLUDE)
> if DAHDI_DEVMODE
> CFLAGS += \
> -Werror \
>
>> The fix: add -fPIC to CFLAGS in Makefile.am, ./bootstrap.sh, build.
>
> Normally, "-fPIC" isn't needed when linking an executable (only on shared objects).
>
> Can you share more info about the build environment?
> * Linux distribution and version (some redhat?)
> * Primary tools versions (e.g: the output of "rpm -q rpm -q gcc make libtool automake autoconf rpm")
> * Extra stuff? maybe building an RPM? (which adds some extra distribution-specific CFLAGS, etc.)
>
> The reason, is that I didn't encounter this failure either with/without "-fPIC"
> and I'd like to try and re-create it.
>
> Thanks for the report,
>
Thanks for the quick response.
Running standard Fedora 23.
rpm -q gcc make libtool automake autoconf rpm | sort
autoconf-2.69-21.fc23.noarch
automake-1.15-4.fc23.noarch
gcc-5.3.1-2.fc23.x86_64
libtool-2.4.6-8.fc23.x86_64
make-4.0-5.1.fc23.x86_64
rpm-4.13.0-0.rc1.12.fc23.x86_64
Here's the bootstrap and configure in the rpm build:
+ cd dahdi-tools-2.11.1
+ ./bootstrap.sh
Generating the configure script ...
+ CFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
-fPIC'
+ export CFLAGS
+ CXXFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
-fPIC'
+ export CXXFLAGS
+ FFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
-fPIC -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -march=native -mtune=native -ftree-vectorize -ffast-math
-fPIC -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
+ export LDFLAGS
+ '[' 1 = 1 ']'
+++ dirname ./configure
++ find . -name config.guess -o -name config.sub
+ for i in '$(find $(dirname ./configure) -name config.guess -o -name
config.sub)'
++ basename ./auxdir/config.guess
+ '[' -f /usr/lib/rpm/redhat/config.guess ']'
+ /usr/bin/rm -f ./auxdir/config.guess
++ basename ./auxdir/config.guess
+ /usr/bin/cp -fv /usr/lib/rpm/redhat/config.guess ./auxdir/config.guess
'/usr/lib/rpm/redhat/config.guess' -> './auxdir/config.guess'
+ for i in '$(find $(dirname ./configure) -name config.guess -o -name
config.sub)'
++ basename ./auxdir/config.sub
+ '[' -f /usr/lib/rpm/redhat/config.sub ']'
+ /usr/bin/rm -f ./auxdir/config.sub
++ basename ./auxdir/config.sub
+ /usr/bin/cp -fv /usr/lib/rpm/redhat/config.sub ./auxdir/config.sub
'/usr/lib/rpm/redhat/config.sub' -> './auxdir/config.sub'
+ '[' 1 = 1 ']'
+ '[' x '!=' x-specs=/usr/lib/rpm/redhat/redhat-hardened-ld ']'
++ find . -name ltmain.sh
+ for i in '$(find . -name ltmain.sh)'
+ /usr/bin/sed -i.backup -e
's~compiler_flags=$~compiler_flags="-specs=/usr/lib/rpm/redhat/redhat-hardened-ld"~'
./auxdir/ltmain.sh
++ pwd
+ ./configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --program-prefix=
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
--libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-dahdi=/home/asterisk/rpmbuild/BUILD/dahdi-tools-2.11.1
...................
FWIW, if -fPIC is not in CFLAGS the .configure compiler check fails:
........
configure:3875: checking whether we are cross compiling
configure:3883: gcc -o conftest -O2 -march=native -mtune=native
-ftree-vectorize -ffast-math -Wl,-z,relro
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c >&5
/usr/bin/ld: /tmp/cciqZ1hg.o: relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile
with -fPIC
/tmp/cciqZ1hg.o: error adding symbols: Bad value
Thanks,
sean
More information about the asterisk-dev
mailing list