From 357a8092512db4998dc063b452fc8f8ffc894e50 Mon Sep 17 00:00:00 2001 From: Phoebe Chen Date: Sat, 23 Dec 2023 23:48:17 -0800 Subject: [PATCH] Replace riscv64 vector GCC CI with clang toolchain. Signed-off-by: Phoebe Chen --- .github/workflows/build.yml | 4 ++-- CMakeLists.txt | 5 +++++ cmake/riscv64.toolchain | 7 +++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca53b74f0dad..9059562efab0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,7 +85,7 @@ jobs: - name: Run tests run: ctest --output-on-failure --parallel $(nproc) working-directory: ${{ github.workspace }}/build/linux/riscv64 - cmake-linux-riscv64-rvv: + cmake-linux-riscv64-vector: runs-on: ubuntu-22.04 timeout-minutes: 120 steps: @@ -101,7 +101,7 @@ jobs: run: tar zxvf riscv64-glibc-ubuntu-22.04-llvm-nightly-2023.11.20-nightly.tar.gz working-directory: ${{ github.workspace }} - name: Configure and build - run: scripts/build-linux-riscv64.sh -DCMAKE_BUILD_TYPE=Release -DXNNPACK_ENABLE_RISCV_VECTOR=ON -DRISCV_TOOLCHAIN_ROOT=${{ github.workspace }}/riscv/ -DRISCV_QEMU_ROOT=${{ github.workspace }}/riscv/ + run: scripts/build-linux-riscv64.sh -DCMAKE_BUILD_TYPE=Release -DXNNPACK_ENABLE_RISCV_VECTOR=ON -DUSE_GNU_SOURCE=ON -DRISCV_TOOLCHAIN_ROOT=${{ github.workspace }}/riscv/ -DRISCV_QEMU_ROOT=${{ github.workspace }}/riscv/ working-directory: ${{ github.workspace }} - name: Run tests run: ctest --output-on-failure --parallel $(nproc) diff --git a/CMakeLists.txt b/CMakeLists.txt index 461c8eef6030..8b30b80e4a79 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,8 @@ OPTION(XNNPACK_BUILD_LIBRARY "Build XNNPACK library" ON) OPTION(XNNPACK_BUILD_TESTS "Build XNNPACK unit tests" ON) OPTION(XNNPACK_BUILD_BENCHMARKS "Build XNNPACK benchmarks" ON) OPTION(XNNPACK_USE_SYSTEM_LIBS "Use system-provided dependency libraries" OFF) +OPTION(USE_GNU_SOURCE "Use _GNU_SOURCE macro" OFF) + # --- [ Determine target processor IF(CMAKE_OSX_ARCHITECTURES) @@ -118,6 +120,9 @@ ADD_COMPILE_DEFINITIONS("XNN_ENABLE_DWCONV_MULTIPASS=$") ENDIF() +IF(USE_GNU_SOURCE) + ADD_COMPILE_DEFINITIONS(_GNU_SOURCE) +ENDIF() IF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # Disable "unary minus operator applied to unsigned type, result still unsigned" warning diff --git a/cmake/riscv64.toolchain b/cmake/riscv64.toolchain index 32d33de5725d..664f86724b65 100644 --- a/cmake/riscv64.toolchain +++ b/cmake/riscv64.toolchain @@ -22,10 +22,9 @@ IF(NOT RISCV_TOOLCHAIN_ROOT) SET(CMAKE_PROGRAM_PATH "/usr/bin/riscv64-linux-gnu") ELSE() MESSAGE(STATUS "RISCV_TOOLCHAIN_ROOT=${RISCV_TOOLCHAIN_ROOT} is defined during compilation.") - SET(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-gcc") - SET(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-gcc") - SET(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-g++") - + SET(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-clang") + SET(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-clang") + SET(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-clang++") SET(CMAKE_FIND_ROOT_PATH "${RISCV_TOOLCHAIN_ROOT}/sysroot/") SET(CMAKE_INCLUDE_PATH "${RISCV_TOOLCHAIN_ROOT}/sysroot/usr/include/") SET(CMAKE_LIBRARY_PATH "${RISCV_TOOLCHAIN_ROOT}/sysroot/usr/lib/")