mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-10 20:11:53 +01:00
Merge branch 'feature/clang_toolchain_compat' into 'master'
Build system: minimal changes for clang compatibility See merge request espressif/esp-idf!15168
This commit is contained in:
@@ -13,3 +13,8 @@ idf_component_register(SRCS "tinycbor/src/cborencoder_close_container_checked.c"
|
||||
|
||||
# for open_memstream.c
|
||||
set_source_files_properties(tinycbor/src/open_memstream.c PROPERTIES COMPILE_DEFINITIONS "__linux__")
|
||||
|
||||
# workaround for the fact that we are passing -ffreestanding to Clang
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-U __STDC_HOSTED__")
|
||||
endif()
|
||||
|
||||
@@ -6,3 +6,7 @@ idf_component_register(SRCS "commands.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES vfs
|
||||
PRIV_REQUIRES driver)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
set_source_files_properties(argtable3/argtable3.c PROPERTIES COMPILE_FLAGS -Wno-clobbered)
|
||||
endif()
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#include "argtable3.h"
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wclobbered"
|
||||
|
||||
/*******************************************************************************
|
||||
* This file is part of the argtable3 library.
|
||||
*
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS := .
|
||||
COMPONENT_SRCDIRS := linenoise argtable3 .
|
||||
|
||||
argtable3/argtable3.o: CFLAGS += -Wno-clobbered
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#
|
||||
# Warn if the toolchain version doesn't match
|
||||
#
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
if(NOT (${target} STREQUAL "linux" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||
get_expected_ctng_version(expected_toolchain expected_gcc)
|
||||
gcc_version_check("${expected_gcc}")
|
||||
crosstool_version_check("${expected_toolchain}")
|
||||
endif()
|
||||
|
||||
if(NOT ${target} STREQUAL "linux" AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
message(WARNING "Building ESP-IDF with clang is an experimental feature and is not yet officially supported.")
|
||||
endif()
|
||||
|
||||
@@ -399,7 +399,7 @@ void IRAM_ATTR __attribute__((noreturn, no_sanitize_undefined)) panic_abort(cons
|
||||
#endif
|
||||
#endif
|
||||
|
||||
*((int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
|
||||
*((volatile int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +94,10 @@ int _fstat_r (struct _reent *r, int fd, struct stat *st)
|
||||
* doesn't have the same signature as the original function.
|
||||
* Disable type mismatch warnings for this reason.
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wattribute-alias"
|
||||
#endif
|
||||
|
||||
int _open_r(struct _reent *r, const char * path, int flags, int mode)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
@@ -133,7 +135,9 @@ int _kill_r(struct _reent *r, int pid, int sig)
|
||||
void _exit(int __status)
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* Similar to syscall_not_implemented, but not taking struct _reent argument */
|
||||
int system(const char* str)
|
||||
|
||||
@@ -55,5 +55,9 @@ idf_component_register(SRCS "${srcs}"
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
# Avoid cache miss by unexpected inlineing when built by -Os
|
||||
set_source_files_properties(${cache_srcs} PROPERTIES COMPILE_FLAGS
|
||||
"-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once")
|
||||
set_source_files_properties(${cache_srcs} PROPERTIES COMPILE_FLAGS "-fno-inline-functions")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
# These flags are GCC specific
|
||||
set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS
|
||||
" -fno-inline-small-functions -fno-inline-functions-called-once")
|
||||
endif()
|
||||
|
||||
@@ -408,4 +408,4 @@ esp_err_t spi_flash_chip_generic_suspend_cmd_conf(esp_flash_t *chip);
|
||||
esp_err_t spi_flash_chip_generic_read_unique_id_none(esp_flash_t *chip, uint64_t* flash_unique_id);
|
||||
|
||||
/// Default timeout configuration used by most chips
|
||||
const flash_chip_op_timeout_t spi_flash_chip_generic_timeout;
|
||||
extern const flash_chip_op_timeout_t spi_flash_chip_generic_timeout;
|
||||
|
||||
@@ -10,4 +10,6 @@ idf_component_register(SRCS "esp_spiffs.c"
|
||||
REQUIRES spi_flash
|
||||
PRIV_REQUIRES bootloader_support esptool_py)
|
||||
|
||||
set_source_files_properties(spiffs/src/spiffs_nucleus.c PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
set_source_files_properties(spiffs/src/spiffs_nucleus.c PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user