diff --git a/doc/BUILDING.rst b/doc/BUILDING.rst index 87281a6d..09e518f5 100644 --- a/doc/BUILDING.rst +++ b/doc/BUILDING.rst @@ -213,6 +213,27 @@ The path of the system tree can be overridden from the default values defined in cd ../STT/native_client make TARGET= stt +RPi4 ARMv8 (Ubuntu 21.10) +^^^^^^^^^^^^^^^^^^^^^^^^^ + +We support cross-compilation from Linux hosts. The following ``--config`` flags can be specified when building with bazel: + +* ``--config=rpi4ub-armv8_opt`` for Ubuntu / ARM64 + +Your command line should look like: + +.. code-block:: + + bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" -c opt --config=rpi4ub-armv8_opt //native_client:libstt.so + +The ``stt`` binary can also be cross-built, with ``TARGET=rpi4ub-armv8``. This might require you to setup a system tree using the tool ``multistrap`` and the multistrap configuration file: ``native_client/multistrap-ubuntu64-impish.conf``. +The path of the system tree can be overridden from the default values defined in ``definitions.mk`` through the ``RASPBIAN`` ``make`` variable. + +.. code-block:: + + cd ../STT/native_client + make TARGET=rpi4ub-armv8 stt + Building ``libstt.so`` for Android ---------------------------------- diff --git a/native_client/BUILD b/native_client/BUILD index 334934a5..2e94a56d 100644 --- a/native_client/BUILD +++ b/native_client/BUILD @@ -19,6 +19,13 @@ config_setting( }, ) +config_setting( + name = "rpi4ub-armv8", + define_values = { + "target_system": "rpi4ub-armv8" + }, +) + genrule( name = "workspace_status", outs = ["workspace_status.cc"], diff --git a/native_client/definitions.mk b/native_client/definitions.mk index 99aba3b2..4846ed11 100644 --- a/native_client/definitions.mk +++ b/native_client/definitions.mk @@ -112,6 +112,28 @@ NODE_PLATFORM_TARGET := --target_arch=arm64 --target_platform=linux TOOLCHAIN_LDD_OPTS := --root $(RASPBIAN)/ endif # ($(TARGET),rpi3-armv8) +# Custom: RPi 4, Ubuntu 21.10, Arm v8 (64-bit) +ifeq ($(TARGET),rpi4ub-armv8) +TOOLCHAIN_DIR ?= ${TFDIR}/bazel-$(shell basename "${TFDIR}")/external/LinaroAarch64Gcc72/bin +TOOLCHAIN ?= $(TOOLCHAIN_DIR)/aarch64-linux-gnu- +RASPBIAN ?= $(abspath $(NC_DIR)/../multistrap-ubuntu64-impish) +CFLAGS := -march=armv8-a -mtune=cortex-a72 -D_GLIBCXX_USE_CXX11_ABI=0 --sysroot $(RASPBIAN) +CXXFLAGS := $(CFLAGS) +LDFLAGS := -Wl,-rpath-link,$(RASPBIAN)/lib/aarch64-linux-gnu/ -Wl,-rpath-link,$(RASPBIAN)/usr/lib/aarch64-linux-gnu/ + +SOX_CFLAGS := -I$(RASPBIAN)/usr/include +SOX_LDFLAGS := $(RASPBIAN)/usr/lib/aarch64-linux-gnu/libsox.so + +PYVER := $(shell python -c "import platform; maj, min, _ = platform.python_version_tuple(); print(maj+'.'+min);") +PYTHON_PACKAGES := +PYTHON_PATH := PYTHONPATH=$(RASPBIAN)/usr/lib/python$(PYVER)/:$(RASPBIAN)/usr/lib/python3/dist-packages/ +PYTHON_SYSCONFIGDATA := _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_aarch64-linux-gnu +NUMPY_INCLUDE := NUMPY_INCLUDE=$(RASPBIAN)/usr/include/python3.9/ +PYTHON_PLATFORM_NAME := --plat-name linux_aarch64 +NODE_PLATFORM_TARGET := --target_arch=arm64 --target_platform=linux +TOOLCHAIN_LDD_OPTS := --root $(RASPBIAN)/ +endif # ($(TARGET),rpi4ub-armv8) + ifeq ($(TARGET),ios-simulator) CFLAGS := -isysroot $(shell xcrun -sdk iphonesimulator13.5 -show-sdk-path) SOX_CFLAGS := diff --git a/native_client/multistrap_ubuntu64_impish.conf b/native_client/multistrap_ubuntu64_impish.conf new file mode 100644 index 00000000..b8119606 --- /dev/null +++ b/native_client/multistrap_ubuntu64_impish.conf @@ -0,0 +1,14 @@ +[General] +arch=arm64 +noauth=false +unpack=true +debootstrap=Debian +aptsources=Debian +cleanup=true + +[Debian] +packages=apt libc6 libc6-dev libstdc++-7-dev linux-libc-dev libffi-dev libpython3.9-dev libsox-dev python3-numpy python3-setuptools +source=http://ports.ubuntu.com/ubuntu-ports +keyring=ubuntu-keyring +components=main universe +suite=impish