ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.29k stars 110 forks source link

build errors in e2fsprogs and mkuserimg.sh for fp2 #235

Closed sarnold closed 5 years ago

sarnold commented 7 years ago

Steps to reproduce

  1. follow dev guide for fp2, customize your local manifest
  2. hack a 3.10 kernel together
  3. get (mostly) successful system/recovery image builds, except after a sync that broke something

Expected behavior:

Follow the steps and "make -jN" works.

Actual behavior

Sometimes it doesn't, this time e2fsprogs fails with:

/home/sarnold/android/ubports/out/host/linux-x86/obj32/SHARED_LIBRARIES/libext2_blkid_host_intermediates/devname.o: In function evms_probe_all': /home/sarnold/android/ubports/external/e2fsprogs/lib/blkid/devname.c:386: undefined reference tomakedev' /home/sarnold/android/ubports/out/host/linux-x86/obj32/SHARED_LIBRARIES/libext2_blkid_host_intermediates/devname.o: In function lvm_get_devno': /home/sarnold/android/ubports/external/e2fsprogs/lib/blkid/devname.c:294: undefined reference tomakedev' /home/sarnold/android/ubports/out/host/linux-x86/obj32/SHARED_LIBRARIES/libext2_blkid_host_intermediates/devname.o: In function probe_all': /home/sarnold/android/ubports/external/e2fsprogs/lib/blkid/devname.c:438: undefined reference tomakedev' collect2: error: ld returned 1 exit status make: [build/core/host_shared_library_internal.mk:44: /home/sarnold/android/ubports/out/host/linux-x86/obj32/lib/libext2_blkid_host.so] Error 1 make: Waiting for unfinished jobs....

And with parallel make, sometimes it gets far enough to fail with a different error, which is just "command not found". The error comes from mkuserimg.sh and it's looking for the command "make_ext4fs", both of which are in an internal bin directory created during the build, so I assume that path should be known from "env-setup" or whatever android magic is supposed to find it (note that it was working fine until my sync 2 days ago).

Logfiles and additional information

I would have filed these on the repo they come from (as long as I can figure that out) but those repos do not have Issues enabled, and the answer person in #ubports told me to put it here. This is slightly custom build for a 3.10 kernel, and the repos are here: https://github.com/VCTLabs and this is my local manifest:

$ cat .repo/local_manifests/fp2.xml 
<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote name="smoose"
        fetch="http://github.com/smoose-nils"
        revision="refs/heads/ubp-5.1" />

<remote name="vct"
        fetch="http://github.com/VCTLabs"
        revision="ubp-5.1-devel" />

  <project path="kernel/fairphone/FP2" name="android_kernel_fairphone_fp2" remote="vct" revision="ubp-5.1-test" />
  <project path="device/fairphone/FP2" name="android_device_fairphone_fp2" remote="vct" revision="ubp-5.1-test" />
  <project path="hardware/qcom/display-caf/msm8974" name="android_hardware_qcom_display" groups="qcom,qcom_display" remote="vct" revision="ubp-5.1-caf-8974-devel" />
  <project path="hardware/qcom/media-caf/msm8974" name="android_hardware_qcom_media" groups="qcom" remote="vct" revision="ubp-5.1-caf-8974-devel" />
  <project path="device/qcom/common" name="android_device_qcom_common" remote="cm" />
  <project path="vendor/fairphone" name="proprietary_vendor_fairphone" remote="smoose"/>

  <project path="build" name="android_build" groups="pdk,tradefed" remote="vct" >
    <copyfile src="core/root.mk" dest="Makefile" />
  </project>

(external) build environment:

$ emerge --info
Portage 2.3.6 (python 2.7.13-final-0, hardened/linux/amd64, gcc-6.4.0, glibc-2.25-r4, 4.9.16-gentoo x86_64)
=================================================================
System uname: Linux-4.9.16-gentoo-x86_64-AMD_FX-tm-6300_Six-Core_Processor-with-gentoo-2.4.1
KiB Mem:     8170760 total,    384772 free
KiB Swap:   20971512 total,  20958820 free
Timestamp of repository gentoo: Mon, 28 Aug 2017 10:30:01 +0000
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.28.1 p1.0) 2.28.1
ccache version 3.3.4 [enabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-lang/perl:            5.24.1-r2::gentoo
dev-lang/python:          2.7.13::gentoo, 3.4.6::gentoo, 3.5.3::gentoo
dev-util/ccache:          3.3.4::gentoo
dev-util/cmake:           3.8.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1::gentoo
sys-apps/openrc:          0.27.2::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r3::gentoo
sys-devel/automake:       1.11.6-r2::gentoo, 1.13.4-r1::gentoo, 1.15.1::gentoo
sys-devel/binutils:       2.28-r2::gentoo, 2.28.1::gentoo
sys-devel/gcc:            5.4.0-r3::gentoo, 6.3.0::ada, 6.4.0::ada, 7.1.0-r1::ada
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r1::gentoo
sys-kernel/linux-headers: 4.11::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r4::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-umask: 022
    sync-uri: rsync://prime.arnolds.bogus/gentoo-portage
    sync-user: portage:portage
    priority: -1000
    eclass-overrides: nerdboy

arm_support
    location: /usr/local/arm
    sync-type: git
    sync-umask: 022
    sync-uri: https://github.com/gentoo/arm.git
    sync-user: portage:portage
    masters: gentoo

nerdboy
    location: /usr/local/portage
    sync-type: git
    sync-umask: 022
    sync-uri: https://github.com/sarnold/portage-overlay.git
    sync-user: portage:portage
    masters: gentoo

ada
    location: /var/lib/layman/ada
    sync-type: laymansync
    sync-umask: 022
    sync-uri: git://github.com/sarnold/ada-overlay.git
    sync-user: portage:portage
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA @GPL-COMPATIBLE @OSI-APPROVED @EULA dlj-1.1 skype-eula googleearth AdobeFlash-10.1"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -mtune=bdver1 -O2 -pipe -flto=6 -ftree-vectorize -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=athlon64 -mtune=bdver1 -O2 -pipe -flto=6 -ftree-vectorize -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-march=athlon64 -mtune=bdver1 -O2 -pipe -flto=6 -ftree-vectorize -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -fuse-linker-plugin"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
PORTAGE_BZIP2_COMMAND="/bin/bzip2"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi ada alsa amd64 amr apache2 apng aspell avahi berkdb bluetooth bzip2 bzlib cairo caps cdda cdr cli consolekit cracklib crypt cups curl cxx dbus diff djvu dnotify dri drm dts dvd eds enchant exif expat fam firefox3 flac fortran gbm gd gdbm gif git glade glamor gmp gnome-keyring gnome-online-accounts gnutls graphite gstreamer gtk gtk3 hardened iconv icu imagemagick inotify introspection ipv6 jpeg json justify lcms ldap libav libnotify libsecret libvirt lua lz4 mng modules mp3 multilib nautilus ncurses networking networkmanager nfs nls nptl nptlonly nsplugin ogg opengl openmp orc pam pango pax_kernel pcre pda pdf pic pie pkcs11 png policykit postgres pulseaudio python qt5 readline rtc samba sasl sdl seamonkey seccomp session sip slp snmp spell sqlite ssh ssl ssp startup-notification svg system-cairo system-harfbuzz system-icu system-jpeg system-libvpx system-sqlite tcl tcpd text theora threads thunar tiff tk truetype udev udisks unicode upower urandom usb v4l vaapi vala vdpau vorbis wayland webp wheel wifi x264 xa xattr xcb xkb xml xtpax xvmc zeroconf zlib" ABI_X86="64 32" ALSA_CARDS="emu10k1 hda-intel usb-audio" APACHE2_MODULES="actions alias auth_digest auth_basic authn_alias access_compat authn_core authn_dbd authz_core cache_disk cern_meta cgi cgid charset_lite authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_connect proxy_http rewrite setenvif speling status unique_id userdir usertrack vhost_alias unixd socache_shmcb" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="adc65 agfa_cl20 aox ax203 barbie canon casio_qv clicksmart310 digigr8 digita dimagev dimera3500 directory enigma13 fuji gsmart300 hp215 iclick jamcam jd11 jl2005a jl2005c kodak_dc120 kodak_dc210 kodak_dc240 kodak_dc3200 kodak_ez200 konica konica_qm150 largan lg_gsm mars mustek panasonic_coolshot panasonic_l859 panasonic_dc1000 panasonic_dc1580 pccam300 pccam600 pentax polaroid_pdc320 polaroid_pdc640 polaroid_pdc700 ptp2 ricoh ricoh_g3 samsung sierra sipix_blink2 sipix_web2 smal sonix sony_dscf1 sony_dscf55 soundvision spca50x sq905 st2205 stv0674 stv0680 sx330z toshiba_pdrm11 topfield tp6801" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx f16c fma3 fma4 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-32 efi-64 pc" INPUT_DEVICES="keyboard mouse joystick evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-minimizer wiki-publisher" LINGUAS="en_US en" NETBEANS_MODULES="apisupport java javafx profiler websvccommon cnd dlight ergonomics groovy mobility webcommon" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4 python3_5 pypy" QEMU_SOFTMMU_TARGETS="arm aarch64 i386 mips64 mipsel ppc ppc64 x86_64" QEMU_USER_TARGETS="arm aarch64 i386 mips64 mipsel ppc ppc64 x86_64" RUBY_TARGETS="ruby24 ruby23 ruby22" SANE_BACKENDS="net" USERLAND="GNU" VIDEO_CARDS="fbdev radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
sarnold commented 7 years ago

I also made a patch for the first issue, but for whatever reason it's not enough for this build setup, or else I'm not applying it correctly, or who knows? Note that method of patching works in some repos, but again, who knows?

Also note that the generic form of makedev is defined if HAVE_SYS_SYSMACROS_H is correctly enabled (I did try defining it directly the same as HAVE_CONFIG_H below but that didn't help.

I spent an adventurous and completely unproductive day troubleshooting this and then I ran out of customer time and have to punt upstream.

$ cat e2fsprogs-fix-sysmacros-and-configure.patch 
diff --git a/configure b/configure
index 31ec8d3..1848cb8 100755
--- a/configure
+++ b/configure
@@ -11427,10 +11427,10 @@ if test "$USE_INCLUDED_LIBINTL" = "yes" ; then
 fi

 if test $cross_compiling = no; then
-   BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
+   BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H"
    BUILD_LDFLAGS="$LDFLAGS"
 else
-   BUILD_CFLAGS=
+   BUILD_CFLAGS="$INCLUDES"
    BUILD_LDFLAGS=
 fi

diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 80662b1..ac37275 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -26,6 +26,9 @@ extern char *optarg;
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "debugfs.h"
 #include "uuid/uuid.h"
diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c
index b151354..3c4173b 100644
--- a/lib/blkid/devname.c
+++ b/lib/blkid/devname.c
@@ -35,6 +35,9 @@
 #if HAVE_SYS_MKDEV_H
 #include <sys/mkdev.h>
 #endif
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif
 #include <time.h>

 #include "blkidP.h"
diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c
index c9f5c92..91c9207 100644
--- a/lib/blkid/devno.c
+++ b/lib/blkid/devno.c
@@ -30,6 +30,9 @@
 #if HAVE_SYS_MKDEV_H
 #include <sys/mkdev.h>
 #endif
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "blkidP.h"

diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index db80c46..247b9ff 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -37,6 +37,9 @@
 #endif /* HAVE_GETMNTINFO */
 #include <string.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "ext2_fs.h"
 #include "ext2fs.h"
sarnold commented 7 years ago

Turns out it was the above glibc issue and I was too dumb to patch the Android.mk to make it work. I also hacked the env script PATH but there might be a better way for that too... Anyway, I appended the second part to this:

export PATH=$ANDROID_BUILD_PATHS$PATH:$ANDROID_HOST_OUT/bin

and applied this patch to make it work:

From edbb41c1eca55325ef7484f4679f8b0a3123f62c Mon Sep 17 00:00:00 2001
From: Steve Arnold <nerdboy@gentoo.org>
Date: Tue, 10 Oct 2017 21:18:03 -0700
Subject: [PATCH] external/e2fsprogs: fix build with newer/patched glibc

Change-Id: I6baa8a9fd1c9559310bfa2a63731f882135f89af
Signed-off-by: Steve Arnold <nerdboy@gentoo.org>
---
 debugfs/debugfs.c      | 3 +++
 lib/blkid/Android.mk   | 3 ++-
 lib/blkid/devname.c    | 4 ++++
 lib/blkid/devno.c      | 3 +++
 lib/ext2fs/ismounted.c | 3 +++
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 80662b1..ac37275 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -26,6 +26,9 @@ extern char *optarg;
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "debugfs.h"
 #include "uuid/uuid.h"
diff --git a/lib/blkid/Android.mk b/lib/blkid/Android.mk
index 6131f3e..7d697fe 100644
--- a/lib/blkid/Android.mk
+++ b/lib/blkid/Android.mk
@@ -53,7 +53,8 @@ libext2_blkid_cflags_linux := \
    -DHAVE_LINUX_FD_H \
    -DHAVE_SYS_PRCTL_H \
    -DHAVE_LSEEK64 \
-   -DHAVE_LSEEK64_PROTOTYPE
+   -DHAVE_LSEEK64_PROTOTYPE \
+   -DHAVE_SYS_SYSMACROS_H

 include $(CLEAR_VARS)

diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c
index b151354..97a2f4f 100644
--- a/lib/blkid/devname.c
+++ b/lib/blkid/devname.c
@@ -35,8 +35,12 @@
 #if HAVE_SYS_MKDEV_H
 #include <sys/mkdev.h>
 #endif
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif
 #include <time.h>

+
 #include "blkidP.h"

 /*
diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c
index c9f5c92..91c9207 100644
--- a/lib/blkid/devno.c
+++ b/lib/blkid/devno.c
@@ -30,6 +30,9 @@
 #if HAVE_SYS_MKDEV_H
 #include <sys/mkdev.h>
 #endif
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "blkidP.h"

diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index db80c46..247b9ff 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -37,6 +37,9 @@
 #endif /* HAVE_GETMNTINFO */
 #include <string.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif

 #include "ext2_fs.h"
 #include "ext2fs.h"
-- 
2.14.1
UniversalSuperBox commented 5 years ago

Sorry about the really long wait, but I'll leave this here for posterity.

The build instructions for the Fairphone 2, Oneplus One, and Nexus 5 have been compiled and uploaded to https://docs.ubports.com/en/latest/porting/ubp-5.1.html. Please note that building on Ubuntu 16.04 is the only supported way.