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

Enable cross compiling arm #38

Merged
merged 12 commits into from
Aug 5, 2024
44 changes: 36 additions & 8 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,70 @@ jobs:
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
arm_c_compiler: clang
arm_cpp_compiler: clang++
- os: ubuntu-22.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: ubuntu-22.04
c_compiler: clang
cpp_compiler: clang++
arm_c_compiler: clang
arm_cpp_compiler: clang++
- os: ubuntu-20.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: ubuntu-20.04
c_compiler: clang
cpp_compiler: clang++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: windows-latest

steps:
- uses: actions/checkout@v4

- name: Build using CMake on Linux
- name: Install cross compiler
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples.sh
--no-tests
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
run: |
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu libstdc++6-arm64-cross linux-libc-dev-arm64-cross

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
if: ${{ Contains(matrix.os, 'windows') }}
id: runvcpkg
with:
# The vcpkg.json file, which will be part of cache key computation.
vcpkgJsonGlob: '**/src/vcpkg.json'

- name: Build using CMake on Linux for amd64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_x64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}

- name: Cleanup Build
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
rm -r ../nx-lyve-cloud-plugin-build/

- name: Build using CMake on Linux for arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_arm64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }}

- name: Build using CMake on Windows
shell: powershell
if: ${{ Contains(matrix.os, 'windows') }}
Expand Down
83 changes: 62 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,70 @@ jobs:
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: ubuntu-22.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: ubuntu-20.04
c_compiler: gcc
cpp_compiler: g++
arm_c_compiler: aarch64-linux-gnu-gcc
arm_cpp_compiler: aarch64-linux-gnu-g++
- os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run build script for Linux
- name: Install cross compiler
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples.sh
--no-tests
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
run: |
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
if: ${{ Contains(matrix.os, 'windows') }}
id: runvcpkg
with:
# The vcpkg.json file, which will be part of cache key computation.
vcpkgJsonGlob: '**/src/vcpkg.json'

- name: Run build script for Linux x64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_x64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}

- name: Package Artifacts Linux x64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
mkdir nx-lyve-cloud-plugin-${{ matrix.os }}_x64
mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}_x64/cloudfuse_plugin.so
cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}_x64/
zip -r nx-lyve-cloud-plugin-${{ matrix.os }}_x64.zip nx-lyve-cloud-plugin-${{ matrix.os }}_x64

- name: Cleanup Build
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
rm -r ../nx-lyve-cloud-plugin-build/

- name: Run build script for Linux arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_arm64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }}

- name: Package Artifacts Linux arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
mkdir nx-lyve-cloud-plugin-${{ matrix.os }}_arm64
mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}_arm64/cloudfuse_plugin.so
cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}_arm64/
zip -r nx-lyve-cloud-plugin-${{ matrix.os }}_arm64.zip nx-lyve-cloud-plugin-${{ matrix.os }}_arm64

- name: Run build script for Windows
shell: powershell
Expand All @@ -48,14 +86,6 @@ jobs:
.\build_samples.bat
--no-tests

- name: Package Artifacts Linux
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
mkdir nx-lyve-cloud-plugin-${{ matrix.os }}
mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}/cloudfuse_plugin.so
cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}/
zip -r nx-lyve-cloud-plugin-${{ matrix.os }}.zip nx-lyve-cloud-plugin-${{ matrix.os }}

- name: Package Artifacts Windows
shell: powershell
if: ${{ Contains(matrix.os, 'windows') }}
Expand All @@ -64,12 +94,20 @@ jobs:
mv ..\nx-lyve-cloud-plugin-build\cloudfuse_plugin\Release\cloudfuse_plugin.dll nx-lyve-cloud-plugin-windows/cloudfuse_plugin.dll
Compress-Archive nx-lyve-cloud-plugin-windows nx-lyve-cloud-plugin-windows.zip

- name: Archive production artifacts from Ubuntu
- name: Archive production artifacts from Ubuntu x64
if: ${{ Contains(matrix.os, 'ubuntu') }}
uses: actions/upload-artifact@v4
with:
name: nx-lyve-cloud-plugin-${{ matrix.os }}_x64
path: nx-lyve-cloud-plugin-${{ matrix.os }}_x64.zip
if-no-files-found: error

- name: Archive production artifacts from Ubuntu arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
uses: actions/upload-artifact@v4
with:
name: nx-lyve-cloud-plugin-${{ matrix.os }}
path: nx-lyve-cloud-plugin-${{ matrix.os }}.zip
name: nx-lyve-cloud-plugin-${{ matrix.os }}_arm64
path: nx-lyve-cloud-plugin-${{ matrix.os }}_arm64.zip
if-no-files-found: error

- name: Archive production artifacts from Windows
Expand All @@ -94,7 +132,10 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: |
nx-lyve-cloud-plugin-ubuntu-24.04/*
nx-lyve-cloud-plugin-ubuntu-22.04/*
nx-lyve-cloud-plugin-ubuntu-20.04/*
nx-lyve-cloud-plugin-ubuntu-24.04_x64/*
nx-lyve-cloud-plugin-ubuntu-22.04_x64/*
nx-lyve-cloud-plugin-ubuntu-20.04_x64/*
nx-lyve-cloud-plugin-ubuntu-24.04_arm64/*
nx-lyve-cloud-plugin-ubuntu-22.04_arm64/*
nx-lyve-cloud-plugin-ubuntu-20.04_arm64/*
nx-lyve-cloud-plugin-windows/*
3 changes: 2 additions & 1 deletion build_samples_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ set -x #< Log each command.

"$BASE_DIR"/build_samples.sh \
--no-tests \
-DCMAKE_TOOLCHAIN_FILE=$BASE_DIR/toolchain_arm64.cmake \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-linux \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_arm64.cmake" \
"$@"
17 changes: 17 additions & 0 deletions build_samples_x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

## Copyright © 2024 Seagate Technology LLC and/or its Affiliates
## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/

set -e #< Exit on error.
set -u #< Prohibit undefined variables.

BASE_DIR=$(readlink -f "$(dirname "$0")") #< Absolute path to the current dir.

set -x #< Log each command.

"$BASE_DIR"/build_samples.sh \
--no-tests \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_x64.cmake" \
"$@"
16 changes: 14 additions & 2 deletions toolchain_arm64.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
## Copyright © 2024 Seagate Technology LLC and/or its Affiliates
## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/

set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
# Clang supports cross compiling, but needs to specify the target to compile to
if(CMAKE_C_COMPILER MATCHES "clang")
set(CMAKE_C_FLAGS "--target=aarch64-linux-gnu")
set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnu")
endif()

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)

set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

# This is required by FindThreads CMake module.
set(THREADS_PTHREAD_ARG "2" CACHE STRING "" FORCE)
Expand Down
10 changes: 10 additions & 0 deletions toolchain_x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Copyright © 2024 Seagate Technology LLC and/or its Affiliates
## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR AMD64)

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
Loading