From fbfa83476dbfedafc2e33efd0efe9401251c37ef Mon Sep 17 00:00:00 2001 From: David Candler Date: Mon, 2 Dec 2024 08:48:10 +0000 Subject: [PATCH 1/2] Add an option to disable QEMU testing Testing with QEMU is implicitly enabled by default, but configuring the project to run with tests requires QEMU. As testing with QEMU is considered optional, it should be possible to disable tests when QEMU is not available or testing is not needed. Since there is already an option for controlling FVP testing, this patch adds a similar option for QEMU, ENABLE_QEMU_TESTING, which instead defaults to ON. This can then be turned off when QEMU is not installed, so that configurations where QEMU is expected can suitably detect and show an error when it is missing. --- CMakeLists.txt | 6 ++++++ arm-multilib/CMakeLists.txt | 7 ++++++- docs/building-from-source.md | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8942842..d37a1ea7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,11 @@ option( "During checkout, apply optional downstream patches to llvm-project to improve performance." ) +option( + ENABLE_QEMU_TESTING + "Tests using QEMU are enabled by default, but can be disabled." + ON +) option( ENABLE_FVP_TESTING "Tests using FVP need to be explictly enabled." @@ -596,6 +601,7 @@ if(NOT PREBUILT_TARGET_LIBRARIES) -DENABLE_VARIANTS=${ENABLE_VARIANTS_PASSTHROUGH} -DLIBC_HDRGEN=${LIBC_HDRGEN} -DFVP_INSTALL_DIR=${FVP_INSTALL_DIR} + -DENABLE_QEMU_TESTING=${ENABLE_QEMU_TESTING} -DENABLE_FVP_TESTING=${ENABLE_FVP_TESTING} -DFVP_CONFIG_DIR=${CMAKE_CURRENT_SOURCE_DIR}/fvp/config -DFETCHCONTENT_SOURCE_DIR_LLVMPROJECT=${FETCHCONTENT_SOURCE_DIR_LLVMPROJECT} diff --git a/arm-multilib/CMakeLists.txt b/arm-multilib/CMakeLists.txt index 50df2c33..2ea8a1eb 100644 --- a/arm-multilib/CMakeLists.txt +++ b/arm-multilib/CMakeLists.txt @@ -33,6 +33,11 @@ set(C_LIBRARY "picolibc" CACHE STRING "Which C library to use.") set_property(CACHE C_LIBRARY PROPERTY STRINGS picolibc newlib llvmlibc) set(LLVM_BINARY_DIR "" CACHE PATH "Path to LLVM toolchain build or install root.") set(LIBC_HDRGEN "" CACHE PATH "Path to prebuilt lbc-hdrgen if not included in LLVM binaries set by LLVM_BINARY_DIR") +option( + ENABLE_QEMU_TESTING + "Tests using QEMU are enabled by default, but can be disabled." + ON +) option( ENABLE_FVP_TESTING "Tests using FVP need to be explictly enabled." @@ -164,7 +169,7 @@ foreach(lib_idx RANGE ${lib_count_dec}) # FVP testing should default to off, so override any # settings from the JSON. - if(test_executor STREQUAL "fvp" AND NOT ${ENABLE_FVP_TESTING}) + if((test_executor STREQUAL "qemu" AND NOT ${ENABLE_QEMU_TESTING}) OR (test_executor STREQUAL "fvp" AND NOT ${ENABLE_FVP_TESTING})) list(APPEND additional_cmake_args "-DENABLE_LIBC_TESTS=OFF" "-DENABLE_COMPILER_RT_TESTS=OFF" "-DENABLE_LIBCXX_TESTS=OFF") set(read_ENABLE_LIBC_TESTS "OFF") set(read_ENABLE_COMPILER_RT_TESTS "OFF") diff --git a/docs/building-from-source.md b/docs/building-from-source.md index 6b70487c..e1efefa3 100644 --- a/docs/building-from-source.md +++ b/docs/building-from-source.md @@ -36,6 +36,10 @@ $ brew install llvm python3 git make ninja qemu cmake $ pip install meson ``` +Testing with QEMU is enabled by default, but can be disabled using the +`-DENABLE_QEMU_TESTING=OFF` CMake option if testing is not required or QEMU is +not installed. + Some recent targets are not supported by QEMU, for these the Arm FVP models are used instead. These models are available free-of-change but are not open-source, and come with their own licenses. From 2c8cc0f0b43c51d1bf50928617d366142ca67f33 Mon Sep 17 00:00:00 2001 From: David Candler Date: Mon, 2 Dec 2024 10:53:01 +0000 Subject: [PATCH 2/2] fixup! Add an option to disable QEMU testing --- CMakeLists.txt | 4 ++-- arm-multilib/CMakeLists.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d37a1ea7..416ce5dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,12 +152,12 @@ option( ) option( ENABLE_QEMU_TESTING - "Tests using QEMU are enabled by default, but can be disabled." + "Enable tests that use QEMU. This option is ON by default." ON ) option( ENABLE_FVP_TESTING - "Tests using FVP need to be explictly enabled." + "Enable tests that use FVPs. This option is OFF by default." ) set( FVP_INSTALL_DIR diff --git a/arm-multilib/CMakeLists.txt b/arm-multilib/CMakeLists.txt index 2ea8a1eb..027332fa 100644 --- a/arm-multilib/CMakeLists.txt +++ b/arm-multilib/CMakeLists.txt @@ -35,12 +35,12 @@ set(LLVM_BINARY_DIR "" CACHE PATH "Path to LLVM toolchain build or install root. set(LIBC_HDRGEN "" CACHE PATH "Path to prebuilt lbc-hdrgen if not included in LLVM binaries set by LLVM_BINARY_DIR") option( ENABLE_QEMU_TESTING - "Tests using QEMU are enabled by default, but can be disabled." + "Enable tests that use QEMU. This option is ON by default." ON ) option( ENABLE_FVP_TESTING - "Tests using FVP need to be explictly enabled." + "Enable tests that use FVPs. This option is OFF by default." ) set( FVP_INSTALL_DIR @@ -167,8 +167,8 @@ foreach(lib_idx RANGE ${lib_count_dec}) file(READ ${variant_json_file} variant_json_str) string(JSON test_executor GET ${variant_json_str} "args" "common" "TEST_EXECUTOR") - # FVP testing should default to off, so override any - # settings from the JSON. + # The multilib project can be configured to disable QEMU and/or FVP + # testing, which will need to override the settings from the json. if((test_executor STREQUAL "qemu" AND NOT ${ENABLE_QEMU_TESTING}) OR (test_executor STREQUAL "fvp" AND NOT ${ENABLE_FVP_TESTING})) list(APPEND additional_cmake_args "-DENABLE_LIBC_TESTS=OFF" "-DENABLE_COMPILER_RT_TESTS=OFF" "-DENABLE_LIBCXX_TESTS=OFF") set(read_ENABLE_LIBC_TESTS "OFF")