Skip to content

Commit 5e03de2

Browse files
committed
feat: improve ARM64 cross-compilation process in Dockerfile
Signed-off-by: liuhy <[email protected]>
1 parent 2bd7a67 commit 5e03de2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Dockerfile.extproc.cross

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ COPY Makefile ./
5555

5656
# Create a modified Makefile for cross-compilation
5757
RUN if [ "$TARGETARCH" = "arm64" ]; then \
58-
sed -i 's/cargo build --release/cargo build --release --target aarch64-unknown-linux-gnu/' tools/make/rust.mk; \
58+
echo "Modifying rust.mk for ARM64 cross-compilation..."; \
59+
sed -i 's/cd candle-binding && cargo build --release/cd candle-binding \&\& cargo build --release --target aarch64-unknown-linux-gnu/' tools/make/rust.mk; \
60+
cat tools/make/rust.mk | grep "cargo build"; \
5961
fi
6062

6163
# Pre-build dependencies to cache them
@@ -72,8 +74,21 @@ RUN cd candle-binding && \
7274
# Copy source code and build
7375
COPY candle-binding/src/ ./candle-binding/src/
7476

75-
# Build with cross-compilation
76-
RUN make rust
77+
# Build with cross-compilation (rebuild with actual source code)
78+
RUN echo "Building Rust library with actual source code..." && \
79+
echo "Current directory: $(pwd)" && \
80+
echo "TARGETARCH: $TARGETARCH" && \
81+
ls -la candle-binding/src/ && \
82+
# Set up environment for cross-compilation
83+
if [ "$TARGETARCH" = "arm64" ]; then \
84+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc; \
85+
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc; \
86+
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++; \
87+
export AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar; \
88+
fi && \
89+
make rust && \
90+
echo "Checking built library..." && \
91+
find candle-binding/target -name "*.so" -type f
7792

7893
# Build the Go application
7994
FROM --platform=linux/amd64 golang:1.24 as go-builder

0 commit comments

Comments
 (0)