Thursday, February 08, 2018

Build stress-ng for ARM

From the README file, some packages are needed to build stress-ng:
* libaio-dev
* libapparmor-dev
* libattr1-dev
* libbsd-dev
* libcap-dev
* libgcrypt11-dev
* libkeyutils-dev
* libsctp-dev
* zlib1g-dev

Since I am building stress-ng for testing in-house SoC, not all features are necessary to be enabled to test. Here is the steps I built.

1. Grab sources tarballs from https://packages.debian.org/sid/libaio-dev
These two tarballs are needed:
libaio_0.3.110.orig.tar.gz
libaio_0.3.110-5.debian.tar.xz

$ tar axf libaio_0.3.110.orig.tar.gz
$ tar axf libaio_0.3.110-5.debian.tar.xz
$ cd libaio-0.3.110/
$ for i in `cat ../debian/patches/series`; do patch -p1 < ../debian/patches/${i}; done
$ CC=arm-linux-gnueabihf-gcc CFLAGS=-mcpu=cortex-a9 make prefix=${HOME}/toolchain/arm-sysroot install

If the build failed because of some re-definition of __NR_io_setup, ... etc., modify
libaio-0.3.110/src/syscall-arm.h
to be
#ifndef __NR_io_setup
#define __NR_io_setup                   (__NR_SYSCALL_BASE+243)
#endif
#ifndef __NR_io_destroy
#define __NR_io_destroy                 (__NR_SYSCALL_BASE+244)
#endif
#ifndef __NR_io_getevents
#define __NR_io_getevents               (__NR_SYSCALL_BASE+245)
#endif
#ifndef __NR_io_submit
#define __NR_io_submit                  (__NR_SYSCALL_BASE+246)
#endif
#ifndef __NR_io_cancel
#define __NR_io_cancel                  (__NR_SYSCALL_BASE+247)
#endif


2. Grab source tarball from https://packages.debian.org/sid/zlib1g-dev

$ tar axf zlib_1.2.8.dfsg.orig.tar.gz
$ cd zlib-1.2.8/

$ CC=arm-linux-gnueabihf-gcc CFLAGS="-mcpu=cortex-a9 -O3" ./configure --prefix=${HOME}/toolchain/arm-sysroot
$ make install

3. Build stress-ng

$ tar axf stress-ng-0.09.15.tar.xz
$ cd stress-ng-0.09.15/
$ CC=arm-linux-gnueabihf-gcc \
> CFLAGS="-pthread -mcpu=cortex-a9 -I${HOME}/toolchain/arm-sysroot/include -L${HOME}/toolchain/arm-sysroot/lib" \
> STATIC=1 make ARCH=arm


Copy the generated stress-ng to the board and run

# ./stress-ng  --metrics-brief --verbose --timeout 5m --all 1