From b437b3070486be6e1ac63393c7ade4bc5f7c8a6d Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 11:34:49 -0300
Subject: [PATCH 01/22] Add build-linux-cross to CI

---
 .github/workflows/build-linux-cross.yml | 53 +++++++++++++++++++++++++
 .github/workflows/build.yml             |  5 ++-
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 .github/workflows/build-linux-cross.yml

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
new file mode 100644
index 000000000000..03c9ceb24f73
--- /dev/null
+++ b/.github/workflows/build-linux-cross.yml
@@ -0,0 +1,53 @@
+name: Build on Linux using cross-compiler
+on:
+  workflow_dispatch:
+  workflow_call:
+
+jobs:
+  ubuntu-22-riscv64-vulkan-cross:
+    runs-on: ubuntu-22.04
+
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Setup Riscv
+        run: |
+          sudo dpkg --add-architecture riscv64
+          sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
+                 /etc/apt/sources.list /etc/apt/apt-mirrors.txt
+          sudo apt-get clean
+          sudo apt-get update
+          sudo apt-get install -y --no-install-recommends \
+                  build-essential \
+                  crossbuild-essential-riscv64 \
+                  libvulkan-dev:riscv64
+
+      - name: Setup Vulkan SDK
+        run: |
+          wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
+          sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
+                        https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
+          sudo apt-get update -y
+          sudo apt-get install -y vulkan-sdk
+
+      - name: Build
+        run: |
+          cmake -B build -DCMAKE_BUILD_TYPE=Release \
+                         -DGGML_VULKAN=ON \
+                         -DGGML_OPENMP=OFF \
+                         -DLLAMA_BUILD_EXAMPLES=ON \
+                         -DLLAMA_BUILD_TESTS=OFF \
+                         -DCMAKE_SYSTEM_NAME=Linux \
+                         -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
+                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc \
+                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ \
+                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
+
+          cmake --build build --config Release -j $(nproc)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 03cde0a48436..03cb6f93fbf2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,7 +10,7 @@ on:
   push:
     branches:
       - master
-    paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
+    paths: ['.github/workflows/build.yml', '.github/workflows/build-linux-cross.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
   pull_request:
     types: [opened, synchronize, reopened]
     paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
@@ -606,6 +606,9 @@ jobs:
             -DGGML_SYCL_F16=ON
           cmake --build build --config Release -j $(nproc)
 
+  build-linux-cross:
+    uses: ./.github/workflows/build-linux-cross.yml
+
   macOS-latest-cmake-ios:
     runs-on: macos-latest
 

From 6a447e15a8e0f50c02f105017122f0ecea845693 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 11:50:49 -0300
Subject: [PATCH 02/22] Install mesa drivers before vulkan sdk

---
 .github/workflows/build-linux-cross.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 03c9ceb24f73..0d446de8e8bb 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -30,7 +30,7 @@ jobs:
           sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
                         https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
           sudo apt-get update -y
-          sudo apt-get install -y vulkan-sdk
+          sudo apt-get install -y mesa-vulkan-drivers vulkan-sdk
 
       - name: Build
         run: |

From ddd7b2fbf8d21ff1a0fcc42b41b862235981a2ae Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 12:04:18 -0300
Subject: [PATCH 03/22] Install vulkan drivers before vulkan sdk

---
 .github/workflows/build-linux-cross.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 0d446de8e8bb..38a167fa80c4 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -22,6 +22,7 @@ jobs:
           sudo apt-get install -y --no-install-recommends \
                   build-essential \
                   crossbuild-essential-riscv64 \
+                  mesa-vulkan-drivers \
                   libvulkan-dev:riscv64
 
       - name: Setup Vulkan SDK
@@ -30,7 +31,7 @@ jobs:
           sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
                         https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
           sudo apt-get update -y
-          sudo apt-get install -y mesa-vulkan-drivers vulkan-sdk
+          sudo apt-get install -y vulkan-sdk
 
       - name: Build
         run: |

From d14edbb64f69d4884ea6cb1391ff07edf08dda75 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 12:14:35 -0300
Subject: [PATCH 04/22] Only install glslang-tools (not full vulkan sdk)

---
 .github/workflows/build-linux-cross.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 38a167fa80c4..22755a803f8f 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -22,7 +22,6 @@ jobs:
           sudo apt-get install -y --no-install-recommends \
                   build-essential \
                   crossbuild-essential-riscv64 \
-                  mesa-vulkan-drivers \
                   libvulkan-dev:riscv64
 
       - name: Setup Vulkan SDK
@@ -31,7 +30,7 @@ jobs:
           sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
                         https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
           sudo apt-get update -y
-          sudo apt-get install -y vulkan-sdk
+          sudo apt-get install -y glslang-tools
 
       - name: Build
         run: |

From 10edb6e098d4039a7ee8cc83c70f45919b95ca53 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 13:01:41 -0300
Subject: [PATCH 05/22] Search for GLSLC program outside find-root-path

---
 ggml/src/ggml-vulkan/CMakeLists.txt | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt
index d970f7e20b46..c29d950c30e3 100644
--- a/ggml/src/ggml-vulkan/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.19)
 cmake_policy(SET CMP0114 NEW)
 
-find_package(Vulkan COMPONENTS glslc REQUIRED)
+find_package(Vulkan COMPONENTS glslc)
 
 function(detect_host_compiler)
     if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
@@ -18,6 +18,15 @@ endfunction()
 if (Vulkan_FOUND)
     message(STATUS "Vulkan found")
 
+    set (GLSLC_PROGRAM ${Vulkan_GLSLC_EXECUTABLE})
+    if (NOT GLSLC_PROGRAM)
+        # When cross-compiling the glslc program needs to be runnable on
+        # build-system architecture but the Vulkan SDK will be for the
+        # target architecture.
+
+        find_program(GLSLC_PROGRAM glslc REQUIRED NO_CMAKE_FIND_ROOT_PATH)
+    endif()
+
     ggml_add_backend_library(ggml-vulkan
                              ggml-vulkan.cpp
                              ../../include/ggml-vulkan.h
@@ -26,7 +35,7 @@ if (Vulkan_FOUND)
     # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
-    execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat_support.comp"
+    execute_process(COMMAND ${GLSLC_PROGRAM} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat_support.comp"
                     OUTPUT_VARIABLE glslc_output
                     ERROR_VARIABLE glslc_error)
 
@@ -40,7 +49,7 @@ if (Vulkan_FOUND)
     # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
-    execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat2_support.comp"
+    execute_process(COMMAND ${GLSLC_PROGRAM} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat2_support.comp"
                     OUTPUT_VARIABLE glslc_output
                     ERROR_VARIABLE glslc_error)
 
@@ -144,7 +153,7 @@ if (Vulkan_FOUND)
                 ${_ggml_vk_source}
 
         COMMAND ${_ggml_vk_genshaders_cmd}
-            --glslc      ${Vulkan_GLSLC_EXECUTABLE}
+            --glslc      ${GLSLC_PROGRAM}
             --input-dir  ${_ggml_vk_input_dir}
             --output-dir ${_ggml_vk_output_dir}
             --target-hpp ${_ggml_vk_header}

From ce5285aee028299091002fbae5c65bd07bcdddaf Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 16:02:17 -0300
Subject: [PATCH 06/22] Do not specify Vulkan components

---
 ggml/src/ggml-vulkan/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt
index c29d950c30e3..af02b275fc65 100644
--- a/ggml/src/ggml-vulkan/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.19)
 cmake_policy(SET CMP0114 NEW)
 
-find_package(Vulkan COMPONENTS glslc)
+find_package(Vulkan)
 
 function(detect_host_compiler)
     if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
@@ -21,7 +21,7 @@ if (Vulkan_FOUND)
     set (GLSLC_PROGRAM ${Vulkan_GLSLC_EXECUTABLE})
     if (NOT GLSLC_PROGRAM)
         # When cross-compiling the glslc program needs to be runnable on
-        # build-system architecture but the Vulkan SDK will be for the
+        # the build-system architecture but the Vulkan SDK will be for the
         # target architecture.
 
         find_program(GLSLC_PROGRAM glslc REQUIRED NO_CMAKE_FIND_ROOT_PATH)

From ce6e54964a3650edab6c057b3145b9c01bf26e76 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 16:08:40 -0300
Subject: [PATCH 07/22] Install shaderc

---
 .github/workflows/build-linux-cross.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 22755a803f8f..a2b761eaa7c0 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -30,7 +30,7 @@ jobs:
           sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
                         https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
           sudo apt-get update -y
-          sudo apt-get install -y glslang-tools
+          sudo apt-get install -y shaderc
 
       - name: Build
         run: |

From b52bb4d8a358fa653567ce3283ca92c941546981 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 16:18:19 -0300
Subject: [PATCH 08/22] Set project name for vulkan-shaders-gen

---
 ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
index 51c78b7d2293..09a1b70759b1 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
@@ -1,5 +1,5 @@
-find_package (Threads REQUIRED)
-
+project(vulkan-shaders-gen)
+find_package(Threads REQUIRED)
 set(TARGET vulkan-shaders-gen)
 add_executable(${TARGET} vulkan-shaders-gen.cpp)
 install(TARGETS ${TARGET} RUNTIME)

From 829bca01b27f63eb0ca267b7c7a81af668fa31cc Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 16:23:34 -0300
Subject: [PATCH 09/22] Set minimum cmake project ver.

---
 ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
index 09a1b70759b1..1262701f1e92 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
@@ -1,3 +1,4 @@
+cmake_minimum_required(VERSION 3.14) # Match top-level project
 project(vulkan-shaders-gen)
 find_package(Threads REQUIRED)
 set(TARGET vulkan-shaders-gen)

From d2ac20413c7bc48dade90eed27a2fd7b2c01490d Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 16:54:17 -0300
Subject: [PATCH 10/22] Use ubuntu latest

---
 .github/workflows/build-linux-cross.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index a2b761eaa7c0..6f93647b87e6 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -4,8 +4,8 @@ on:
   workflow_call:
 
 jobs:
-  ubuntu-22-riscv64-vulkan-cross:
-    runs-on: ubuntu-22.04
+  ubuntu-latest-riscv64-vulkan-cross:
+    runs-on: ubuntu-latest
 
     steps:
       - uses: actions/checkout@v4

From d8d3ba5e6726442540fecc34c3815f57cbd941f5 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 17:30:05 -0300
Subject: [PATCH 11/22] Add cpu-only build

---
 .github/workflows/build-linux-cross.yml | 35 +++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 6f93647b87e6..58a0237249ec 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -4,6 +4,41 @@ on:
   workflow_call:
 
 jobs:
+  ubuntu-latest-riscv64-cpu-cross:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Setup Riscv
+        run: |
+          sudo dpkg --add-architecture riscv64
+          sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
+                 /etc/apt/sources.list /etc/apt/apt-mirrors.txt
+          sudo apt-get clean
+          sudo apt-get update
+          sudo apt-get install -y --no-install-recommends \
+                  build-essential \
+                  crossbuild-essential-riscv64
+
+      - name: Build
+        run: |
+          cmake -B build -DCMAKE_BUILD_TYPE=Release \
+                         -DGGML_OPENMP=OFF \
+                         -DLLAMA_BUILD_EXAMPLES=ON \
+                         -DLLAMA_BUILD_TESTS=OFF \
+                         -DCMAKE_SYSTEM_NAME=Linux \
+                         -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
+                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc \
+                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ \
+                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
+
+          cmake --build build --config Release -j $(nproc)
+
   ubuntu-latest-riscv64-vulkan-cross:
     runs-on: ubuntu-latest
 

From 7e276bceca0917069636c42b59d4b2b5aad68eca Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 17:50:57 -0300
Subject: [PATCH 12/22] Use Noble glslc instead of LunarG

---
 .github/workflows/build-linux-cross.yml | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 58a0237249ec..abf7e86950ea 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -56,17 +56,10 @@ jobs:
           sudo apt-get update
           sudo apt-get install -y --no-install-recommends \
                   build-essential \
+                  glslc \
                   crossbuild-essential-riscv64 \
                   libvulkan-dev:riscv64
 
-      - name: Setup Vulkan SDK
-        run: |
-          wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
-          sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list \
-                        https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
-          sudo apt-get update -y
-          sudo apt-get install -y shaderc
-
       - name: Build
         run: |
           cmake -B build -DCMAKE_BUILD_TYPE=Release \

From ef7376e30de8f6ba445ce239537478579888bab7 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 17 Mar 2025 18:03:20 -0300
Subject: [PATCH 13/22] Revert change to ggml/src/ggml-vulkan/CMakeLists.txt

---
 ggml/src/ggml-vulkan/CMakeLists.txt | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt
index af02b275fc65..d970f7e20b46 100644
--- a/ggml/src/ggml-vulkan/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.19)
 cmake_policy(SET CMP0114 NEW)
 
-find_package(Vulkan)
+find_package(Vulkan COMPONENTS glslc REQUIRED)
 
 function(detect_host_compiler)
     if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
@@ -18,15 +18,6 @@ endfunction()
 if (Vulkan_FOUND)
     message(STATUS "Vulkan found")
 
-    set (GLSLC_PROGRAM ${Vulkan_GLSLC_EXECUTABLE})
-    if (NOT GLSLC_PROGRAM)
-        # When cross-compiling the glslc program needs to be runnable on
-        # the build-system architecture but the Vulkan SDK will be for the
-        # target architecture.
-
-        find_program(GLSLC_PROGRAM glslc REQUIRED NO_CMAKE_FIND_ROOT_PATH)
-    endif()
-
     ggml_add_backend_library(ggml-vulkan
                              ggml-vulkan.cpp
                              ../../include/ggml-vulkan.h
@@ -35,7 +26,7 @@ if (Vulkan_FOUND)
     # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
-    execute_process(COMMAND ${GLSLC_PROGRAM} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat_support.comp"
+    execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat_support.comp"
                     OUTPUT_VARIABLE glslc_output
                     ERROR_VARIABLE glslc_error)
 
@@ -49,7 +40,7 @@ if (Vulkan_FOUND)
     # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
-    execute_process(COMMAND ${GLSLC_PROGRAM} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat2_support.comp"
+    execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat2_support.comp"
                     OUTPUT_VARIABLE glslc_output
                     ERROR_VARIABLE glslc_error)
 
@@ -153,7 +144,7 @@ if (Vulkan_FOUND)
                 ${_ggml_vk_source}
 
         COMMAND ${_ggml_vk_genshaders_cmd}
-            --glslc      ${GLSLC_PROGRAM}
+            --glslc      ${Vulkan_GLSLC_EXECUTABLE}
             --input-dir  ${_ggml_vk_input_dir}
             --output-dir ${_ggml_vk_output_dir}
             --target-hpp ${_ggml_vk_header}

From 2ec6ef037d240ada6a1fc6ff580fb50555941de8 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Thu, 27 Mar 2025 10:37:08 -0300
Subject: [PATCH 14/22] Temp. applied patch from #12272 to test compile fix

---
 ggml/src/ggml-vulkan/CMakeLists.txt                | 8 ++++++++
 ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt
index d970f7e20b46..08be3f051b2c 100644
--- a/ggml/src/ggml-vulkan/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/CMakeLists.txt
@@ -23,6 +23,8 @@ if (Vulkan_FOUND)
                              ../../include/ggml-vulkan.h
                             )
 
+    set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF)
+
     # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
@@ -35,8 +37,11 @@ if (Vulkan_FOUND)
     else()
         message(STATUS "GL_KHR_cooperative_matrix supported by glslc")
         add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
+        set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON)
     endif()
 
+    set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF)
+
     # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
@@ -49,6 +54,7 @@ if (Vulkan_FOUND)
     else()
         message(STATUS "GL_NV_cooperative_matrix2 supported by glslc")
         add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
+        set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON)
     endif()
 
     target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
@@ -119,6 +125,8 @@ if (Vulkan_FOUND)
             SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
             CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
                     -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
+                    -DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT_GLSLC_SUPPORT}
+                    -DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT}
             BUILD_COMMAND ${CMAKE_COMMAND} --build .
             INSTALL_COMMAND ${CMAKE_COMMAND} --install .
             INSTALL_DIR ${CMAKE_BINARY_DIR}
diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
index 1262701f1e92..20817d7d9a77 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
@@ -1,6 +1,12 @@
 cmake_minimum_required(VERSION 3.14) # Match top-level project
 project(vulkan-shaders-gen)
 find_package(Threads REQUIRED)
+if (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
+	add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
+endif()
+if (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
+	add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
+endif()
 set(TARGET vulkan-shaders-gen)
 add_executable(${TARGET} vulkan-shaders-gen.cpp)
 install(TARGETS ${TARGET} RUNTIME)

From bb935314b0d27c8072c752146be08a4adecdb3e6 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Thu, 27 Mar 2025 11:05:58 -0300
Subject: [PATCH 15/22] Fix indent

---
 ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
index 20817d7d9a77..b71cd39c6f9e 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.14) # Match top-level project
 project(vulkan-shaders-gen)
 find_package(Threads REQUIRED)
 if (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
-	add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
+        add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
 endif()
 if (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
-	add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
+        add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
 endif()
 set(TARGET vulkan-shaders-gen)
 add_executable(${TARGET} vulkan-shaders-gen.cpp)

From 16aef52977b670f0236c32bcd31e7c7f90ab453c Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Thu, 27 Mar 2025 15:19:34 -0300
Subject: [PATCH 16/22] Add arm64 build

---
 .github/workflows/build-linux-cross.yml | 43 +++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index abf7e86950ea..431a52826bbd 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -6,6 +6,7 @@ on:
 jobs:
   ubuntu-latest-riscv64-cpu-cross:
     runs-on: ubuntu-latest
+    if: ${{ false }}  # todo: re-enable this when riscv compile error fixed
 
     steps:
       - uses: actions/checkout@v4
@@ -41,6 +42,7 @@ jobs:
 
   ubuntu-latest-riscv64-vulkan-cross:
     runs-on: ubuntu-latest
+    if: ${{ false }}  # todo: re-enable this when riscv compile error fixed
 
     steps:
       - uses: actions/checkout@v4
@@ -79,3 +81,44 @@ jobs:
                          -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
 
           cmake --build build --config Release -j $(nproc)
+
+  ubuntu-latest-arm64-vulkan-cross:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Setup Arm64
+        run: |
+          sudo dpkg --add-architecture arm64
+          sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
+                 /etc/apt/sources.list /etc/apt/apt-mirrors.txt
+          sudo apt-get clean
+          sudo apt-get update
+          sudo apt-get install -y --no-install-recommends \
+                  build-essential \
+                  glslc \
+                  crossbuild-essential-arm64 \
+                  libvulkan-dev:arm64
+
+      - name: Build
+        run: |
+          cmake -B build -DCMAKE_BUILD_TYPE=Release \
+                         -DGGML_VULKAN=ON \
+                         -DGGML_OPENMP=OFF \
+                         -DLLAMA_BUILD_EXAMPLES=ON \
+                         -DLLAMA_BUILD_TESTS=OFF \
+                         -DCMAKE_SYSTEM_NAME=Linux \
+                         -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
+                         -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
+                         -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
+                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_FIND_ROOT_PATH=/usr/lib/aarch64-linux-gnu \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
+
+          cmake --build build --config Release -j $(nproc)

From ee518582454de70258e01d1b27d8a3cf26f7e7c4 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Fri, 28 Mar 2025 16:41:38 -0300
Subject: [PATCH 17/22] Revert temp. applied patch from #12272 to test compile
 fix

---
 ggml/src/ggml-vulkan/CMakeLists.txt                |  8 --------
 ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt | 11 ++---------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt
index 08be3f051b2c..d970f7e20b46 100644
--- a/ggml/src/ggml-vulkan/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/CMakeLists.txt
@@ -23,8 +23,6 @@ if (Vulkan_FOUND)
                              ../../include/ggml-vulkan.h
                             )
 
-    set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF)
-
     # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
@@ -37,11 +35,8 @@ if (Vulkan_FOUND)
     else()
         message(STATUS "GL_KHR_cooperative_matrix supported by glslc")
         add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
-        set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON)
     endif()
 
-    set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF)
-
     # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
     # If it's not, there will be an error to stderr.
     # If it's supported, set a define to indicate that we should compile those shaders
@@ -54,7 +49,6 @@ if (Vulkan_FOUND)
     else()
         message(STATUS "GL_NV_cooperative_matrix2 supported by glslc")
         add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
-        set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON)
     endif()
 
     target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
@@ -125,8 +119,6 @@ if (Vulkan_FOUND)
             SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
             CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
                     -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-                    -DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT_GLSLC_SUPPORT}
-                    -DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT}
             BUILD_COMMAND ${CMAKE_COMMAND} --build .
             INSTALL_COMMAND ${CMAKE_COMMAND} --install .
             INSTALL_DIR ${CMAKE_BINARY_DIR}
diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
index b71cd39c6f9e..51c78b7d2293 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
@@ -1,12 +1,5 @@
-cmake_minimum_required(VERSION 3.14) # Match top-level project
-project(vulkan-shaders-gen)
-find_package(Threads REQUIRED)
-if (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
-        add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
-endif()
-if (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
-        add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
-endif()
+find_package (Threads REQUIRED)
+
 set(TARGET vulkan-shaders-gen)
 add_executable(${TARGET} vulkan-shaders-gen.cpp)
 install(TARGETS ${TARGET} RUNTIME)

From 5ad6133cbb2e640378b489832942b94fc76a6fa7 Mon Sep 17 00:00:00 2001
From: Mason M <mason@bandoti.com>
Date: Mon, 31 Mar 2025 15:29:08 -0300
Subject: [PATCH 18/22] Re-Activate RISCV builds

---
 .github/workflows/build-linux-cross.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 431a52826bbd..22f71b3bff8f 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -6,7 +6,6 @@ on:
 jobs:
   ubuntu-latest-riscv64-cpu-cross:
     runs-on: ubuntu-latest
-    if: ${{ false }}  # todo: re-enable this when riscv compile error fixed
 
     steps:
       - uses: actions/checkout@v4
@@ -42,7 +41,6 @@ jobs:
 
   ubuntu-latest-riscv64-vulkan-cross:
     runs-on: ubuntu-latest
-    if: ${{ false }}  # todo: re-enable this when riscv compile error fixed
 
     steps:
       - uses: actions/checkout@v4

From 610dda15cf878eb519b8fc4ff7560c07c6d0dfd6 Mon Sep 17 00:00:00 2001
From: bandoti <141645996+bandoti@users.noreply.github.com>
Date: Thu, 3 Apr 2025 13:54:33 -0300
Subject: [PATCH 19/22] Use gcc/g++ 14 instead of default in
 crossbuild-essentials

---
 .github/workflows/build-linux-cross.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 22f71b3bff8f..a60614f43f4b 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -57,7 +57,8 @@ jobs:
           sudo apt-get install -y --no-install-recommends \
                   build-essential \
                   glslc \
-                  crossbuild-essential-riscv64 \
+                  gcc-14-riscv64-linux-gnu \
+                  g++-14-riscv64-linux-gnu \
                   libvulkan-dev:riscv64
 
       - name: Build
@@ -69,8 +70,8 @@ jobs:
                          -DLLAMA_BUILD_TESTS=OFF \
                          -DCMAKE_SYSTEM_NAME=Linux \
                          -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
-                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc \
-                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ \
+                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
+                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
                          -DCMAKE_C_FLAGS_INIT='-fPIC' \
                          -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
                          -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \

From ed65c64bfa908116fb2803e2c4340921dc322d09 Mon Sep 17 00:00:00 2001
From: bandoti <141645996+bandoti@users.noreply.github.com>
Date: Thu, 3 Apr 2025 14:05:10 -0300
Subject: [PATCH 20/22] Use gcc/g++ 14 instead of crossbuild-essential

---
 .github/workflows/build-linux-cross.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index a60614f43f4b..51a7226a0c9b 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -18,7 +18,8 @@ jobs:
           sudo apt-get update
           sudo apt-get install -y --no-install-recommends \
                   build-essential \
-                  crossbuild-essential-riscv64
+                  gcc-14-riscv64-linux-gnu \
+                  g++-14-riscv64-linux-gnu
 
       - name: Build
         run: |

From 67dde0b422da696070518f79cdd80d4a283333db Mon Sep 17 00:00:00 2001
From: bandoti <141645996+bandoti@users.noreply.github.com>
Date: Thu, 3 Apr 2025 14:08:27 -0300
Subject: [PATCH 21/22] Update build-linux-cross.yml

---
 .github/workflows/build-linux-cross.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index 51a7226a0c9b..f9b05df3be01 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -29,8 +29,8 @@ jobs:
                          -DLLAMA_BUILD_TESTS=OFF \
                          -DCMAKE_SYSTEM_NAME=Linux \
                          -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
-                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc \
-                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ \
+                         -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
+                         -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
                          -DCMAKE_C_FLAGS_INIT='-fPIC' \
                          -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
                          -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \

From 78fa6a552b6bcf65f1fd48e90803a856145e2154 Mon Sep 17 00:00:00 2001
From: bandoti <141645996+bandoti@users.noreply.github.com>
Date: Thu, 3 Apr 2025 16:03:52 -0300
Subject: [PATCH 22/22] Use cmake switch for position-independent code

---
 .github/workflows/build-linux-cross.yml | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build-linux-cross.yml b/.github/workflows/build-linux-cross.yml
index f9b05df3be01..d4176fef9cee 100644
--- a/.github/workflows/build-linux-cross.yml
+++ b/.github/workflows/build-linux-cross.yml
@@ -31,8 +31,7 @@ jobs:
                          -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
                          -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
                          -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
-                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
-                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
                          -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
                          -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
                          -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
@@ -73,8 +72,7 @@ jobs:
                          -DCMAKE_SYSTEM_PROCESSOR=riscv64 \
                          -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
                          -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
-                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
-                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
                          -DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
                          -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
                          -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
@@ -114,8 +112,7 @@ jobs:
                          -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
                          -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
                          -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-                         -DCMAKE_C_FLAGS_INIT='-fPIC' \
-                         -DCMAKE_CXX_FLAGS_INIT='-fPIC' \
+                         -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
                          -DCMAKE_FIND_ROOT_PATH=/usr/lib/aarch64-linux-gnu \
                          -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
                          -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
