ci: Add libelf to the Android image.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 3 Oct 2021 15:34:29 +0000 (17:34 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 9 Nov 2021 20:51:14 +0000 (20:51 +0000)
Needed for RADV.

The mirror situation is kinda messy since the library is not
maintained and the original website is offline. Put a mirror
in that seemed to be used by some non-fdo CIs already, but
if reliability is still a concern we can discuss more mirrors.

There is an alternative implementation that is maintained in
elfutils, but that doesn't build on Android:
1) Doesn't build with clang (resolved in git, so next release probably)
2) Needs argp_parse with is a glibc specific feature.

There is a version of elfutils in AOSP but instead of fixing upstream
they just made an Android.bp that avoids building most stuff, which
isn't really usable here.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13164>

.gitlab-ci.yml
.gitlab-ci/container/debian/android_build.sh

index 360a532..fc3509c 100644 (file)
@@ -376,7 +376,7 @@ debian/android_build:
   extends:
     - .use-debian/x86_build-base
   variables:
-    MESA_IMAGE_TAG: &debian-android_build "2021-10-02-bump-libdrm-3"
+    MESA_IMAGE_TAG: &debian-android_build "2021-10-02-libelf-2"
 
 .use-debian/android_build:
   extends:
index 45f75e1..54ec8cf 100644 (file)
@@ -3,6 +3,7 @@
 set -ex
 
 EPHEMERAL="\
+         autoconf \
          rdfind \
          unzip \
          "
@@ -58,4 +59,48 @@ done
 
 rm -rf $LIBDRM_VERSION
 
+export LIBELF_VERSION=libelf-0.8.13
+wget https://fossies.org/linux/misc/old/$LIBELF_VERSION.tar.gz
+
+# Not 100% sure who runs the mirror above so be extra careful
+if ! echo "4136d7b4c04df68b686570afa26988ac ${LIBELF_VERSION}.tar.gz" | md5sum -c -; then
+    echo "Checksum failed"
+    exit 1
+fi
+
+tar -xf ${LIBELF_VERSION}.tar.gz
+cd $LIBELF_VERSION
+
+# Work around a bug in the original configure not enabling __LIBELF64.
+autoreconf
+
+for arch in \
+        x86_64-linux-android \
+        i686-linux-android \
+        aarch64-linux-android \
+        arm-linux-androideabi ; do
+
+    ccarch=${arch}
+    if [ "${arch}" ==  'arm-linux-androideabi' ]
+    then
+       ccarch=armv7a-linux-androideabi
+    fi
+
+    export CC=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ar
+    export CC=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}29-clang
+    export CXX=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}29-clang++
+    export LD=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ld
+    export RANLIB=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ranlib
+
+    # The configure script doesn't know about android, but doesn't really use the host anyway it
+    # seems
+    ./configure --host=x86_64-linux-gnu  --disable-nls --disable-shared \
+                --libdir=/usr/local/lib/${arch}
+    make install
+    make distclean
+done
+
+cd ..
+rm -rf $LIBELF_VERSION
+
 apt-get purge -y $EPHEMERAL