From 16b5f177cb1fa2f74166962ef2871f635bc4209d Mon Sep 17 00:00:00 2001 From: Nick Dunklee Date: Mon, 30 Sep 2024 16:38:22 -0600 Subject: [PATCH] Updating cross-compile for both aarch64 and x86_64 on ARM --- sovrn/Dockerfile | 10 ++++++++-- sovrn/README.md | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sovrn/Dockerfile b/sovrn/Dockerfile index f6e7ff0de50d..dc43d6416c06 100644 --- a/sovrn/Dockerfile +++ b/sovrn/Dockerfile @@ -11,8 +11,14 @@ RUN wget https://downloads.lightbend.com/scala/2.12.17/scala-2.12.17.tgz -P /tmp ln -s /usr/local/scala-2.12.17 /usr/local/scala && \ rm /tmp/scala-2.12.17.tgz -# Set environment variables for Java, Python, Maven, and Scala -ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.aarch64 +# Set a default value for TARGET_PLATFORM +# This is chosen at build time using the --build-arg flag +# Example: docker build --build-arg TARGET_PLATFORM=aarch64 -t xgboost . +ARG TARGET_PLATFORM=aarch64 +#ARG TARGET_PLATFORM=x86_64 + +# Set environment variables for Java and Scala +ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.${TARGET_PLATFORM} ENV PATH=${PATH}:${JAVA_HOME}/bin:/usr/local/scala/bin # Set Java 8 as the default Java version diff --git a/sovrn/README.md b/sovrn/README.md index aa4465c0e0d0..860e0b5f72f5 100644 --- a/sovrn/README.md +++ b/sovrn/README.md @@ -23,6 +23,15 @@ docker run -v $(pwd)/..:/xgboost --rm -it xgboost-build Now you should have a Docker ready to build your jar for aarch64/ARM64. +## Cross-Compile XGBoost for x86_64 on ARM64 + +```bash +docker buildx create --name xgboost-builder --use +docker buildx inspect --bootstrap +docker buildx build --platform linux/amd64 -t xgboost-build . --load --build-arg TARGET_PLATFORM=amd64 +docker run -v $(pwd)/..:/xgboost --rm -it --platform linux/amd64 xgboost-build +``` + # Inside the Docker ```bash