mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
[RISC-V] Support CMake build with custom compiler flags
This CL aims to support custom compiler flags. Because upstream clang has supported to build for x280 with -mcpu=sifive-x280. Change-Id: Ic8fbf026fe6805ac5c3422a9ccc3f53293c89570 Signed-off-by: Bruce Lai <bruce.lai@sifive.com> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4713191 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
parent
423e2b97ea
commit
b76fcd4654
@ -238,6 +238,18 @@ After running script, clang & qemu are built in `build-toolchain-qemu/riscv-clan
|
|||||||
-DUSE_RVV=ON .
|
-DUSE_RVV=ON .
|
||||||
cmake --build out/Release/
|
cmake --build out/Release/
|
||||||
|
|
||||||
|
#### Customized Compiler Flags
|
||||||
|
|
||||||
|
Customized compiler flags are supported by `-DRISCV_COMPILER_FLAGS="xxx"`.
|
||||||
|
If `-DRISCV_COMPILER_FLAGS="xxx"` is manually assigned, other compile flags(e.g disable -march=xxx) will not be appended.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
cmake -B out/Release/ -DUNIT_TEST=ON \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="./riscv_script/riscv-clang.cmake" \
|
||||||
|
-DRISCV_COMPILER_FLAGS="-mcpu=sifive-x280" \
|
||||||
|
.
|
||||||
|
|
||||||
### Run on QEMU
|
### Run on QEMU
|
||||||
|
|
||||||
|
|||||||
@ -28,17 +28,20 @@ set(CMAKE_OBJDUMP "${TOOLCHAIN_PATH}/bin/llvm-objdump")
|
|||||||
set(CMAKE_OBJCOPY "${TOOLCHAIN_PATH}/bin/llvm-objcopy")
|
set(CMAKE_OBJCOPY "${TOOLCHAIN_PATH}/bin/llvm-objcopy")
|
||||||
|
|
||||||
# compile options
|
# compile options
|
||||||
message(STATUS "USE_RVV: ${USE_RVV}")
|
set(RISCV_COMPILER_FLAGS "" CACHE STRING "Compile flags")
|
||||||
message(STATUS "USE_AUTO_VECTORIZER: ${USE_AUTO_VECTORIZER}")
|
# if user provides RISCV_COMPILER_FLAGS, appeding compile flags is avoided.
|
||||||
set(RISCV_COMPILER_FLAGS)
|
if(RISCV_COMPILER_FLAGS STREQUAL "")
|
||||||
if(USE_RVV)
|
message(STATUS "USE_RVV: ${USE_RVV}")
|
||||||
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gcv")
|
message(STATUS "USE_AUTO_VECTORIZER: ${USE_AUTO_VECTORIZER}")
|
||||||
if(NOT USE_AUTO_VECTORIZER)
|
if(USE_RVV)
|
||||||
# Disable auto-vectorizer
|
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gcv")
|
||||||
add_compile_options(-fno-vectorize -fno-slp-vectorize)
|
if(NOT USE_AUTO_VECTORIZER)
|
||||||
|
# Disable auto-vectorizer
|
||||||
|
add_compile_options(-fno-vectorize -fno-slp-vectorize)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gc")
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gc")
|
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "RISCV_COMPILER_FLAGS: ${RISCV_COMPILER_FLAGS}")
|
message(STATUS "RISCV_COMPILER_FLAGS: ${RISCV_COMPILER_FLAGS}")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user