diff --git a/platform.txt b/platform.txt index 3ca4ffae2..c34c719ae 100644 --- a/platform.txt +++ b/platform.txt @@ -93,7 +93,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig -lairkiss -lwpa2 {build.stdcpp_lib} -lm -lc -lgcc compiler.cpp.cmd=xtensa-lx106-elf-g++ -compiler.cpp.flags=-c "{compiler.warning_flags}-cppflags" {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags} {build.iramfloat} +compiler.cpp.flags=-c "{compiler.warning_flags}-cxxflags" {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags} {build.iramfloat} compiler.as.cmd=xtensa-lx106-elf-as diff --git a/tests/common.sh b/tests/common.sh index aa7542235..d26db8f3a 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -131,6 +131,7 @@ function build_sketches() local build_cmd build_cmd+=${cli_path} build_cmd+=" compile"\ +" --warnings=all"\ " --build-path $build_dir"\ " --fqbn $fqbn"\ " --libraries $library_path"\ @@ -307,20 +308,23 @@ function install_core() fi # Set our custom warnings for all builds - { echo "compiler.c.extra_flags=-Wall -Wextra -Werror $debug_flags"; - echo "compiler.cpp.extra_flags=-Wall -Wextra -Werror $debug_flags"; - echo "mkbuildoptglobals.extra_flags=--ci --cache_core"; } \ - > platform.local.txt + printf "%s\n" \ + "compiler.c.extra_flags=-Wall -Wextra $debug_flags" \ + "compiler.cpp.extra_flags=-Wall -Wextra $debug_flags" \ + "mkbuildoptglobals.extra_flags=--ci --cache_core" \ + > ${core_path}/platform.local.txt echo -e "\n----platform.local.txt----" cat platform.local.txt echo -e "\n----\n" + # Fetch toolchain & filesystem utils pushd tools python3 get.py -q popd popd + # todo: windows runners are using copied tree local core_dir core_dir=$(dirname "$hardware_core_path") mkdir -p "$core_dir" diff --git a/tools/warnings/README.md b/tools/warnings/README.md index 5fb33f2bd..fa65199f1 100644 --- a/tools/warnings/README.md +++ b/tools/warnings/README.md @@ -1,12 +1,11 @@ These are the warning options for the compiler at different levels. -Because G++ 10 produces code which crashes when a function is declared +Because GCC produces code which crashes when a function is declared to return a value but doesn't (this is undefined per the C++ specs, but legal for C11 and above code as long as the [non]returned value is ignored), we cannot warn them if we use "-w" to disable all warnings, and instead have to delete every warning but "-Wreturn-type" -Generate the "none-g++" file with the following command: -```` -./tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc --help=warnings -Q | grep '\[enabled\]' | grep -v 'return-type' | awk '{print $1}' | sed 's/-W/-Wno-/' | grep -v = | grep -v -- -f | egrep -v '(c11-c2x-compat|c90-c99-compat|c99-c11-compat|declaration-after-statement|designated-init|discarded-array-qualifiers|discarded-qualifiers|implicit-int|incompatible-pointer-types|int-conversion|old-style-definition|override-init-side-effects|pointer-to-int-cast)' > tools/warnings/none-g++ -```` +Generate the C++ variant with the [`make_none-cxxflags.sh`](make_none-cxxflags.sh) script + +Modify [`patterns_none-cxxflags.txt`](patterns_none-cxxflags.txt) patterns to ignore incompatible warning types diff --git a/tools/warnings/default-cppflags b/tools/warnings/default-cxxflags similarity index 100% rename from tools/warnings/default-cppflags rename to tools/warnings/default-cxxflags diff --git a/tools/warnings/extra-cppflags b/tools/warnings/extra-cxxflags similarity index 100% rename from tools/warnings/extra-cppflags rename to tools/warnings/extra-cxxflags diff --git a/tools/warnings/make_none-cxxflags.sh b/tools/warnings/make_none-cxxflags.sh new file mode 100755 index 000000000..0f0eb2ed4 --- /dev/null +++ b/tools/warnings/make_none-cxxflags.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +root=$(git rev-parse --show-toplevel) +${CC:-xtensa-lx106-elf-gcc} --help=warnings -Q |\ + grep '\[enabled\]' |\ + grep -v 'return-type' |\ + awk '{print $1}' |\ + sed 's/-W/-Wno-/' |\ + grep -v = |\ + grep -v -f ${root}/tools/warnings/patterns_none-cxxflags.txt |\ + sort -u > ${root}/tools/warnings/none-cxxflags diff --git a/tools/warnings/more-cppflags b/tools/warnings/more-cxxflags similarity index 100% rename from tools/warnings/more-cppflags rename to tools/warnings/more-cxxflags diff --git a/tools/warnings/none-cppflags b/tools/warnings/none-cxxflags similarity index 81% rename from tools/warnings/none-cppflags rename to tools/warnings/none-cxxflags index d72f50f2a..5a16b0d41 100644 --- a/tools/warnings/none-cppflags +++ b/tools/warnings/none-cxxflags @@ -1,5 +1,10 @@ -Wno-address-of-packed-member -Wno-aggressive-loop-optimizations +-Wno-analyzer-double-fclose +-Wno-analyzer-double-free +-Wno-analyzer-exposure-through-output-file +-Wno-analyzer-file-leak +-Wno-analyzer-free-of-non-heap -Wno-analyzer-malloc-leak -Wno-analyzer-null-argument -Wno-analyzer-null-dereference @@ -8,18 +13,19 @@ -Wno-analyzer-stale-setjmp-buffer -Wno-analyzer-tainted-array-index -Wno-analyzer-unsafe-call-within-signal-handler --Wno-attribute-warning +-Wno-analyzer-use-after-free +-Wno-analyzer-use-of-pointer-in-stale-stack-frame -Wno-attributes +-Wno-attribute-warning -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined -Wno-cannot-profile -Wno-coverage-mismatch -Wno-cpp --Wno-deprecated --Wno-deprecated-declarations -Wno-div-by-zero -Wno-endif-labels -Wno-enum-compare +-Wno-free-nonheap-object -Wno-hsa -Wno-if-not-aligned -Wno-ignored-attributes diff --git a/tools/warnings/patterns_none-cxxflags.txt b/tools/warnings/patterns_none-cxxflags.txt new file mode 100644 index 000000000..b5f3d2498 --- /dev/null +++ b/tools/warnings/patterns_none-cxxflags.txt @@ -0,0 +1,22 @@ += +NSObject-attribute +c11-c2x-compat +c90-c99-compat +c99-c11-compat +compare-distinct-pointer-types +complain-wrong-lang +declaration-after-statement +declaration-missing-parameter-type +deprecated +deprecated-declarations +designated-init +discarded-array-qualifiers +discarded-qualifiers +implicit-function-declaration +implicit-int +incompatible-pointer-types +int-conversion +old-style-definition +override-init-side-effects +pointer-to-int-cast +return-mismatch