Add build scripts and continuous integration for ARM (#460)

* Scripts for ARM build

* Set permissions

* Fix ARM script bugs

* Fix typo

* Tweak ARM build

* Update README with ARM build instructions
This commit is contained in:
Douglas Stebila 2019-02-12 16:42:34 -05:00 committed by GitHub
parent a7da6ec8ea
commit e0eda13ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 7 deletions

View File

@ -20,6 +20,19 @@ matrix:
- graphviz
before_install:
- sh .travis/install-clang-format-linux.sh
script:
- .travis/all-tests.sh
- os: linux
compiler: arm-linux-gnueabi-gcc
addons:
apt:
packages:
- gcc-arm-linux-gnueabi
- libc6-dev-armel-cross
- qemu
script:
- scripts/arm-cross-compile.sh
- scripts/arm-run-tests-qemu.sh
- os: linux
compiler: gcc
env:
@ -35,6 +48,8 @@ matrix:
- graphviz
before_install:
- sh .travis/install-clang-format-linux.sh
script:
- .travis/all-tests.sh
- os: linux
compiler: gcc
env: CC_OVERRIDE=gcc-5
@ -46,6 +61,8 @@ matrix:
- gcc-5
- doxygen
- graphviz
script:
- .travis/all-tests.sh
- os: linux
compiler: gcc
env:
@ -60,6 +77,8 @@ matrix:
- libssl-dev
- doxygen
- graphviz
script:
- .travis/all-tests.sh
- os: osx
compiler: clang
env:
@ -70,6 +89,8 @@ matrix:
before_install:
- brew update
- brew install libsodium doxygen graphviz
script:
- .travis/all-tests.sh
- os: osx
compiler: clang
env:
@ -78,6 +99,5 @@ matrix:
before_install:
- brew update
- brew install doxygen graphviz
script:
- .travis/all-tests.sh
script:
- .travis/all-tests.sh

View File

@ -149,14 +149,21 @@ Builds are tested using the Appveyor continuous integration system on Windows Se
The supported schemes are defined in the projects' `winconfig.h` file.
Building on other platforms
Building and running on ARM
---------------------------
We do not yet fully support building liboqs on ARM platforms, but are working towards maintaining ARM support in a future release.
Binaries for ARM can be cross-compiled from Ubuntu Linux. Builds are tested using the Travis continuous integration system on Ubuntu 14.04.5 with QEMU target CPU Cortex-A8.
At present, we have successfully built liboqs on a Raspberry Pi 3B (armv7l) with the following configure command:
In order to cross compile, you need to have an appropriate toolchain installed, and to test you need QEMU installed. On Ubuntu:
./configure --disable-aes-ni --disable-sig-qtesla --disable-kem-frodokem
sudo apt install gcc-arm-linux-gnueabi libc6-dev-armel-cross qemu
Once the toolchain is installed, you can use the following scripts to build and test ARM builds from Ubuntu Linux:
scripts/arm-cross-compile.sh
scripts/arm-run-tests-qemu.sh
At present there are still some quirks with our ARM build, including problems with the Picnic and qTESLA and the known answer tests causing build errors or segmentation faults. See issues #461, #462, and #463.
Documentation
-------------

35
scripts/arm-cross-compile.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# sudo apt-get install gcc-arm-linux-gnueabi libc6-dev-armel-cross
set -e
CBUILD="$(gcc -dumpmachine)"
CHOST=arm-linux-gnueabi
rm -rf build-arm
mkdir build-arm
PREFIX="$(pwd)/build-arm"
if [ ! -f "openssl-1.1.1a.tar.gz" ]; then
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
fi
rm -rf openssl-1.1.1a
tar zxf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
CC="${CHOST}-gcc" ./Configure linux-armv4 no-shared no-dso no-hw no-engine no-tests -DOPENSSL_NO_SECURE_MEMORY --prefix="${PREFIX}"
make -j
make install_dev
cd ..
autoreconf -i
hacks=(
gcc_cv_compiler=true # Detecting at this phase isn't good for cross compilation
--disable-aes-ni # This should be conditionalized on x86 host
--disable-sig-picnic
CFLAGS=-D_ARM_ # Several files aren't using the right define
)
./configure --disable-shared --enable-static --host="${CHOST}" --build="$CBUILD" CC="${CHOST}-gcc" --with-openssl-dir="${PREFIX}" "${hacks[@]}"
make -j
make -j check LDFLAGS="-L${PREFIX}/lib -static"

13
scripts/arm-run-tests-qemu.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# sudo apt-get install qemu
set -e
CHOST=arm-linux-gnueabi
qemu-arm -cpu cortex-a8 -L /usr/arm-linux-gnueabi tests/example_kem
qemu-arm -cpu cortex-a8 -L /usr/arm-linux-gnueabi tests/test_kem
# qemu-arm -cpu cortex-a8 -L /usr/arm-linux-gnueabi tests/example_sig
# qemu-arm -cpu cortex-a8 -L /usr/arm-linux-gnueabi tests/test_sig