[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

dpkg-buildflags and cross-building



I've been using dpkg-buildflags to nobble the link path and
rpath-link LDFLAGS setting because the current cross-toolchain for
arm64 does not get these right by default (and it doesn't have libssp).

This works pleasingly well (I've only found a couple of packages that
don't honour dpkg-buildflags already), until you get to something that
wants to do some native building as well as some cross-building during
a package build.

I set  /etc/dpkg/buildflasg.conf to:
STRIP CFLAGS -fstack-protector
STRIP CXXFLAGS -fstack-protector
APPEND LDFLAGS -L/usr/lib/aarch64-linux-gnu -L/lib/aarch64-linux-gnu -L/usr/lib
-Wl,-rpath-link=/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:/usr/lib

Unfortunately because dpkg-buildflag settings are not arch-specific
this goes wrong when a native (amd64) gcc comes along and is then told to find
it's libraries in /usr/lib/aarch64-linux-gnu:

/bin/bash ../../libtool --tag=CC --mode=link gcc -I../../src/include -Wall -Wshadow -Wpointer-arith -Wwrite-strings
-Wstrict-prototypes -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/aarch64-linux-gnu -L/lib/aarch64-linux-gnu
-L/usr/lib -Wl,-rpath-link=/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:/usr/lib -o qgen common.o file.o first.o
ql_y.o ql_l.o qgen.o second.o third.o -lfl libtool: link: gcc -I../../src/include -Wall -Wshadow -Wpointer-arith
-Wwrite-strings -Wstrict-prototypes -Wl,-Bsymbolic-functions -Wl,-z -Wl,relro
-Wl,-rpath-link=/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:/usr/lib -o qgen common.o file.o first.o ql_y.o
ql_l.o qgen.o second.o third.o -L/usr/lib/aarch64-linux-gnu -L/lib/aarch64-linux-gnu -L/usr/lib -lfl
/usr/bin/ld: skipping incompatible /usr/lib/aarch64-linux-gnu/libfl_pic.a when searching for /usr/lib/aarch64-linux-gnu/libfl_pic.a
/usr/bin/ld: cannot find /usr/lib/aarch64-linux-gnu/libfl_pic.a inside
/usr/bin/ld: skipping incompatible /usr/lib/aarch64-linux-gnu/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/aarch64-linux-gnu/libc.a when searching for -lc

So, is there a way to make dpkg-buildflags arch-specific, so they are 
picked up for one CC and not another?

Yes I realise that fixing the compiler would be a better fix in this case,
but the concept of varying buildflags between architectures is a useful
one, as especially during bootstrap when cross-compiling is required it is
very likely to be the case the cross-compiler needs so different flags to
the more capable native toolchain.

Any ideas? 

Wookey
-- 
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/


Reply to: