aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Berglund <patrik.berglund@arm.com>2020-03-11 12:20:43 +0530
committerDeepak Pandey <Deepak.Pandey@arm.com>2020-03-13 21:13:06 +0530
commitb8d9154191f2e8560e380d0b0757a10e1c71d191 (patch)
treec47aaa763496d67de5c7dac9e6df60dd445604b5
parentaad83df493563b1121598e584ec1a3fa6d6631a1 (diff)
n1sdp: add the wrapper script to build perf with openCSDN1SDP-2020.03.26
Signed-off-by: Deepak Pandey <Deepak.Pandey@arm.com>
-rwxr-xr-xbuild-perf.sh191
1 files changed, 191 insertions, 0 deletions
diff --git a/build-perf.sh b/build-perf.sh
new file mode 100755
index 0000000..81f847d
--- /dev/null
+++ b/build-perf.sh
@@ -0,0 +1,191 @@
+#!/bin/bash
+#
+
+set -e
+set -u
+shopt -s nullglob
+
+# these component are build and "installed" in this order
+readonly COMPONENTS=( \
+ opencsd \
+ zlib \
+ libelf \
+ perf \
+)
+
+readonly libelf_URL="https://sourceware.org/pub/elfutils/0.178/elfutils-0.178.tar.bz2"
+readonly opencsd_URL="https://github.com/Linaro/OpenCSD/archive/v0.12.2.tar.gz"
+readonly perf_URL="/dev/null"
+readonly zlib_URL="https://zlib.net/zlib-1.2.11.tar.xz"
+
+opencsd_compile() {
+ cd "$DIR_SRC/decoder/build/linux/"
+ env \
+ ARCH=arm64 \
+ CROSS_COMPILE="$MRTOOLPREFIX" \
+ make $MAKEOPTS
+
+}
+opencsd_install() {
+ cd "$DIR_SRC/decoder/build/linux/"
+ make install PREFIX="$BDIR/sysroot"
+}
+
+
+zlib_configure() {
+ mkdir -p "$DIR_BUILD"
+ cd "$DIR_BUILD"
+ "$DIR_SRC/configure" \
+ --prefix="$BDIR/sysroot" \
+ --static
+}
+
+libelf_configure() {
+ mkdir -p "$DIR_BUILD"
+ cd "$DIR_BUILD"
+ env \
+ CPPFLAGS="-isystem $BDIR/sysroot/include"\
+ LDFLAGS="-L$BDIR/sysroot/lib" \
+ "$DIR_SRC/configure" \
+ --host=x86_64-linux-gnu \
+ --build=aarch64-linux-gnu \
+ --prefix="$BDIR/sysroot" \
+ --disable-debuginfod \
+ --disable-gprof \
+ --disable-gcov \
+ --disable-textrelcheck
+}
+
+perf_compile() {
+ cd "$ME_DIR/linux/tools/perf/"
+
+ # if some other deps of perf is a cxx lib then this will fail with symbol duplications...
+ local libcxx="$(${MRTOOLPREFIX}gcc -print-file-name=libstdc++.a)"
+ local CORESIGHT_OPTS=( \
+ "CORESIGHT=1" \
+ "CSINCLUDES=\"$BDIR/sysroot/include\"" \
+ "CSLIBS=\"$BDIR/sysroot/lib\" -Wl,--whole-archive,$libcxx,--no-whole-archive" \
+ )
+
+ mkdir -p "$DIR_BUILD"
+ env \
+ EXTRA_CFLAGS="-isystem $BDIR/sysroot/include"
+ EXTRA_LDFLAGS="-L$BDIR/sysroot/lib"
+ make \
+ V=1 \
+ "${CORESIGHT_OPTS[@]}" \
+ LDFLAGS="-static" \
+ O="$DIR_BUILD" \
+ ARCH=arm64 \
+ CROSS_COMPILE="${MRTOOLPREFIX}" \
+
+ test -e "$DIR_BUILD/feature/test-libopencsd.bin" || die "opencsd support not activated"
+}
+
+perf_install() {
+ "${MRTOOLPREFIX}strip" --strip-all "$DIR_BUILD/perf" -o "$DIR_BUILD/perf.stripped"
+ install \
+ -m0666 \
+ -Dt "$ME_DIR/output/n1sdp/build_artifact/" \
+ "$DIR_BUILD/perf" \
+ "$DIR_BUILD/perf.stripped"
+}
+
+if test "${MAKEOPTS:-}" = "" ; then
+ MAKEOPTS="-j$(( ($(grep -E '^processor[[:blank:]]*:' /proc/cpuinfo | wc -l))+4 ))"
+ echo "auto populating MAKEOPTS=\"$MAKEOPTS\""
+else
+ echo "user supplied MAKEOPTS=\"$MAKEOPTS\""
+fi
+readonly MAKEOPTS
+
+# Move to the top directory (based on the assuption that we are in build-scripts
+cd "$(dirname "$(realpath "$0")")/.."
+
+if ! test -e sync_workspace.py -a -e readme.rst -a -e board_firmware ; then
+ echo "ERROR: Please make sure to execute the script in the root of 'arm-reference-platforms'" >&2
+ exit 1
+fi
+
+readonly ME_DIR="$PWD"
+readonly MRTOOLPREFIX="$ME_DIR/tools/gcc/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
+readonly CC="${MRTOOLPREFIX}gcc"
+export CC
+
+readonly BDIR="$ME_DIR/output/perf"
+rm -rf "$BDIR"
+mkdir -p "$BDIR"
+
+die() {
+ echo "ERROR: $*" >&2
+ exit 1
+}
+
+phase_get() {
+ local name="$COMPONENT"
+ local url="$1" ; shift
+ test "$url" != "/dev/null" || return 0
+
+ mkdir -p "$BDIR/download/"
+ local filename="$(basename "$url")"
+ local filepath_fetched="$BDIR/download/$filename"
+ if test "${N1SDP_PERF_DOWNLOAD_CACHE:-}" != "" ; then
+ test ! -e "$N1SDP_PERF_DOWNLOAD_CACHE/$name/$filename" \
+ || cp "$N1SDP_PERF_DOWNLOAD_CACHE/$name/$filename"
+ fi
+ test -e "$filepath_fetched" || wget "$url" -O "$filepath_fetched"
+ mkdir -p "$BDIR/comp/$name/"
+ cd "$BDIR/comp/$name/"
+ tar xf "$filepath_fetched"
+ test "$(for x in * ; do echo "$x" ; done | wc -l)" = "1" || die "unexpected content"
+ mv * src
+}
+
+phase_configure() {
+ :
+}
+
+phase_compile() {
+ cd "$DIR_BUILD"
+ make $MAKEOPTS
+}
+
+phase_install() {
+ cd "$DIR_BUILD"
+ make install
+}
+
+phase_exec() {
+ local COMPONENT="$1" ; shift
+ local PHASE="$1" ; shift
+ DIR_SRC="$BDIR/comp/$COMPONENT/src"
+ DIR_BUILD="$BDIR/comp/$COMPONENT/build"
+ printf "%- 10s: $COMPONENT\n" "$PHASE"
+ cd "/"
+ (
+ set -e
+ set -u
+ set -x
+ if declare -f "${COMPONENT}_$PHASE" >/dev/null ; then
+ "${COMPONENT}_$PHASE" "$@"
+ else
+ "phase_$PHASE" "$@"
+ fi
+ ) &> "$BDIR/comp/$comp.$PHASE.log" \
+ || {
+ cat "$BDIR/comp/$comp.$PHASE.log" >&2
+ die "phase step failed"
+ }
+}
+
+mkdir -p "$BDIR/comp"
+for comp in "${COMPONENTS[@]}"; do
+ s="${comp}_URL"
+ phase_exec "$comp" get "${!s}"
+done
+
+for comp in "${COMPONENTS[@]}"; do
+ for PHASE in configure compile install ; do
+ phase_exec "$comp" "$PHASE"
+ done
+done