[asterisk-dev] dahdi-tools 2.11.1 : fix for relocation error on build

Oron Peled oron.peled at xorcom.com
Thu Mar 3 15:34:16 CST 2016


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,

-- 
Oron Peled                                 Voice: +972-4-8228492
oron at actcom.co.il                  http://users.actcom.co.il/~oron
Q:  What does FAQ stand for?
A:  We have Frequently Asked this Question, and we have no idea.




More information about the asterisk-dev mailing list