feat(docker): add ARM64 cross-compilation support via Docker
Add Dockerfile and build script for Linux aarch64 cross-compilation targeting ARM64 devices like Raspberry Pi. Includes documentation updates explaining the build process and troubleshooting tips. The changes enable building Palladium binaries for ARM64 architecture using cross-compilation in a Docker container, with output binaries placed in the build directory.
This commit is contained in:
16
docker-build/Dockerfile.linux-aarch64
Normal file
16
docker-build/Dockerfile.linux-aarch64
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive TZ=UTC
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential libtool autotools-dev automake autoconf pkg-config \
|
||||||
|
bsdmainutils python3 curl ca-certificates git unzip zip file rsync \
|
||||||
|
make cmake patch \
|
||||||
|
g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY . /src
|
||||||
|
|
||||||
|
CMD ["/bin/bash"]
|
||||||
@@ -64,6 +64,77 @@ docker run --rm -it -v "$(pwd)/../build/linux-x86_64":/out palladium-builder:lin
|
|||||||
|
|
||||||
**Missing dependencies:** The Dockerfile installs all required build dependencies automatically
|
**Missing dependencies:** The Dockerfile installs all required build dependencies automatically
|
||||||
|
|
||||||
|
## Linux aarch64 Build
|
||||||
|
|
||||||
|
### Overview
|
||||||
|
|
||||||
|
This build creates Linux aarch64 (ARM64) binaries specifically designed for single board computers like the popular Raspberry Pi and other ARM-based devices. The build process uses cross-compilation in a Docker container:
|
||||||
|
|
||||||
|
1. **Builds a Docker image** (`palladium-builder:linux-aarch64-ubuntu20.04`) containing ARM64 cross-compilation toolchain
|
||||||
|
2. **Copies the entire repository** into the container during image build
|
||||||
|
3. **Cross-compiles for ARM64** using the `depends` system with `aarch64-linux-gnu` target
|
||||||
|
4. **Outputs binaries** to a mounted volume for host access
|
||||||
|
|
||||||
|
### Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd docker-build
|
||||||
|
chmod +x build-linux-aarch64.sh
|
||||||
|
./build-linux-aarch64.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
ARM64 binaries will be available in `../build/linux-aarch64/` directory.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Docker installed and running ([installation guide](https://docs.docker.com/get-docker/))
|
||||||
|
- Sufficient disk space for the build process (at least 12 GB free)
|
||||||
|
- Internet connection for downloading dependencies and ARM64 cross-compilation toolchain
|
||||||
|
|
||||||
|
### Target Devices
|
||||||
|
|
||||||
|
This build is optimized for:
|
||||||
|
- **Raspberry Pi 4** and newer models
|
||||||
|
- **Raspberry Pi 3** (64-bit mode)
|
||||||
|
- Other ARM64-based single board computers
|
||||||
|
- ARM64 Linux servers and workstations
|
||||||
|
|
||||||
|
### Produced Binaries
|
||||||
|
|
||||||
|
The following ARM64 binaries are built and copied to the output directory:
|
||||||
|
|
||||||
|
- `palladiumd`: Main daemon
|
||||||
|
- `palladium-cli`: Command-line client
|
||||||
|
- `palladium-tx`: Transaction utility
|
||||||
|
- `palladium-wallet`: Wallet utility
|
||||||
|
- `palladium-qt`: GUI application (if Qt dependencies are available)
|
||||||
|
|
||||||
|
### Output Directory
|
||||||
|
|
||||||
|
Binaries are placed in: `../build/linux-aarch64/` (relative to the docker-build directory)
|
||||||
|
|
||||||
|
### Cross-Compilation Details
|
||||||
|
|
||||||
|
- **Target Triple**: `aarch64-linux-gnu`
|
||||||
|
- **Toolchain**: GCC ARM64 cross-compiler
|
||||||
|
- **Dependencies**: Built using the `depends` system for ARM64 target
|
||||||
|
- **Configuration**: Uses `CONFIG_SITE` for proper cross-compilation setup
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
**Permission errors:** The build script automatically handles file permissions using host UID/GID
|
||||||
|
|
||||||
|
**Build failed:** Run interactive container for debugging:
|
||||||
|
```bash
|
||||||
|
docker run --rm -it -v "$(pwd)/../build/linux-aarch64":/out palladium-builder:linux-aarch64-ubuntu20.04 bash
|
||||||
|
```
|
||||||
|
|
||||||
|
**Cross-compilation issues:** Ensure the ARM64 cross-compilation toolchain is properly installed in the container
|
||||||
|
|
||||||
|
**Missing binaries:** Check that the configure script detected the ARM64 target correctly
|
||||||
|
|
||||||
|
**Docker build issues:** Ensure Docker has sufficient resources and the daemon is running
|
||||||
|
|
||||||
## Windows x86_64 Build
|
## Windows x86_64 Build
|
||||||
|
|
||||||
### Overview
|
### Overview
|
||||||
|
|||||||
61
docker-build/build-linux-aarch64.sh
Normal file
61
docker-build/build-linux-aarch64.sh
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
IMAGE_NAME="palladium-builder:linux-aarch64-ubuntu20.04"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
|
OUT_DIR="${REPO_DIR}/build/aarch64"
|
||||||
|
HOST_TRIPLE="aarch64-linux-gnu"
|
||||||
|
|
||||||
|
HOST_UID="$(id -u)"
|
||||||
|
HOST_GID="$(id -g)"
|
||||||
|
|
||||||
|
echo "[*] Build image including ALL repository files (COPY . /src)..."
|
||||||
|
|
||||||
|
docker build --platform=linux/amd64 \
|
||||||
|
-t "$IMAGE_NAME" \
|
||||||
|
-f "${SCRIPT_DIR}/Dockerfile.linux-aarch64" \
|
||||||
|
"${REPO_DIR}"
|
||||||
|
|
||||||
|
mkdir -p "${OUT_DIR}"
|
||||||
|
|
||||||
|
echo "[*] Start container: build COMPLETED in container; mount ONLY output..."
|
||||||
|
docker run --rm --platform=linux/amd64 \
|
||||||
|
-e HOST_UID="${HOST_UID}" -e HOST_GID="${HOST_GID}" \
|
||||||
|
-v "${OUT_DIR}":/out \
|
||||||
|
"$IMAGE_NAME" \
|
||||||
|
bash -c "
|
||||||
|
set -euo pipefail
|
||||||
|
cd /src
|
||||||
|
|
||||||
|
echo '[*] depends (HOST=${HOST_TRIPLE})...'
|
||||||
|
cd depends && make HOST=${HOST_TRIPLE} -j\$(nproc) && cd ..
|
||||||
|
|
||||||
|
echo '[*] autogen/configure...'
|
||||||
|
[[ -x ./autogen.sh ]] && ./autogen.sh
|
||||||
|
[[ -f ./configure ]] || { echo 'configure not found: autogen failed'; exit 1; }
|
||||||
|
|
||||||
|
./configure --prefix=\$PWD/depends/${HOST_TRIPLE} \
|
||||||
|
--host=${HOST_TRIPLE} \
|
||||||
|
--enable-glibc-back-compat \
|
||||||
|
--enable-reduce-exports \
|
||||||
|
CC=${HOST_TRIPLE}-gcc CXX=${HOST_TRIPLE}-g++ \
|
||||||
|
AR=${HOST_TRIPLE}-ar RANLIB=${HOST_TRIPLE}-ranlib STRIP=${HOST_TRIPLE}-strip \
|
||||||
|
LDFLAGS='-static-libstdc++'
|
||||||
|
|
||||||
|
echo '[*] make...'
|
||||||
|
make -j\$(nproc)
|
||||||
|
|
||||||
|
echo '[*] copy binaries to /out...'
|
||||||
|
mkdir -p /out
|
||||||
|
for b in src/palladiumd src/palladium-cli src/palladium-tx src/palladium-wallet src/qt/palladium-qt; do
|
||||||
|
[[ -f \"\$b\" ]] && install -m 0755 \"\$b\" /out/
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add permissions to host user
|
||||||
|
chown -R \${HOST_UID:-0}:\${HOST_GID:-0} /out
|
||||||
|
|
||||||
|
echo '[*] build COMPLETED (all binaries in container) → /out'
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "[*] Binaries aarch64 available in: ${OUT_DIR}"
|
||||||
Reference in New Issue
Block a user