diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc2f7e78d7203..8894b47628b455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,12 +301,6 @@ if(CONFIG_COMPILER_COLOR_DIAGNOSTICS) zephyr_compile_options($) endif() -if("${SPARSE}" STREQUAL "y") - list(APPEND TOOLCHAIN_C_FLAGS -D__CHECKER__) - # Avoid compiler "attribute directive ignored" warnings - list(APPEND TOOLCHAIN_C_FLAGS -Wno-attributes) -endif() - zephyr_compile_options( ${TOOLCHAIN_C_FLAGS} ) diff --git a/cmake/compiler/gcc/target.cmake b/cmake/compiler/gcc/target.cmake index de3d80a9e6ca81..c97004829730cd 100644 --- a/cmake/compiler/gcc/target.cmake +++ b/cmake/compiler/gcc/target.cmake @@ -5,39 +5,8 @@ set_ifndef(C++ g++) # Configures CMake for using GCC, this script is re-used by several # GCC-based toolchains -if("${SPARSE}" STREQUAL "y") - # No search PATHS because we need more than cgcc in the default PATH - find_program(CMAKE_C_COMPILER cgcc REQUIRED) - message(STATUS "Found sparse: ${CMAKE_C_COMPILER}") - - find_program(SPARSE_REAL_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH REQUIRED) - - # We know what REAL_CC _must_ be, so why do we ask the user to define it? Because CMake - # cannot set (evil) build time env variables at configure time: - # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-get-or-set-environment-variables - # As of Sep. 2022, sparse/cgcc has unfortunately no --real-cc option as it should. - # - # In theory we could define REAL_CC ourselves here and fix the configure-time - # --print-file-name below (and maybe others). Then ask the user to define REAL_CC later - # at _build_ time. But in practice who would define environment variables at build time - # _only_? So best to fail early and clearly here. - if ("$ENV{REAL_CC}" STREQUAL "") - message(FATAL_ERROR - "The only way to override its 'cc' default when cross-compiling with sparse is " - "unfortunately an environment variable. So you _must_ set REAL_CC at both configuration " - "time and build time to: ${SPARSE_REAL_COMPILER}") - else() # check ENV{REAL_CC} - file(REAL_PATH "${SPARSE_REAL_COMPILER}" real_compiler_rp) - file(REAL_PATH "$ENV{REAL_CC}" env_real_cc_rp) - cmake_path(COMPARE "${real_compiler_rp}" EQUAL "${env_real_cc_rp}" expected_env_REAL_CC) - if(NOT expected_env_REAL_CC) - message(FATAL_ERROR - "Unexpected environment variable REAL_CC: $ENV{REAL_CC}, must be: ${SPARSE_REAL_COMPILER}") - endif() - endif() -else() # SPARSE - find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) -endif() +find_package(Deprecated COMPONENTS SPARSE) +find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) if(${CMAKE_C_COMPILER} STREQUAL CMAKE_C_COMPILER-NOTFOUND) message(FATAL_ERROR "C compiler ${CROSS_COMPILE}${CC} not found - Please check your toolchain installation") diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 5a654204f71318..03c490c68d7bf6 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -66,12 +66,6 @@ macro(configure_linker_script linker_script_gen linker_pass_define) zephyr_get_include_directories_for_lang(C current_includes) get_property(current_defines GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES) - if("${SPARSE}" STREQUAL "y") - set(ld_command ${SPARSE_REAL_COMPILER}) - else() - set(ld_command ${CMAKE_C_COMPILER}) - endif() - add_custom_command( OUTPUT ${linker_script_gen} DEPENDS @@ -80,7 +74,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${extra_dependencies} # NB: 'linker_script_dep' will use a keyword that ends 'DEPENDS' ${linker_script_dep} - COMMAND ${ld_command} + COMMAND ${CMAKE_C_COMPILER} -x assembler-with-cpp ${NOSYSDEF_CFLAG} -MD -MF ${linker_script_gen}.dep -MT ${linker_script_gen} diff --git a/cmake/modules/FindDeprecated.cmake b/cmake/modules/FindDeprecated.cmake index c2582474b2c7cd..a48fe547ac23db 100644 --- a/cmake/modules/FindDeprecated.cmake +++ b/cmake/modules/FindDeprecated.cmake @@ -78,6 +78,18 @@ if("XTOOLS" IN_LIST Deprecated_FIND_COMPONENTS) "Please set ZEPHYR_TOOLCHAIN_VARIANT to 'zephyr'") endif() +if("SPARSE" IN_LIST Deprecated_FIND_COMPONENTS) + list(REMOVE_ITEM Deprecated_FIND_COMPONENTS SPARSE) + # This code was deprecated after Zephyr v3.2.0 + if(SPARSE) + message(DEPRECATION + "Setting SPARSE=${SPARSE} is deprecated. " + "Please set ZEPHYR_SCA_VARIANT to 'sparse'" + ) + set_ifndef(ZEPHYR_SCA_VARIANT sparse) + endif() +endif() + if("SOURCES" IN_LIST Deprecated_FIND_COMPONENTS) list(REMOVE_ITEM Deprecated_FIND_COMPONENTS SOURCES) if(SOURCES)