]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add ARM cross build and validation
authorJun He <jun.he@arm.com>
Thu, 12 Apr 2018 05:31:59 +0000 (13:31 +0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 28 Apr 2018 16:20:13 +0000 (18:20 +0200)
Update configure and test scripts to cross compile
and validate arm build-outs on x86 by using qemu

Change-Id: I183d003ebafcf686de26fd1705704ded4b344580
Signed-off-by: Jun He <jun.he@arm.com>
.travis.yml
configure
test/Makefile.in
test/testCVEinputs.sh

index 693723c8b527c4e4cc6ae75fd1fef1d70247a9a3..975fc4b22c9c30cd153a4cb4f59564a7e68e3c43 100644 (file)
@@ -47,4 +47,79 @@ matrix:
       compiler: clang
       env: BUILDDIR=../build TOOL="cmake ../zlib-ng"
 
+    # Cross compiling for arm variants
+    - os: linux
+      compiler: aarch64-linux-gnu-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-aarch64-linux-gnu
+            - libc-dev-arm64-cross
+      # For all aarch64 implementations NEON is mandatory, while crypto/crc are not.
+      # So for aarch64 NEON should be automatically enabled, and "acle" should be explicitly defined
+      env: CHOST=aarch64-linux-gnu BUILDDIR=. TOOL="./configure --warn --zlib-compat"
+    - os: linux
+      compiler: aarch64-linux-gnu-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-aarch64-linux-gnu
+            - libc-dev-arm64-cross
+      # AArch64 toolchain in Trusty is 4.8.2, which doesn't support acle intrinsics.
+      # Until TravisCI provides Xenial dist (which comes with gcc-aarch64-5.3.1) 'acle' option cannot
+      # be enabled in subset. But the command
+      # "CHOST=aarch64-linux-gnu ./configure --warn --zlib-compat --acle"
+      # should work if manually test it in a dist with gcc-aarch64 5.1 or higher
+      # env: CHOST=aarch64-linux-gnu BUILDDIR=. TOOL="./configure --warn --zlib-compat --acle"
+      env: CHOST=aarch64-linux-gnu BUILDDIR=. TOOL="./configure --warn --zlib-compat"
+    # Hard-float subsets
+    - os: linux
+      compiler: arm-linux-gnueabihf-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-arm-linux-gnueabihf
+            - libc-dev-armhf-cross
+      env: CHOST=arm-linux-gnueabihf BUILDDIR=. TOOL="./configure --warn"
+    - os: linux
+      compiler: arm-linux-gnueabihf-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-arm-linux-gnueabihf
+            - libc-dev-armhf-cross
+      env: CHOST=arm-linux-gnueabihf BUILDDIR=. TOOL="./configure --warn --zlib-compat --neon"
+    - os: linux
+      compiler: arm-linux-gnueabihf-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-arm-linux-gnueabihf
+            - libc-dev-armhf-cross
+      env: CHOST=arm-linux-gnueabihf BUILDDIR=. TOOL="./configure --warn --zlib-compat"
+    # Soft-float subset
+    - os: linux
+      compiler: arm-linux-gnueabi-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-arm-linux-gnueabi
+            - libc-dev-armel-cross
+      env: CHOST=arm-linux-gnueabi BUILDDIR=. TOOL="./configure"
+    - os: linux
+      compiler: arm-linux-gnueabi-gcc
+      addons:
+        apt:
+          packages:
+            - qemu
+            - gcc-arm-linux-gnueabi
+            - libc-dev-armel-cross
+      env: CHOST=arm-linux-gnueabi BUILDDIR=. TOOL="./configure --zlib-compat"
+
 script: mkdir -p $BUILDDIR && cd $BUILDDIR && $TOOL && make -j2 && make test
index 5eff8749cfe644f7ce5124f8aad2e40e4edd727a..8d64be516b0f99ab3a0627665acb2d04d6733b16 100755 (executable)
--- a/configure
+++ b/configure
@@ -853,6 +853,7 @@ case "${ARCH}" in
 
     # ARM specific optimizations
     arm | armv[3467]l | armv4b | armv4tl | armv5tel | armv5tejl | armv[67]hl | armv7hnl | armv[78]-a | armv8-a+* | armv8.[1234]-a | armv8.[1234]-a+*)
+        [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=arm
         ARCHDIR=arch/arm
         ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} fill_window_arm.o"
         ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} fill_window_arm.lo"
@@ -915,6 +916,7 @@ case "${ARCH}" in
     ;;
     # 64-bit ARM specific optimizations
     aarch64)
+        [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=aarch64
         ARCHDIR=arch/aarch64
         ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} fill_window_arm.o"
         ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} fill_window_arm.lo"
@@ -945,6 +947,15 @@ case "${ARCH}" in
         CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
         SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
     ;;
+    powerpc)
+        [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc
+    ;;
+    powerpc64)
+        [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64
+    ;;
+    *)
+        [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=$ARCH
+    ;;
 esac
 
 echo "ARCH: ${ARCH}"
@@ -1078,6 +1089,7 @@ mkdir -p test
 TESTINCLUDES="-I$SRCDIR"
 if [ "$SRCDIR" != "$BUILDDIR" ]; then TESTINCLUDES="${TESTINCLUDES} -I$BUILDDIR"; fi
 if test $compat -eq 1; then COMPATTESTS="compattests"; fi
+if test $QEMU_ARCH; then QEMU_RUN="qemu-$QEMU_ARCH -L /usr/${CHOST}/"; fi
 sed < $SRCDIR/test/Makefile.in "
 /^CC *=/s#=.*#=$CC#
 /^CFLAGS *=/s#=.*#=$CFLAGS#
@@ -1088,6 +1100,7 @@ sed < $SRCDIR/test/Makefile.in "
 /^SRCDIR *=/s#=.*#=$SRCDIR/test#
 /^SRCTOP *=/s#=.*#=$SRCDIR#
 /^COMPATTESTS *=/s#=.*#=$COMPATTESTS#
+/^QEMU_RUN *=/s#=.*#=$QEMU_RUN#
 " > test/Makefile
 
 # create zlib.pc with the configure results
index 9d6047dd0bf84a7af0188d4ba0bfdeb2ce8e59ca..a78f4daf4b84d3e4c5f2d5eb1d426e8a738ee4c3 100644 (file)
@@ -11,36 +11,44 @@ INCLUDES=
 TEST_LDFLAGS=-L.. ../libz.a
 
 COMPATTESTS =
+QEMU_RUN=
+QEMU_VER:=$(shell command -v $(QEMU_RUN) --version 2> /dev/null)
 
 all: oldtests cvetests $(COMPATTESTS)
 
 oldtests: #set by ../configure
-
-teststatic:
+check_cross_dep:
+ifneq (,$(QEMU_RUN))
+ifeq (,$(QEMU_VER))
+       $(error "You need QEMU to run tests on non-native platform")
+endif
+endif
+
+teststatic: check_cross_dep
        @TMPST=tmpst_$$; \
-       if echo hello world | ../minigzip$(EXE) | ../minigzip$(EXE) -d && ../example$(EXE) $$TMPST ; then \
+       if echo hello world | ${QEMU_RUN} ../minigzip$(EXE) | ${QEMU_RUN} ../minigzip$(EXE) -d && ${QEMU_RUN} ../example$(EXE) $$TMPST ; then \
          echo '                *** zlib test OK ***'; \
        else \
          echo '                *** zlib test FAILED ***'; exit 1; \
        fi; \
        rm -f $$TMPST
 
-testshared:
+testshared: check_cross_dep
        @LD_LIBRARY_PATH=`pwd`/..:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
        LD_LIBRARYN32_PATH=`pwd`/..:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
        DYLD_LIBRARY_PATH=`pwd`/..:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
        SHLIB_PATH=`pwd`/..:$(SHLIB_PATH) ; export SHLIB_PATH; \
        TMPSH=tmpsh_$$; \
-       if echo hello world | ../minigzipsh$(EXE) | ../minigzipsh$(EXE) -d && ../examplesh$(EXE) $$TMPSH; then \
+       if echo hello world | ${QEMU_RUN} ../minigzipsh$(EXE) | ${QEMU_RUN} ../minigzipsh$(EXE) -d && ${QEMU_RUN} ../examplesh$(EXE) $$TMPSH; then \
          echo '                *** zlib shared test OK ***'; \
        else \
          echo '                *** zlib shared test FAILED ***'; exit 1; \
        fi; \
        rm -f $$TMPSH
 
-test64:
+test64: check_cross_dep
        @TMP64=tmp64_$$; \
-       if echo hello world | ../minigzip64$(EXE) | ../minigzip64$(EXE) -d && ../example64$(EXE) $$TMP64; then \
+       if echo hello world | ${QEMU_RUN} ../minigzip64$(EXE) | ${QEMU_RUN} ../minigzip64$(EXE) -d && ${QEMU_RUN} ../example64$(EXE) $$TMP64; then \
          echo '                *** zlib 64-bit test OK ***'; \
        else \
          echo '                *** zlib 64-bit test FAILED ***'; exit 1; \
@@ -52,11 +60,11 @@ cvetests: testCVEinputs
 # Tests requiring zlib-ng to be built with --zlib-compat
 compattests: testCVE-2003-0107
 
-testCVEinputs:
-       @EXE=$(EXE) $(SRCDIR)/testCVEinputs.sh
+testCVEinputs: check_cross_dep
+       @EXE=$(EXE) QEMU_RUN="${QEMU_RUN}" $(SRCDIR)/testCVEinputs.sh
 
-testCVE-2003-0107: CVE-2003-0107$(EXE)
-       @if ./CVE-2003-0107$(EXE); then \
+testCVE-2003-0107: CVE-2003-0107$(EXE) check_cross_dep
+       @if ${QEMU_RUN} ./CVE-2003-0107$(EXE); then \
          echo '                *** zlib not vulnerable to CVE-2003-0107 ***'; \
        else \
          echo '                *** zlib VULNERABLE to CVE-2003-0107 ***'; exit 1; \
index f253d264d3c8152342677436293f220dd694e3cf..8f23438d799b34d83b4f622f3525d1ff7db4206d 100755 (executable)
@@ -1,12 +1,21 @@
 #!/bin/bash
 TESTDIR="$(dirname "$0")"
 
+# check for QEMU if QEMU_RUN is set
+if [ ! -z "${QEMU_RUN}" ]; then
+    QEMU_VERSION=$(${QEMU_RUN} --version 2> /dev/null)
+    if [ -z "${QEMU_VERSION}" ]; then
+        echo "**** You need QEMU to run tests on non-native platform"
+        exit 1
+    fi
+fi
+
 CVEs="CVE-2002-0059 CVE-2004-0797 CVE-2005-1849 CVE-2005-2096"
 
 for CVE in $CVEs; do
     fail=0
     for testcase in ${TESTDIR}/${CVE}/*.gz; do
-       ../minigzip${EXE} -d < "$testcase"
+       ${QEMU_RUN} ../minigzip${EXE} -d < "$testcase"
        # we expect that a 1 error code is OK
        # for a vulnerable failure we'd expect 134 or similar
        if [ $? -ne 1 ] && [ $? -ne 0 ]; then