mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
cmake: Add a compatible old GCC flag, fix the cmake example building
This commit is contained in:
@@ -157,10 +157,11 @@ echo -e "\nFound issues:"
|
|||||||
# Ignore the next messages:
|
# Ignore the next messages:
|
||||||
# "error.o" or "-Werror" in compiler's command line
|
# "error.o" or "-Werror" in compiler's command line
|
||||||
# "reassigning to symbol" or "changes choice state" in sdkconfig
|
# "reassigning to symbol" or "changes choice state" in sdkconfig
|
||||||
# Compiler and toochain versions is not supported from make/project.mk
|
# 'Compiler and toochain versions is not supported' from make/project.mk
|
||||||
IGNORE_WARNS="\
|
IGNORE_WARNS="\
|
||||||
library/error\.o\
|
library/error\.o\
|
||||||
\|\ -Werror\|error\.d\
|
\|\ -Werror\
|
||||||
|
\|error\.d\
|
||||||
\|reassigning to symbol\
|
\|reassigning to symbol\
|
||||||
\|changes choice state\
|
\|changes choice state\
|
||||||
\|Compiler version is not supported\
|
\|Compiler version is not supported\
|
||||||
|
@@ -160,8 +160,17 @@ echo -e "\nFound issues:"
|
|||||||
# Ignore the next messages:
|
# Ignore the next messages:
|
||||||
# "error.o" or "-Werror" in compiler's command line
|
# "error.o" or "-Werror" in compiler's command line
|
||||||
# "reassigning to symbol" or "changes choice state" in sdkconfig
|
# "reassigning to symbol" or "changes choice state" in sdkconfig
|
||||||
sort -u "${LOG_SUSPECTED}" | \
|
# 'Compiler and toochain versions is not supported' from crosstool_version_check.cmake
|
||||||
grep -v "library/error.o\|\ -Werror\|reassigning to symbol\|changes choice state" \
|
IGNORE_WARNS="\
|
||||||
|
library/error\.o\
|
||||||
|
\|\ -Werror\
|
||||||
|
\|error\.d\
|
||||||
|
\|reassigning to symbol\
|
||||||
|
\|changes choice state\
|
||||||
|
\|crosstool_version_check\.cmake\
|
||||||
|
"
|
||||||
|
|
||||||
|
sort -u "${LOG_SUSPECTED}" | grep -v "${IGNORE_WARNS}" \
|
||||||
&& RESULT=$RESULT_ISSUES \
|
&& RESULT=$RESULT_ISSUES \
|
||||||
|| echo -e "\tNone"
|
|| echo -e "\tNone"
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ function(crosstool_version_check expected_ctng_version)
|
|||||||
OUTPUT_QUIET)
|
OUTPUT_QUIET)
|
||||||
|
|
||||||
string(REGEX MATCH "crosstool-ng-[0-9a-g\\.-]+" ctng_version "${toolchain_stderr}")
|
string(REGEX MATCH "crosstool-ng-[0-9a-g\\.-]+" ctng_version "${toolchain_stderr}")
|
||||||
string(REPLACE "crosstool-ng-" "" ctng_version "${ctng_version}")
|
|
||||||
# We use FIND to match version instead of STREQUAL because some toolchains are built
|
# We use FIND to match version instead of STREQUAL because some toolchains are built
|
||||||
# with longer git hash strings than others. This will match any version which starts with
|
# with longer git hash strings than others. This will match any version which starts with
|
||||||
# the expected version string.
|
# the expected version string.
|
||||||
@@ -30,3 +29,21 @@ function(crosstool_version_check expected_ctng_version)
|
|||||||
"doesn't match supported version ${expected_ctng_version}. ${ctng_version_warning}")
|
"doesn't match supported version ${expected_ctng_version}. ${ctng_version_warning}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(get_expected_ctng_version _toolchain_ver _gcc_ver)
|
||||||
|
file(STRINGS ${IDF_PATH}/tools/toolchain_versions.mk config_contents)
|
||||||
|
foreach(name_and_value ${config_contents})
|
||||||
|
# Strip spaces
|
||||||
|
string(REPLACE " " "" name_and_value ${name_and_value})
|
||||||
|
# Find variable name
|
||||||
|
string(REGEX MATCH "^[^=]+" name ${name_and_value})
|
||||||
|
# Find the value
|
||||||
|
string(REPLACE "${name}=" "" value ${name_and_value})
|
||||||
|
# Getting values
|
||||||
|
if("${name}" STREQUAL "SUPPORTED_TOOLCHAIN_COMMIT_DESC")
|
||||||
|
set("${_toolchain_ver}" "${value}" PARENT_SCOPE)
|
||||||
|
elseif("${name}" STREQUAL "SUPPORTED_TOOLCHAIN_GCC_VERSIONS")
|
||||||
|
set(${_gcc_ver} "${value}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
@@ -40,6 +40,13 @@ macro(idf_set_global_variables)
|
|||||||
|
|
||||||
# path to idf.py tool
|
# path to idf.py tool
|
||||||
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
|
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
|
||||||
|
|
||||||
|
# Temporary trick to support both gcc5 and gcc8 builds
|
||||||
|
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 5.2.0)
|
||||||
|
set(GCC_NOT_5_2_0 0)
|
||||||
|
else()
|
||||||
|
set(GCC_NOT_5_2_0 1)
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Add all the IDF global compiler & preprocessor options
|
# Add all the IDF global compiler & preprocessor options
|
||||||
@@ -86,6 +93,30 @@ function(idf_set_global_compiler_options)
|
|||||||
-Wno-old-style-declaration
|
-Wno-old-style-declaration
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CONFIG_DISABLE_GCC8_WARNINGS)
|
||||||
|
add_compile_options(
|
||||||
|
-Wno-parentheses
|
||||||
|
-Wno-sizeof-pointer-memaccess
|
||||||
|
-Wno-clobbered
|
||||||
|
)
|
||||||
|
|
||||||
|
# doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
|
||||||
|
if(NOT CMAKE_C_COMPILER_VERSION VERSION_EQUAL 5.2.0)
|
||||||
|
add_compile_options(
|
||||||
|
-Wno-format-overflow
|
||||||
|
-Wno-stringop-truncation
|
||||||
|
-Wno-misleading-indentation
|
||||||
|
-Wno-cast-function-type
|
||||||
|
-Wno-implicit-fallthrough
|
||||||
|
-Wno-unused-const-variable
|
||||||
|
-Wno-switch-unreachable
|
||||||
|
-Wno-format-truncation
|
||||||
|
-Wno-memset-elt-size
|
||||||
|
-Wno-int-in-bool-context
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Stack protection
|
# Stack protection
|
||||||
if(NOT BOOTLOADER_BUILD)
|
if(NOT BOOTLOADER_BUILD)
|
||||||
if(CONFIG_STACK_CHECK_NORM)
|
if(CONFIG_STACK_CHECK_NORM)
|
||||||
@@ -114,6 +145,8 @@ function(idf_set_global_compiler_options)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Temporary trick to support both gcc5 and gcc8 builds
|
||||||
|
add_definitions(-DGCC_NOT_5_2_0=${GCC_NOT_5_2_0})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
@@ -134,8 +167,9 @@ function(idf_verify_environment)
|
|||||||
# Warn if the toolchain version doesn't match
|
# Warn if the toolchain version doesn't match
|
||||||
#
|
#
|
||||||
# TODO: make these platform-specific for diff toolchains
|
# TODO: make these platform-specific for diff toolchains
|
||||||
gcc_version_check("5.2.0")
|
get_expected_ctng_version(expected_toolchain expected_gcc)
|
||||||
crosstool_version_check("1.22.0-80-g6c4433a")
|
gcc_version_check("${expected_gcc}")
|
||||||
|
crosstool_version_check("${expected_toolchain}")
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user