mirror of
https://github.com/esp8266/Arduino.git
synced 2025-05-31 08:42:49 +03:00
Tools - none-cxxflags generator script & enable deprecation warnings (#9245)
* Tools - none-cxxflags generator script GCC10 -> GCC (as in general, not specific to 10) cpp -> cxx to be consistent with gcc terminology grep exclude patterns in a separate file exclude 'deprecated' warnings by default * actually set warnings when compiling --warnings=none is arduino-cli implicit default
This commit is contained in:
parent
2c72e6f015
commit
a5f18b5f91
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
11
tools/warnings/make_none-cxxflags.sh
Executable file
11
tools/warnings/make_none-cxxflags.sh
Executable file
@ -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
|
@ -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
|
22
tools/warnings/patterns_none-cxxflags.txt
Normal file
22
tools/warnings/patterns_none-cxxflags.txt
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user