Skip to content

Commit

Permalink
github actions: do not build libclc manually for android (#741)
Browse files Browse the repository at this point in the history
* github actions: do not build libclc manually for android

* Free up more space

Change-Id: Id187afef6b9256a2bb741fda41ecf6ec5007d8e9

* update README.md

---------

Co-authored-by: Kévin Petit <[email protected]>
  • Loading branch information
rjodinchr and kpet authored Nov 30, 2024
1 parent 8efb406 commit 6df2be1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
- name: Setup Ninja
uses: ./.github/actions/setup-ninja
Expand Down Expand Up @@ -109,29 +110,10 @@ jobs:
with:
version: 1.3.250.1
rt-dir: ${{ github.workspace }}/vulkanrt
- name: Build libclc
if: ${{ matrix.android-abi != '' }}
env:
LLVM_NATIVE_DIR: ${{ github.workspace }}/build_llvm_native/
LLVM_ARCHIVE_PREFIX: LLVM-19.1.0-rc2-Linux-X64
LIBCLC_DIR: ${{ github.workspace }}/build_libclc
run: |
set -x
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0-rc2/${LLVM_ARCHIVE_PREFIX}.tar.xz
mkdir -p ${LLVM_NATIVE_DIR}
tar -xf ${LLVM_ARCHIVE_PREFIX}.tar.xz -C ${LLVM_NATIVE_DIR}
cmake -S '${{ github.workspace }}/external/clspv/third_party/llvm/libclc' -B ${LIBCLC_DIR} -G Ninja \
-DLLVM_CMAKE_DIR=${LLVM_NATIVE_DIR}/${LLVM_ARCHIVE_PREFIX}/lib/cmake \
-DCMAKE_CXX_COMPILER=${LLVM_NATIVE_DIR}/${LLVM_ARCHIVE_PREFIX}/bin/clang++ \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DLIBCLC_TARGETS_TO_BUILD="clspv--;clspv64--"
cmake --build ${LIBCLC_DIR}
ls -l ${LIBCLC_DIR}
rm -rf ${LLVM_NATIVE_DIR} ${LLVM_ARCHIVE_PREFIX}.tar.xz
- name: Prepare Android CMake arguments
if: ${{ matrix.android-abi != '' }}
run: |
echo "android-cmake-args=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/ndk/android-ndk-r25c/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.android-abi }} -DVulkan_LIBRARY=${{ github.workspace }}/ndk/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/33/libvulkan.so -DCLSPV_EXTERNAL_LIBCLC_DIR=${{ github.workspace }}/build_libclc" >> $GITHUB_ENV
echo "android-cmake-args=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/ndk/android-ndk-r25c/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.android-abi }} -DVulkan_LIBRARY=${{ github.workspace }}/ndk/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/33/libvulkan.so" >> $GITHUB_ENV
- name: Build Perfetto
if: ${{ matrix.perfetto }}
shell: bash
Expand Down Expand Up @@ -170,6 +152,16 @@ jobs:
- name: Build clang
run: cmake --build '${{ env.builddir }}' --config Release --target clang -j2
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
# Our build is complete, we can now delete all the static libraries and
# intermediate objects to free up space.
- name: Free space on the runner
shell: bash
run: |
set -x
df -h
find '${{ env.builddir }}' -name "*.a" -delete
find '${{ env.builddir }}' -name "*.o" -delete
df -h
- name: Install
run: cmake --install '${{ env.builddir }}'
- uses: actions/upload-artifact@v4
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ the build system:
* `CLVK_ENABLE_UBSAN` can be used to enable
[UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html).

## Cross-compiling
## Building libclc manually

When cross-compiling clvk, libclc binaries need to be compiled separately:
When compiling clvk on small machine (such as Raspberry pi) building libclc
manually can help. Here are the few steps to do it:

1. Build a host native clang compiler using the source pointed by clspv in `<clvk>/external/clspv/third_party/llvm`:
```
Expand All @@ -158,7 +159,7 @@ cmake --build <clang_host> --target install
2. Build libclc using that compiler:
```
cmake -B <libclc> -S <clvk>/external/clspv/third_party/llvm/libclc \
-DLLVM_CMAKE_DIR="<clang_host>/install/lib/cmake" \
-DLLVM_CMAKE_DIR="<clang_host>/lib/cmake" \
-DLIBCLC_DIR_TARGETS_TO_BUILD="clspv--;clspv64--"
cmake --build <libclc>
```
Expand Down

0 comments on commit 6df2be1

Please sign in to comment.