Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-33405: Add support for ubuntu arm #19571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,19 @@ on:
description: 'Asset Name (if upload-package is true)'
required: false
default: 'build-docker-package'
tag_postfix:
type: string
description: 'Either -arm or empty string'
required: false
default: ''
secrets:
LNB_TOKEN:
required: false

jobs:

build-docker:
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04${{ inputs.tag_postfix }}
steps:
- name: Free additional disk space (remove Android SDK + Tools)
continue-on-error: true
Expand Down Expand Up @@ -113,8 +118,8 @@ jobs:
vcpkg_sha_short=$(git rev-parse --short=8 HEAD)
echo "vcpkg_sha_short=$vcpkg_sha_short" >> $GITHUB_OUTPUT
docker_build_label=hpccsystems/platform-build-${{ inputs.os }}
echo "docker_tag=$docker_build_label:$vcpkg_sha_short" >> $GITHUB_OUTPUT
echo "docker_tag_candidate_base=$docker_build_label:$branch_label" >> $GITHUB_OUTPUT
echo "docker_tag=$docker_build_label:$vcpkg_sha_short${{ inputs.tag_postfix }}" >> $GITHUB_OUTPUT
echo "docker_tag_candidate_base=$docker_build_label:$branch_label${{ inputs.tag_postfix }}" >> $GITHUB_OUTPUT

- name: Print vars
shell: "bash"
Expand All @@ -133,12 +138,12 @@ jobs:
- uses: hendrikmuhs/[email protected]
with:
save: ${{ inputs.update-cache == true }}
key: docker-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-${{ inputs.containerized == true && 'k8s' || 'bare-metal' }}-${{ inputs.ln == true && 'LN' || 'HPCC-Platform' }}
key: docker${{ inputs.tag_postfix }}-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-${{ inputs.containerized == true && 'k8s' || 'bare-metal' }}-${{ inputs.ln == true && 'LN' || 'HPCC-Platform' }}
restore-keys: |
docker-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-${{ inputs.containerized == true && 'k8s' || 'bare-metal' }}-
docker-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-
docker-${{ inputs.os }}-${{ inputs.build-type }}-
docker-${{ inputs.os }}-
docker${{ inputs.tag_postfix }}-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-${{ inputs.containerized == true && 'k8s' || 'bare-metal' }}-
docker${{ inputs.tag_postfix }}-${{ inputs.os }}-${{ inputs.build-type }}-${{ steps.vars.outputs.branch_label }}-
docker${{ inputs.tag_postfix }}-${{ inputs.os }}-${{ inputs.build-type }}-
docker${{ inputs.tag_postfix }}-${{ inputs.os }}-

- name: Docker build image
uses: docker/build-push-action@v5
Expand All @@ -149,7 +154,7 @@ jobs:
push: false
load: true
build-args: |
VCPKG_REF=${{ steps.vars.outputs.vcpkg_sha_short }}
VCPKG_REF=${{ steps.vars.outputs.vcpkg_sha_short }}${{ inputs.tag_postfix }}
tags: |
${{ steps.vars.outputs.docker_tag }}
${{ steps.vars.outputs.docker_tag_candidate_base }}
Expand All @@ -174,7 +179,7 @@ jobs:
--mount source="${{ github.workspace }}/build",target=/hpcc-dev/build,type=bind,consistency=delegated \
--mount source="${{ github.workspace }}/.ccache",target=/root/.ccache,type=bind,consistency=delegated \
${{ steps.vars.outputs.docker_tag }} "\
cmake -G Ninja -S /hpcc-dev/${{ inputs.ln == true && 'LN' || 'HPCC-Platform' }} -B /hpcc-dev/build -DHPCC_SOURCE_DIR=/hpcc-dev/HPCC-Platform -DVCPKG_FILES_DIR=/hpcc-dev -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -DCONTAINERIZED=${{ inputs.containerized == true && 'ON' || 'OFF' }} -DCPACK_STRIP_FILES=${{ inputs.strip-files == true && 'ON' || 'OFF' }} ${{ inputs.single-package == true && '-DINCLUDE_PLUGINS=ON' || '-D$plugin=ON' }} ${{ inputs.cmake-configuration }} ${{ inputs.cmake-configuration-ex }} && \
cmake -G Ninja -S /hpcc-dev/${{ inputs.ln == true && 'LN' || 'HPCC-Platform' }} -B /hpcc-dev/build -DHPCC_SOURCE_DIR=/hpcc-dev/HPCC-Platform -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -DCONTAINERIZED=${{ inputs.containerized == true && 'ON' || 'OFF' }} -DCPACK_STRIP_FILES=${{ inputs.strip-files == true && 'ON' || 'OFF' }} ${{ inputs.single-package == true && '-DINCLUDE_PLUGINS=ON' || '-D$plugin=ON' }} ${{ inputs.cmake-configuration }} ${{ inputs.cmake-configuration-ex }} && \
cmake --build /hpcc-dev/build --parallel ${{ inputs.upload-package == true && '--target package' || ''}}"
done

Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/build-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,29 @@ jobs:
asset-name: 'docker-package'
secrets: inherit

build-docker-ubuntu-24_04-arm:
if: ${{ contains('pull_request,push', github.event_name) }}
uses: ./.github/workflows/build-docker.yml
with:
os: ubuntu-24.04
tag_postfix: "-arm"
secrets: inherit

build-docker-ubuntu-24_04:
if: ${{ contains('pull_request,push', github.event_name) }}
uses: ./.github/workflows/build-docker.yml
with:
os: ubuntu-24.04
secrets: inherit

build-docker-ubuntu-22_04-arm:
if: ${{ contains('pull_request,push', github.event_name) }}
uses: ./.github/workflows/build-docker.yml
with:
os: ubuntu-22.04
tag_postfix: "-arm"
secrets: inherit

build-docker-ubuntu-22_04:
if: ${{ contains('pull_request,push', github.event_name) }}
uses: ./.github/workflows/build-docker.yml
Expand Down Expand Up @@ -214,3 +230,12 @@ jobs:
build-type: 'Release'
cmake-configuration-ex: '-DUSE_CPPUNIT=OFF -DCLIENTTOOLS_ONLY=ON -DINCLUDE_PLUGINS=OFF -DUSE_AZURE=OFF -DUSE_CASSANDRA=OFF -DSUPPRESS_CASSANDRAEMBED=ON -DUSE_JAVA=OFF -DUSE_OPENLDAP=OFF'
secrets: inherit

build-gh_runner-macos-14:
if: ${{ contains('pull_request,push', github.event_name) }}
uses: ./.github/workflows/build-gh_runner.yml
with:
os: macos-14
build-type: 'Release'
cmake-configuration-ex: '-DCMAKE_OSX_ARCHITECTURES=arm64 -DUSE_CPPUNIT=OFF -DCLIENTTOOLS_ONLY=ON -DINCLUDE_PLUGINS=OFF -DUSE_AZURE=OFF -DUSE_CASSANDRA=OFF -DSUPPRESS_CASSANDRAEMBED=ON -DUSE_JAVA=OFF -DUSE_OPENLDAP=OFF'
secrets: inherit
7 changes: 7 additions & 0 deletions cmake_modules/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ elseif(APPLE)
set(VCPKG_TARGET_TRIPLET "x64-osx" CACHE STRING "target triplet")
endif()
elseif(UNIX)
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: If we ever want to do cross-compiling, this won't be correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree - I had a mental note to see if there was a better way than this (like the OSX flag).

string(STRIP ${ARCHITECTURE} ARCHITECTURE)
if(ARCHITECTURE MATCHES "arm" OR ARCHITECTURE MATCHES "aarch64")
set(VCPKG_HOST_TRIPLET "arm64-linux-dynamic" CACHE STRING "host triplet")
set(VCPKG_TARGET_TRIPLET "arm64-linux-dynamic" CACHE STRING "target triplet")
else()
set(VCPKG_HOST_TRIPLET "x64-linux-dynamic" CACHE STRING "host triplet")
set(VCPKG_TARGET_TRIPLET "x64-linux-dynamic" CACHE STRING "target triplet")
endif()
endif()

message("-- vcpkg settings:")
Expand Down
43 changes: 41 additions & 2 deletions dockerfiles/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ trapFunc() {
trap 'trapFunc "${LINENO}/${BASH_LINENO}" "$?" "$BASH_COMMAND"' ERR

globals() {
detect_arch
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"
ROOT_DIR=$(git rev-parse --show-toplevel)

set +e
export $(grep -v '^#' $ROOT_DIR/.env | sed -e 's/\r$//' | xargs) > /dev/null
if [ -f $ROOT_DIR/.env ]; then
export $(grep -v '^#' $ROOT_DIR/.env | sed -e 's/\r$//' | xargs) > /dev/null
fi
set -e

GIT_REF=$(git rev-parse --short=8 HEAD)
Expand All @@ -24,6 +27,10 @@ globals() {
pushd $ROOT_DIR/vcpkg
VCPKG_REF=$(git rev-parse --short=8 HEAD)
popd
if [ "$ARCH" == "arm64" ]; then
VCPKG_REF="$VCPKG_REF-arm"
RELEASE_BASE_IMAGE="arm64v8/$RELEASE_BASE_IMAGE"
fi
DOCKER_USERNAME="${DOCKER_USERNAME:-hpccbuilds}"

CMAKE_OPTIONS="-G Ninja -DCPACK_THREADS=$(docker info --format '{{.NCPU}}') -DUSE_OPTIONAL=OFF -DCONTAINERIZED=ON -DINCLUDE_PLUGINS=ON -DSUPPRESS_V8EMBED=ON"
Expand Down Expand Up @@ -265,6 +272,10 @@ build() {
exit 1
fi

if [ "$ARCH" == "arm64" ]; then
base="$base"
fi

if [ "$RECONFIGURE" -eq 1 ]; then
reconfigure
fi
Expand Down Expand Up @@ -331,6 +342,25 @@ function cleanup() {
fi
}

function detect_arch() {
if [ -z "$ARCH" ]; then
if [ "$(uname -m)" == "x86_64" ]; then
ARCH="x64"
elif [ "$(uname -m)" == "aarch64" ]; then
ARCH="arm64"
elif [ "$(uname -m)" == "arm64" ]; then
ARCH="arm64"
else
echo "Unsupported architecture: $(uname -m)"
exit 1
fi
fi
if [ "$ARCH" != "x64" ] && [ "$ARCH" != "arm64" ]; then
echo "Unsupported architecture: $ARCH"
exit 1
fi
}

trap cleanup EXIT

status() {
Expand All @@ -344,7 +374,9 @@ status() {
echo "MODE: $MODE"
echo "RECONFIGURE: $RECONFIGURE"
echo "BUILD_OS: $BUILD_OS"
echo "RELEASE_BASE_IMAGE: $RELEASE_BASE_IMAGE"
echo "HPCC_BUILD: $HPCC_BUILD"
echo "ARCH: $ARCH"
}

# Print usage information
Expand All @@ -361,6 +393,7 @@ usage() {
echo " -t, --tag tag the build volume with the current branch ref"
echo " will preserve build state per branch"
echo " -r, --reconfigure reconfigure CMake before building"
echo " -a, --architecture override default architecture (x64 or arm64)"
}

# Set default values
Expand All @@ -369,8 +402,9 @@ MODE="release"
RECONFIGURE=0
DEB_FILE=""
BUILD_OS="ubuntu-22.04"
RELEASE_BASE_IMAGE="ubuntu:jammy-20230308" # Matches vcpkg base image (does not need to be an exact match)
RELEASE_BASE_IMAGE="ubuntu:22.04" # Matches vcpkg base image (does not need to be an exact match)
TAG_BUILD=0
ARCH=""

# Parse command line arguments
while [[ $# -gt 0 ]]
Expand Down Expand Up @@ -413,6 +447,11 @@ case $key in
RECONFIGURE=1
shift # past argument
;;
-a|--architecture)
ARCH="$2"
shift # past argument
shift # past value
;;
-h|--help)
usage
exit 0
Expand Down
Loading
Loading