libcap2 fails to cross-build

Bug #872435 reported by Wookey
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libcap2 (Debian)
Fix Released
Unknown
libcap2 (Ubuntu)
Fix Released
Undecided
Loïc Minier

Bug Description

libcap2 fails to cross-build:

Base natty source has no cross support. Adding standard 'set cross-build variables' support to this debhelper package makes it try to do the right thing, but it tries to link to x86 libraries:
arm-linux-gnueabi-gcc -Wl,-x -shared -O2 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -g -L/home/wookey/testing/build/build/xdeb/libcap2/libcap/../libcap -lattr -Wl,-soname,libcap.so.2 -o libcap.so.2.20 cap_alloc.o cap_proc.o cap_extint.o cap_flag.o cap_text.o cap_file.o
/usr/lib/x86_64-linux-gnu/libattr.so: file not recognized: File format not recognized

The actual problem seems to be that xdeb fails to install libattr1-armel-cross and libattr1-dev-armel-cross and the compiler has the host library path on the end of the search list so if the build-arch version of the library is installed then it gets found and used.

There is also a bug in this versoin of the package so that attempting to do make clean without pam-modules installed fails. That is the subject of a separate bug.

------------
The build command is:
xdeb --only-explicit -a armel --prefer-apt --apt-source --debug --force-rebuild bash

The actual build command xdeb issues is:
debuild --no-lintian -eUSER -eCONFIG_SITE=/etc/dpkg-cross/cross-config.armel -eDEB_BUILD_OPTIONS=nocheck -eGTEST_INCLUDEDIR=/usr/arm-linux-gnueabi/include -eGTEST_LIBDIR=/usr/arm-linux-gnueabi/lib -ePKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabi/lib/pkgconfig:/usr/arm-linux-gnueabi/share/pkgconfig:/usr/share/pkgconfig -eDH_VERBOSE=1 -aarmel -b -uc -us -tc

To easily reproduce the build environment in which this bug was discovered follow the HOWTO here:
https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/CrossBuildNano

Tags: cross

Related branches

Revision history for this message
Wookey (wookey) wrote :
Revision history for this message
Loïc Minier (lool) wrote : Re: [Bug 872435] [NEW] libcap2 fails to cross-build

On Tue, Oct 11, 2011, Wookey wrote:
> Base natty source has no cross support. Adding standard 'set
> cross-build variables' support to this debhelper package makes it try
> to do the right thing, but it tries to link to x86 libraries:
> arm-linux-gnueabi-gcc -Wl,-x -shared -O2 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -g -L/home/wookey/testing/build/build/xdeb/libcap2/libcap/../libcap -lattr -Wl,-soname,libcap.so.2 -o libcap.so.2.20 cap_alloc.o cap_proc.o cap_extint.o cap_flag.o cap_text.o cap_file.o
> /usr/lib/x86_64-linux-gnu/libattr.so: file not recognized: File format not recognized

 (Just commenting on that part of the report)

 This is a problem that was pretty common, especially before libraries
 were converted to multiarch because many build systems such as libtool
 would add -L/usr/lib early in the search path. It's nice if we can fix
 these build systems, but there's a simpler workaround in having
 binutils configured to support both the host and the build
 architectures. Actually, I thought this was explicitly the case in our
 cross-toolchains for a long time, but I guess that's a recent
 regression? Seems like an Ubuntu binutils bug to me.

 Now in your case the /usr/lib/x86_64-linux-gnu/ library search path
 seems to come from spec files, which is weird: I don't think
 arm-linux-gnueabi-gcc should have a x86_86 library directory in its
 library search path, that seems like an Ubuntu gcc-4.x bug.

--
Loïc Minier

Revision history for this message
Loïc Minier (lool) wrote :

Did you really mean bash in the xdeb command you provide to reproduce the bug?

I tried in a clean oneiric chroot, debootstrap --variant=buildd, with xdeb and cross-toolchain installed and with an additional arch=armel entry added to sources.list, bash failed to build but libcap2 didn't appear in the build sequence:
xdeb --only-explicit -a armel --prefer-apt --apt-source --debug --force-rebuild bash
[...]
Configuration is:
Default configs parsed: ['/etc/xdeb/xdeb.cfg', '/home/lool/xdeb/xdeb.cfg']

architecture: 'armel'
blacklist: set([ 'cracklib-runtime',
        'libdb4.7-java',
        'libdb4.7-java-dev',
        'libdb4.7-java-gcj',
        'libgio-fam',
[...]
Building working tree cache ...
 bash -> ncurses (libncurses5-dev)
Recursing: ncurses -> bash
Build sequence: ncurses* bash*

===== Importing ncurses_5.9-1ubuntu5 =====
[...]
===== Building bash_4.2-0ubuntu4 =====
[...]
test -n "arm-linux-gnueabi-ranlib" && arm-linux-gnueabi-ranlib libmalloc.a
make[3]: Leaving directory `/home/lool/xdeb-bash/bash/build-bash/lib/malloc'
rm -f bash
gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/malloc -L./lib/sh -Wl,-Bsymbolic-functions -rdynamic -g -O2 -Wall -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o bashline.o list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o pcomplib.o syntax.o xmalloc.o -lbuiltins -lglob -lsh -lreadline -lhistory -lcurses -ltilde -lmalloc -ldl
./builtins/libbuiltins.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status

Revision history for this message
Loïc Minier (lool) wrote :

I tried explicitly xdeb-ing libcap2, and got yet another failure:
xdeb-run --only-explicit -a armel --prefer-apt --apt-source --debug --force-rebuild libcap2
[...]
Building working tree cache ...
 libcap2 -> attr (libattr1-dev)
 libcap2 -> pam (libpam0g-dev)
Recursing: attr -> libcap2
Recursing: pam -> libcap2
Build sequence: attr* pam* libcap2*
[...]
===== Importing attr_1:2.4.46-3 =====
[...]
===== Importing pam_1.1.3-2ubuntu1 =====
[...]
===== Building libcap2_1:2.21-2 =====
[...]
   dh_auto_build
        make -j1
make[1]: Entering directory `/home/lool/xdeb-bash/libcap2'
make -C libcap all
make[2]: Entering directory `/home/lool/xdeb-bash/libcap2/libcap'
=> making cap_names.list.h from /home/lool/xdeb-bash/libcap2/libcap/../libcap/include/linux/capability.h
perl -e 'while ($l=<>) { if ($l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$/) { $tok=$1; $val=$2; $tok =~ tr/A-Z/a-z/; print "{\"$tok\",$val},\n"; } }' /home/lool/xdeb-bash/libcap2/libcap/../libcap/include/linux/capability.h | fgrep -v 0x > cap_names.list.h
gcc -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include _makenames.c -o _makenames
[...]
   dh_strip
        arm-linux-gnueabi-strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/libcap2-bin/lib/security/pam_cap.so
arm-linux-gnueabi-strip:debian/libcap2-bin/lib/security/pam_cap.so: File format not recognized
dh_strip: arm-linux-gnueabi-strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/libcap2-bin/lib/security/pam_cap.so returned exit code 1
make: *** [binary] Error 29
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2

which is because it's not using a cross compiler; after fixing debian/rules to set CC and BUILD_CC as in https://launchpadlibrarian.net/37542685/libcap2_1%3A2.16-5ubuntu1_1%3A2.16-5ubuntu2%7Ecross1.diff.gz but adapted for the new dh-based rules, it cross-built fine:
[...]
=> making cap_names.list.h from /home/lool/xdeb-bash/libcap2/libcap/../libcap/include/linux/capability.h
perl -e 'while ($l=<>) { if ($l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$/) { $tok=$1; $val=$2; $tok =~ tr/A-Z/a-z/; print "{\"$tok\",$val},\n"; } }' /home/lool/xdeb-bash/libcap2/libcap/../libcap/include/linux/capability.h | fgrep -v 0x > cap_names.list.h
gcc -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include _makenames.c -o _makenames
./_makenames > cap_names.h
arm-linux-gnueabi-gcc -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -g -fPIC -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include -I/home/lool/xdeb-bash/libcap2/libcap/../libcap/include -c cap_alloc.c -o cap_alloc.o
[...]
dpkg-deb: building package `libcap2-armel-cross' in `./libcap2-armel-cross_2.21-2_all.deb'.
['libcap2-armel-cross_2.21-2_all.deb', 'libcap-dev-armel-cross_2.21-2_all.deb']

affects: xdeb (Ubuntu) → libcap2 (Ubuntu)
Loïc Minier (lool)
Changed in libcap2 (Ubuntu):
status: New → Fix Committed
assignee: nobody → Loïc Minier (lool)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libcap2 - 1:2.22-1ubuntu1

---------------
libcap2 (1:2.22-1ubuntu1) precise; urgency=low

  * Fix cross-building by passing CC and BUILD_CC to dh_auto_make; based on a
    patch by Colin Watson for the previous CDBS packaging, but adapted for the
    new dh-based packaging; LP: #872435.
 -- Loic Minier <email address hidden> Wed, 19 Oct 2011 16:30:24 +0200

Changed in libcap2 (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Wookey (wookey) wrote :
Download full text (10.6 KiB)

sorry - that 'bash' was a copy-paste error.

I just tried re-running the build (using the 'patched-to-use correct gcc' libcap2 fromhttps://launchpad.net/~linaro-foundations/+archive/cross-alip - I see it used to be a cdbs package back at v2.16 and now is a debhelper package - that confused me for a mo)
 in a clean natty chroot created accoring to the 'cross-building nano' howto and got this:

Building working tree cache ...
 libcap2 -> attr (libattr1-dev)
 libcap2 -> pam (libpam0g-dev)
Recursing: attr -> libcap2
Recursing: pam -> libcap2
Build sequence: attr* pam* libcap2*
sudo apt-get -y --allow-unauthenticated -o Dir::State::Lists=/home/wookey/testing/build/natty/build/cleantest/lists.apt -o Dir::Cache::pkgcache=/home/wookey/testing/build/natty/build/cleantest/pkgcache.bin -o Dir::Cache::srcpkgcache=/home/wookey/testing/build/natty/build/cleantest/srcpkgcache.bin -o Dir::Etc::sourcelist=/home/wookey/testing/build/natty/build/cleantest/sources.list --no-install-recommends install debhelper indent libattr1-dev libpam0g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  html2text libattr1 po-debconf
Suggested packages:
  dh-make libmail-box-perl
Recommended packages:
  libmail-sendmail-perl
The following NEW packages will be installed:
  debhelper html2text indent libattr1-dev libpam0g-dev po-debconf
The following packages will be upgraded:
  libattr1
1 upgraded, 6 newly installed, 0 to remove and 22 not upgraded.
Need to get 1061 kB of archives.
After this operation, 3383 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libattr1 html2text po-debconf debhelper indent libpam0g-dev libattr1-dev
Authentication warning overridden.
Get:1 http://ppa.launchpad.net/linaro-foundations/cross-alip/ubuntu/ natty/main libattr1 amd64 1:2.4.44-2ubuntu3cross1 [13.3 kB]
Get:2 http://ppa.launchpad.net/linaro-foundations/cross-alip/ubuntu/ natty/main libattr1-dev amd64 1:2.4.44-2ubuntu3cross1 [37.1 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ natty/main html2text amd64 1.3.2a-15 [104 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ natty/main po-debconf all 1.0.16+nmu1 [212 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ natty/main debhelper all 8.1.2ubuntu4 [482 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ natty/main indent amd64 2.2.11-1 [87.7 kB]
Get:7 http://archive.ubuntu.com/ubuntu/ natty/main libpam0g-dev amd64 1.1.2-2ubuntu8 [125 kB]
Fetched 1061 kB in 10s (98.1 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 75, <> line 7.)
debconf: falling back to frontend: Readline
(Reading database ... 16150 files and directories currently installed.)
Preparing to replace libattr1 1:2.4.44-2ubuntu3 (using .../libattr1_1%3a2.4.44-2ubuntu3cross1_amd64.deb) ...
Unpacking replacement libatt...

Revision history for this message
Loïc Minier (lool) wrote :

This could also be a bug in your cross toolchain

I'm not sure of the value of tracking issues cross-compiling natty packages at this point though

Revision history for this message
Wookey (wookey) wrote : Re: [Bug 872435] Re: libcap2 fails to cross-build

+++ Loïc Minier [2011-10-19 21:35 -0000]:
> This could also be a bug in your cross toolchain

possibly, but I can't think of a reason how that would work easily.

It's xdeb using apt and dpkg-cross. (and dpkg-cross doesn't get
called, which is is the problem). One of those three is responsible.
That's not what I thin kof as the 'cross-toolchain'.

> I'm not sure of the value of tracking issues cross-compiling natty
> packages at this point though

Not much. I'm just going through seeing which issues are still present
in oneiric. Once the autobuilder for that is running, I'll add one for
precise.

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

Revision history for this message
Loïc Minier (lool) wrote :

On Wed, Oct 19, 2011, Wookey wrote:
> > This could also be a bug in your cross toolchain
> possibly, but I can't think of a reason how that would work easily.
>
> It's xdeb using apt and dpkg-cross. (and dpkg-cross doesn't get
> called, which is is the problem). One of those three is responsible.
> That's not what I thin kof as the 'cross-toolchain'.

 Check comment #2 again where I point out that it might be because
 your cross-binutils doesn't know how to deal with host binaries.

--
Loïc Minier

Changed in libcap2 (Debian):
status: Unknown → New
Changed in libcap2 (Debian):
status: New → Fix Committed
Changed in libcap2 (Debian):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.