Skip to contentSkip to conversation

travis: Cross-compile ARM builds

RFC PATCH New Petr Vorel 2 participants 7 messages Dec 12, 2017 – Dec 14, 2017

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover travis: Cross-compile ARM builds

Hi,

last patch-set for travis, adding cross-compile ARM builds (32-bit and 64-bit). Both builds are in-tree, as out-of-tree build is tested by 2 native builds.

NOTE: It might be possible to add foreign architecture to ubuntu and install other libraries and headers to do build with full dependencies, but I haven't tested it.

See the result:
https://travis-ci.org/pevik-travis/ltp/builds/315469420

Kind regards,
Petr

Petr Vorel (2):
build.sh: Add cross-compile build option
travis: Add 2x cross-compile ARM build

 .travis.yml | 33 ++++++++++++++++-----------------
 build.sh    | 15 ++++++++++++++-
 2 files changed, 30 insertions(+), 18 deletions(-)
Signature · 1 line
2.15.0
author
#1 lore raw

RFC PATCH 1/2 build.sh: Add cross-compile build option

It requires to set CROSS_COMPILE or CC variable.

---
 build.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
build.sh +14 -1
index b0d0fb156..29da4d29e 100755
@@ -26,10 +26,21 @@ build_32()
 
 build_native()
 {
-	echo "===== native in tree build into $PREFIX ====="
+	echo "===== native in-tree build into $PREFIX ====="
 	build_in_tree
 }
 
+build_cross()
+{
+	local host="${CROSS_COMPILE%-}"
+	[ -n "$host" ] || host="${CC%-gcc}"
+	[ -n "$host" ] || \
+		{ echo "Missing CROSS_COMPILE and CC variables. You need to set at least one" >&2; exit 1; }
+
+	echo "===== cross-compile ${host} in-tree build into $PREFIX ====="
+	build_in_tree "--host=$host" CROSS_COMPILE="${host}-"
+}
+
 build_out_tree()
 {
 	local tree="$PWD"
@@ -90,6 +101,7 @@ Options:
 
 BUILD TYPES:
 32      32-bit in-tree build
+cross   cross-compile in-tree build (requires to set CROSS_COMPILE or CC variable)
 native  native in-tree build
 out     out-of-tree build
 
@@ -100,6 +112,7 @@ EOF
 case "$1" in
 	-h|--help|help) usage; exit 0;;
 	32) build="build_32";;
+	cross) build="build_cross";;
 	out) build="build_out_tree";;
 	*) build="build_native";;
 esac
Signature · 1 line
2.15.0
author
#2 lore raw

RFC PATCH 2/2 travis: Add 2x cross-compile ARM build

In reply to Petr Vorel

Use arm-linux-gnueabihf-gcc and aarch64-linux-gnu-gcc compilers.

Cross-compile builds have just minimal dependencies (kernel and glibc headers).

Builds replace native gcc-4.9 and gcc-6 builds to keep max 10 build jobs in travis.

---
 .travis.yml | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
.travis.yml +16 -17
index 2087e4174..74838be7c 100644
@@ -4,14 +4,6 @@ matrix:
     include:
 
         # normal native in-tree builds
-        - os: linux
-          env: BUILD="native" INSTALL_PACKAGES="$BUILD"
-          compiler: gcc-4.9
-          addons:
-              apt:
-                  sources: ['ubuntu-toolchain-r-test']
-                  packages: ['gcc-4.9']
-
         - os: linux
           env: BUILD="native" INSTALL_PACKAGES="$BUILD"
           compiler: gcc-5
@@ -20,14 +12,6 @@ matrix:
                   sources: ['ubuntu-toolchain-r-test']
                   packages: ['gcc-5']
 
-        - os: linux
-          env: BUILD="native" INSTALL_PACKAGES="$BUILD"
-          compiler: gcc-6
-          addons:
-              apt:
-                  sources: ['ubuntu-toolchain-r-test']
-                  packages: ['gcc-6']
-
         - os: linux
           env: BUILD="native" INSTALL_PACKAGES="$BUILD"
           compiler: gcc-7
@@ -87,6 +71,21 @@ matrix:
                   sources: ['ubuntu-toolchain-r-test']
                   packages: ['gcc-7']
 
+        # cross-compile ARM builds
+        - os: linux
+          env: BUILD="cross" INSTALL_PACKAGES="$BUILD"
+          compiler: arm-linux-gnueabihf-gcc
+          addons:
+              apt:
+                  packages: ['gcc-arm-linux-gnueabihf', 'libc6-dev-armhf-cross']
+
+        - os: linux
+          env: BUILD="cross" INSTALL_PACKAGES="$BUILD"
+          compiler: aarch64-linux-gnu-gcc
+          addons:
+              apt:
+                  packages: ['gcc-aarch64-linux-gnu', 'libc6-dev-arm64-cross']
+
 notifications:
     email:
         secure: "b/xcA/K5OyQvPPnd0PRahTH5LJu8lgz8goGHvhXpHo+ZPsPgTDXNFo5cX9fSOkMuFKeoW8iGl0wOgK2+ptc8mbYDw277K4RFIHRHeV/KIoE1EzjQnEFiL8J0oHCAvDj12o0AXeriTyY9gICXKbR31Br6Zh5eKViDJe2OAGeHeDU="
@@ -95,7 +94,7 @@ before_install:
     # installing / removing dependencies
     - if [ "$INSTALL_PACKAGES" = "" ]; then
           sudo apt remove $(cat .travis.packages_native | grep -v -e 'libc6' -e 'libc6-dev' -e 'linux-libc-dev' -e 'libacl1')
-      ; else
+      ; elif [ "$INSTALL_PACKAGES" != "cross" ]; then
           sudo apt install -qq $(cat .travis.packages_native)
       ; fi
 
Signature · 1 line
2.15.0
#3 lore raw

RFC PATCH 2/2 travis: Add 2x cross-compile ARM build

Hi!

Quoted 2 lines

Builds replace native gcc-4.9 and gcc-6 builds to keep max 10 build jobs in travis.

So the cross compilers are gcc-4.x and gcc-6.x? I ask since we just ask for arm cross compilers without a version in the script below.

I that is true I suppose that the cross compiler versions may change without us noticing, which is not that big deal but it may be better to select specific version instead if possible.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

RFC PATCH 2/2 travis: Add 2x cross-compile ARM build

Hi Cyril,

Quoted 2 lines

So the cross compilers are gcc-4.x and gcc-6.x? I ask since we just ask for arm cross compilers without a version in the script below.

Versions are 4.8.4 for both. It's actually visible in the log:

https://travis-ci.org/pevik-travis/ltp/jobs/315469429

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.

https://travis-ci.org/pevik-travis/ltp/jobs/315469430

$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Quoted 3 lines

I that is true I suppose that the cross compiler versions may change without us noticing, which is not that big deal but it may be better to select specific version instead if possible.

The reason why it's not fixed is that it's possible only with special repository ubuntu-toolchain-r-test, which is used for other jobs. AFAIK they don't provide arm toolchain, that's why I used standard trusty repository for ARM.

So is that ok as it is?

Kind regards,
Petr

#5 lore raw

RFC PATCH 2/2 travis: Add 2x cross-compile ARM build

Hi!

Quoted 13 lines
Quoted 2 lines

So the cross compilers are gcc-4.x and gcc-6.x? I ask since we just ask for arm cross compilers without a version in the script below.

Versions are 4.8.4 for both. It's actually visible in the log:

https://travis-ci.org/pevik-travis/ltp/jobs/315469429

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.

https://travis-ci.org/pevik-travis/ltp/jobs/315469430

$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Quoted 8 lines
Quoted 3 lines

I that is true I suppose that the cross compiler versions may change without us noticing, which is not that big deal but it may be better to select specific version instead if possible.

The reason why it's not fixed is that it's possible only with special repository ubuntu-toolchain-r-test, which is used for other jobs. AFAIK they don't provide arm toolchain, that's why I used standard trusty repository for ARM.

So is that ok as it is?

I guess so.

It's a smoke test so we have to keep the number of build reasonably small and having arm builds is agruably more important than all possible gcc flavors. Moreover we still run gcc-4.9 and gcc-6 for 32bit builds right?

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#6 lore raw

RFC PATCH 2/2 travis: Add 2x cross-compile ARM build

Hi!

Quoted 20 lines
Quoted 19 lines
Quoted 2 lines

So the cross compilers are gcc-4.x and gcc-6.x? I ask since we just ask for arm cross compilers without a version in the script below.

Versions are 4.8.4 for both. It's actually visible in the log:

https://travis-ci.org/pevik-travis/ltp/jobs/315469429

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.

https://travis-ci.org/pevik-travis/ltp/jobs/315469430

$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
Quoted 3 lines

I that is true I suppose that the cross compiler versions may change without us noticing, which is not that big deal but it may be better to select specific version instead if possible.

The reason why it's not fixed is that it's possible only with special repository ubuntu-toolchain-r-test, which is used for other jobs. AFAIK they don't provide arm toolchain, that's why I used standard trusty repository for ARM.

Quoted 8 lines
Quoted 1 line

So is that ok as it is?

I guess so.

It's a smoke test so we have to keep the number of build reasonably small and having arm builds is agruably more important than all possible gcc flavors. Moreover we still run gcc-4.9 and gcc-6 for 32bit builds right?

Yes, we do.

Kind regards,
Petr