Hmm, can't build crosstool-ng yet.
This commit is contained in:
parent
436a3c085f
commit
2755339c39
86
Dockerfile
86
Dockerfile
@ -10,7 +10,7 @@ ENV CFLAGS="-static -O2" \
|
|||||||
CXXFLAGS="-static -O2" \
|
CXXFLAGS="-static -O2" \
|
||||||
LDFLAGS="-static"
|
LDFLAGS="-static"
|
||||||
|
|
||||||
# Base build tools + musl-dev, etc.
|
# Install build dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
build-base \
|
build-base \
|
||||||
cmake \
|
cmake \
|
||||||
@ -24,10 +24,78 @@ RUN apk add --no-cache \
|
|||||||
linux-headers \
|
linux-headers \
|
||||||
bash \
|
bash \
|
||||||
ccache \
|
ccache \
|
||||||
mold
|
mold \
|
||||||
|
musl-dev \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
python3 \
|
||||||
|
bison \
|
||||||
|
flex \
|
||||||
|
texinfo \
|
||||||
|
gperf \
|
||||||
|
help2man \
|
||||||
|
gettext-dev \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
libtool \
|
||||||
|
patch \
|
||||||
|
gawk \
|
||||||
|
xz-dev
|
||||||
|
|
||||||
# Configure mold as the default linker
|
# Build ncurses from source
|
||||||
ENV LD=mold
|
RUN cd /tmp && \
|
||||||
|
wget https://invisible-mirror.net/archives/ncurses/ncurses-6.4.tar.gz && \
|
||||||
|
tar xf ncurses-6.4.tar.gz && \
|
||||||
|
cd ncurses-6.4 && \
|
||||||
|
./configure --prefix=/usr \
|
||||||
|
--without-shared \
|
||||||
|
--with-normal \
|
||||||
|
--enable-pc-files \
|
||||||
|
--with-pkg-config-libdir=/usr/lib/pkgconfig \
|
||||||
|
--enable-widec \
|
||||||
|
--disable-database \
|
||||||
|
--with-fallbacks=linux \
|
||||||
|
--with-panel \
|
||||||
|
--with-panel-libs && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
make install && \
|
||||||
|
cd .. && \
|
||||||
|
rm -rf ncurses-6.4*
|
||||||
|
|
||||||
|
# Build crosstool-ng
|
||||||
|
RUN cd /tmp && \
|
||||||
|
wget https://github.com/crosstool-ng/crosstool-ng/releases/download/crosstool-ng-1.25.0/crosstool-ng-1.25.0.tar.xz && \
|
||||||
|
tar xf crosstool-ng-1.25.0.tar.xz && \
|
||||||
|
cd crosstool-ng-1.25.0 && \
|
||||||
|
export CPPFLAGS="-I/usr/include/ncursesw" && \
|
||||||
|
./configure --prefix=/usr && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
make install && \
|
||||||
|
cd .. && \
|
||||||
|
rm -rf crosstool-ng-1.25.0*
|
||||||
|
|
||||||
|
# Create crosstool-ng config
|
||||||
|
RUN mkdir -p /tmp/ct-ng && \
|
||||||
|
cd /tmp/ct-ng && \
|
||||||
|
ct-ng aarch64-unknown-linux-musl && \
|
||||||
|
sed -i 's/CT_MUSL_VERSION="1.2.4"/CT_MUSL_VERSION="1.2.4"/' .config && \
|
||||||
|
sed -i 's/CT_GCC_VERSION="13.1.0"/CT_GCC_VERSION="13.1.0"/' .config && \
|
||||||
|
sed -i 's/CT_BINUTILS_VERSION="2.41"/CT_BINUTILS_VERSION="2.41"/' .config && \
|
||||||
|
sed -i 's/CT_LINUX_VERSION="6.1.28"/CT_LINUX_VERSION="6.1.28"/' .config && \
|
||||||
|
sed -i 's/CT_PARALLEL_JOBS=0/CT_PARALLEL_JOBS=$(nproc)/' .config
|
||||||
|
|
||||||
|
# Build the toolchain
|
||||||
|
RUN cd /tmp/ct-ng && \
|
||||||
|
ct-ng build
|
||||||
|
|
||||||
|
# Install the toolchain
|
||||||
|
RUN mkdir -p /opt/cross && \
|
||||||
|
cp -r /tmp/ct-ng/.build/aarch64-unknown-linux-musl/* /opt/cross/ && \
|
||||||
|
rm -rf /tmp/ct-ng
|
||||||
|
|
||||||
|
# Add toolchain to PATH
|
||||||
|
ENV PATH="/opt/cross/bin:${PATH}"
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# nlohmann/json (compiled static .a) #
|
# nlohmann/json (compiled static .a) #
|
||||||
@ -94,13 +162,19 @@ RUN apk add --no-cache \
|
|||||||
curl \
|
curl \
|
||||||
linux-headers \
|
linux-headers \
|
||||||
ccache \
|
ccache \
|
||||||
mold
|
mold \
|
||||||
|
ncurses-dev \
|
||||||
|
ncurses-terminfo-base
|
||||||
|
|
||||||
# Configure mold as the default linker
|
# Configure mold as the default linker
|
||||||
ENV LD=mold
|
ENV LD=mold
|
||||||
|
|
||||||
# Copy pre‑built static libs + headers
|
# Copy pre‑built static libs + headers and cross-compiler toolchain
|
||||||
COPY --from=builder /usr/local /usr/local
|
COPY --from=builder /usr/local /usr/local
|
||||||
|
COPY --from=builder /opt/cross /opt/cross
|
||||||
|
|
||||||
|
# Add toolchain to PATH
|
||||||
|
ENV PATH="/opt/cross/bin:${PATH}"
|
||||||
|
|
||||||
ENV CFLAGS="-static -O2" \
|
ENV CFLAGS="-static -O2" \
|
||||||
CXXFLAGS="-static -O2" \
|
CXXFLAGS="-static -O2" \
|
||||||
|
21
test/cmake/aarch64-linux-gnu.cmake
Normal file
21
test/cmake/aarch64-linux-gnu.cmake
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||||
|
|
||||||
|
# Specify the cross compilers
|
||||||
|
set(CMAKE_C_COMPILER /opt/cross/bin/aarch64-unknown-linux-musl-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER /opt/cross/bin/aarch64-unknown-linux-musl-g++)
|
||||||
|
|
||||||
|
# Where is the target environment
|
||||||
|
set(CMAKE_FIND_ROOT_PATH /opt/cross/aarch64-unknown-linux-musl)
|
||||||
|
|
||||||
|
# Search for programs in the build host directories
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
|
||||||
|
# Search for libraries and headers in the target directories
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
|
# Set compiler flags
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a")
|
34
test/crossbuild.sh
Executable file
34
test/crossbuild.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TARGET_ARCH="aarch64"
|
||||||
|
OUTDIR="output-${TARGET_ARCH}"
|
||||||
|
|
||||||
|
# Create volume if it doesn't exist
|
||||||
|
docker volume create cppbuild-cache-${TARGET_ARCH}
|
||||||
|
|
||||||
|
# Build command to run in the container
|
||||||
|
BUILD_COMMAND="mkdir -p /app/build && \
|
||||||
|
cd /app/build && \
|
||||||
|
cmake -G Ninja \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=/app/src/cmake/${TARGET_ARCH}-linux-gnu.cmake \
|
||||||
|
/app/src && \
|
||||||
|
ninja -j$(nproc) && \
|
||||||
|
mkdir -p /app/src/$OUTDIR && \
|
||||||
|
cp /app/build/ipdemo /app/src/$OUTDIR/ipdemo && \
|
||||||
|
chown -R $(id -u):$(id -g) /app/src/$OUTDIR"
|
||||||
|
|
||||||
|
# Run the build in the container
|
||||||
|
docker run --rm \
|
||||||
|
-v cppbuild-cache-${TARGET_ARCH}:/app/build \
|
||||||
|
-v $(pwd):/app/src \
|
||||||
|
-w /app/src \
|
||||||
|
-e CCACHE_DIR=/app/build/.ccache \
|
||||||
|
-e CC="ccache /opt/cross/bin/aarch64-unknown-linux-musl-gcc" \
|
||||||
|
-e CXX="ccache /opt/cross/bin/aarch64-unknown-linux-musl-g++" \
|
||||||
|
-e LD=mold \
|
||||||
|
-e CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) \
|
||||||
|
-e NINJA_STATUS="[%f/%t] " \
|
||||||
|
cpp-httplib-builder:latest \
|
||||||
|
-c "$BUILD_COMMAND"
|
||||||
|
|
||||||
|
echo "Build completed. Output is in $OUTDIR directory"
|
Loading…
x
Reference in New Issue
Block a user