From ea6a17ea0339628e367debc208c91ef92f367f9a Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 20 Jul 2022 20:08:41 -0700 Subject: [PATCH] fix broken dependencies when building on aarch64 --- Makefile | 19 ++++++++++++++++--- install-deps.sh | 23 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 67f9c58..a701537 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,18 @@ .PHONY: all clean configure -all: build-ppc64le/benchmarks build-aarch64/benchmarks build-x86_64/benchmarks + +host_arch = $(shell uname -m) +ifeq ($(host_arch),x86_64) + enabled_arches = ppc64le aarch64 x86_64 +else ifeq ($(host_arch),aarch64) + # debian 10 doesn't have cross-compilers for ppc64le from aarch64 + enabled_arches = aarch64 x86_64 +else ifeq ($(host_arch),ppc64le) + enabled_arches = ppc64le aarch64 x86_64 +else + $(error unsupported arch $(host_arch)) +endif + +all: $(foreach arch,$(enabled_arches),build-$(arch)/benchmarks) common_cmake_flags = -S . common_cmake_flags += -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE @@ -7,7 +20,7 @@ common_cmake_flags += -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE reset_make_env = "MAKEFLAGS=" "MFLAGS=" "MAKELEVEL=" "MAKE_TERMERR=" "MAKE_TERMOUT=" .installed-dependencies: install-deps.sh - ./install-deps.sh + ./install-deps.sh $(enabled_arches) touch .installed-dependencies build-ppc64le/Makefile: toolchain-powerpc64le-linux-gnu.cmake CMakeLists.txt .installed-dependencies @@ -22,7 +35,7 @@ build-x86_64/Makefile: toolchain-x86_64-linux-gnu.cmake CMakeLists.txt .installe rm -fr build-x86_64 env $(reset_make_env) cmake $(common_cmake_flags) -B build-x86_64 -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-linux-gnu.cmake -configure: build-ppc64le/Makefile build-aarch64/Makefile build-x86_64/Makefile +configure: $(foreach arch,$(enabled_arches),build-$(arch)/Makefile) .PHONY: __force-run diff --git a/install-deps.sh b/install-deps.sh index b9c9fd2..d1acd39 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -1,14 +1,31 @@ #!/bin/bash set -e +arches="$*" +if [[ "$arches" == "" ]]; then + arches="x86_64 aarch64 ppc64le" +fi # need to install g++ first so the local arch will get filtered out later which g++ > /dev/null || (set -x; sudo apt install build-essential g++) needed=() -which x86_64-linux-gnu-g++ > /dev/null || needed+=(g++-x86-64-linux-gnu) -which aarch64-linux-gnu-g++ > /dev/null || needed+=(g++-aarch64-linux-gnu) -which powerpc64le-linux-gnu-g++ > /dev/null || needed+=(g++-powerpc64le-linux-gnu) +for arch in $arches; do + case "$arch" in + x86_64) + which x86_64-linux-gnu-g++ > /dev/null || needed+=(g++-x86-64-linux-gnu) + ;; + aarch64) + which aarch64-linux-gnu-g++ > /dev/null || needed+=(g++-aarch64-linux-gnu) + ;; + ppc64le) + which powerpc64le-linux-gnu-g++ > /dev/null || needed+=(g++-powerpc64le-linux-gnu) + ;; + *) + echo "unknown arch: $arch" >&2 + exit 1 + esac +done which clang++-11 > /dev/null || needed+=(clang-11) which make > /dev/null || needed+=(make) which cmake > /dev/null || needed+=(cmake) -- 2.30.2