Skip to content

Commit

Permalink
[#25] Add a workflow step for Linux cross-compilation (x86_64 -> ARM64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Galarius committed Feb 24, 2024
1 parent e562a76 commit af3e2ee
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 18 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Linux - Install prerequisites
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install gcc-11 g++-11
- name: Create virtual environment
run: python3 -m venv .pyenv

Expand Down
42 changes: 33 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
if: "contains(matrix.config.os, 'ubuntu')"
run: |
sudo apt update
sudo apt install gcc-11 g++-11
sudo apt install gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu
ls /usr/bin/ | grep aarch64
- name: Set up Python
uses: actions/setup-python@v2
Expand Down Expand Up @@ -111,26 +112,46 @@ jobs:
- name: Linux - Configure & Build (Release)
if: "contains(matrix.config.os, 'ubuntu')"
run: |
./build.py conan-install
./build.py configure
./build.py build
./build.py conan-install -o .conan-x86_64 -pr:h profiles/linux.release.x86_64
./build.py configure -t .conan-x86_64/build/Release/generators/conan_toolchain.cmake -b .build-x86_64 -bt Release
./build.py build -b .build-x86_64
file .build-x86_64/opencl-language-server
./build.py conan-install -o .conan-armv8 -pr:h profiles/linux.release.armv8
./build.py configure -t .conan-armv8/build/Release/generators/conan_toolchain.cmake -b .build-armv8 -bt Release
./build.py build -b .build-armv8
file .build-armv8/opencl-language-server
- name: Linux - Archive Artifact
if: "contains(matrix.config.os, 'ubuntu')"
run: |
cd ${{github.workspace}}/.build/
cd ${{github.workspace}}/.build-x86_64/
tar -czvf opencl-language-server-linux-x86_64.tar.gz opencl-language-server
cd ${{github.workspace}}/.build-armv8/
tar -czvf opencl-language-server-linux-arm64.tar.gz opencl-language-server
- name: Linux - Upload Artifact
- name: Linux - Upload Artifact (x86_64)
if: "contains(matrix.config.os, 'ubuntu')"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.create_release.outputs.upload_url}}
asset_path: ${{github.workspace}}/.build/opencl-language-server-linux-x86_64.tar.gz
asset_path: ${{github.workspace}}/.build-x86_64/opencl-language-server-linux-x86_64.tar.gz
asset_name: opencl-language-server-linux-x86_64.tar.gz
asset_content_type: application/gzip

- name: Linux - Upload Artifact (armv8)
if: "contains(matrix.config.os, 'ubuntu')"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.create_release.outputs.upload_url}}
asset_path: ${{github.workspace}}/.build-armv8/opencl-language-server-linux-arm64.tar.gz
asset_name: opencl-language-server-linux-arm64.tar.gz
asset_content_type: application/gzip


- name: Mac - Configure & Build (Release)
Expand All @@ -139,14 +160,17 @@ jobs:
./build.py conan-install -o .conan-x86_64 -pr:h profiles/darwin.release.x86_64
./build.py configure -t .conan-x86_64/build/Release/generators/conan_toolchain.cmake -b .build-x86_64 -bt Release
./build.py build -b .build-x86_64
file .build-x86_64/opencl-language-server
./build.py conan-install -o .conan-armv8 -pr:h profiles/darwin.release.armv8
./build.py configure -t .conan-armv8/build/Release/generators/conan_toolchain.cmake -b .build-armv8 -bt Release
./build.py build -b .build-armv8
file .build-armv8/opencl-language-server
mkdir -p .build-universal/
lipo -create -output .build-universal/opencl-language-server .build-x86_64/opencl-language-server .build-armv8/opencl-language-server
lipo -archs .build-universal/opencl-language-server
file .build-universal/opencl-language-server
- name: Mac - Archive Artifact
if: "contains(matrix.config.os, 'macos')"
Expand Down Expand Up @@ -196,7 +220,7 @@ jobs:
- name: Linux - Archive Licenses
if: "contains(matrix.config.os, 'ubuntu')"
run: |
cd ${{github.workspace}}/.conan-install
cd ${{github.workspace}}/.conan-x86_64
tar -czvf licenses.tar.gz licenses
- name: Linux - Upload Licenses
Expand All @@ -206,6 +230,6 @@ jobs:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.create_release.outputs.upload_url}}
asset_path: ${{github.workspace}}/.conan-install/licenses.tar.gz
asset_path: ${{github.workspace}}/.conan-x86_64/licenses.tar.gz
asset_name: licenses.tar.gz
asset_content_type: application/gzip
15 changes: 14 additions & 1 deletion DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@ xcrun altool --notarization-history 0 --asc-provider ${PROVIDER} --password "@ke
xcrun altool --notarization-info ${REQUEST_ID} --password "@keychain:AC_PASSWORD"
```

### CLI
## Linux

### Cross compilation (x86_64 -> armv8)

```shell
sudo apt install gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu
./build.py conan-install -o .conan-armv8 -pr:h profiles/linux.release.armv8
./build.py configure -t .conan-armv8/build/Release/generators/conan_toolchain.cmake -b .build-armv8 -bt Release
./build.py build -b .build-armv8
```

*ubuntu-20.04, gcc-9*

## CLI

The `opencl-language-server` offers support for file logging, as well as subcommands that allow you to test its functionality without starting the server.

Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OpenCLLanguageServerConanfile(ConanFile):
homepage = "https://github.com/Galarius/opencl-language-server"
topics = ("opencl", "language-server")
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
generators = "CMakeToolchain", "CMakeDeps", "VirtualBuildEnv"
options = {"enable_testing": [True, False]}
default_options = {"enable_testing": False}
requires = (
Expand Down
1 change: 1 addition & 0 deletions libclang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if(DEFINED LLVM_ROOT_DIR AND NOT LLVM_ROOT_DIR STREQUAL "")
# LLVM_ROOT_DIR is already defined
else()
# Download prebuilt static llvm & clang libraries
# TODO: prebuilt libs for Linux ARM are missing
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/libclang-urls.txt libclang_entries)
message(STATUS "Parsing ${CMAKE_CURRENT_SOURCE_DIR}/libclang-urls.txt...")
foreach(entry ${libclang_entries})
Expand Down
2 changes: 1 addition & 1 deletion profiles/linux.common
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[settings]
compiler=gcc
compiler.version=11
compiler.version=9
compiler.libcxx=libstdc++11
compiler.cppstd = gnu17
os=Linux
9 changes: 9 additions & 0 deletions profiles/linux.common.armv8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Common settings (Linux)

[buildenv]
CC=/usr/bin/aarch64-linux-gnu-gcc-9
CXX=/usr/bin/aarch64-linux-gnu-g++-9
LD=/usr/bin/aarch64-linux-gnu-ld

[conf]
tools.build:compiler_executables={"c": "/usr/bin/aarch64-linux-gnu-gcc-9", "cpp": "/usr/bin/aarch64-linux-gnu-g++-9"}
6 changes: 6 additions & 0 deletions profiles/linux.debug.armv8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include(linux.common)
include(linux.common.armv8)

[settings]
arch=armv8
build_type=Debug
6 changes: 6 additions & 0 deletions profiles/linux.release.armv8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include(linux.common)
include(linux.common.armv8)

[settings]
arch=armv8
build_type=Release

0 comments on commit af3e2ee

Please sign in to comment.