8000 Tools - none-cxxflags generator script & enable deprecation warnings … · esp8266/Arduino@a5f18b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit a5f18b5

Browse files
authored
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
1 parent 2c72e6f commit a5f18b5

9 files changed

+55
-13
lines changed

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
9393
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
9494

9595
compiler.cpp.cmd=xtensa-lx106-elf-g++
96-
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}
96+
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}
9797

9898
compiler.as.cmd=xtensa-lx106-elf-as
9999

tests/common.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function build_sketches()
131131
local build_cmd
132132
build_cmd+=${cli_path}
133133
build_cmd+=" compile"\
134+
" --warnings=all"\
134135
" --build-path $build_dir"\
135136
" --fqbn $fqbn"\
136137
" --libraries $library_path"\
@@ -307,20 +308,23 @@ function install_core()
307308
fi
308309

309310
# Set our custom warnings for all builds
310-
{ echo "compiler.c.extra_flags=-Wall -Wextra -Werror $debug_flags";
311-
echo "compiler.cpp.extra_flags=-Wall -Wextra -Werror $debug_flags";
312-
echo "mkbuildoptglobals.extra_flags=--ci --cache_core"; } \
313-
> platform.local.txt
311+
printf "%s\n" \
312+
"compiler.c.extra_flags=-Wall -Wextra $debug_flags" \
313+
"compiler.cpp.extra_flags=-Wall -Wextra $debug_flags" \
314+
"mkbuildoptglobals.extra_flags=--ci --cache_core" \
315+
> ${core_path}/platform.local.txt
314316
echo -e "\n----platform.local.txt----"
315317
cat platform.local.txt
316318
echo -e "\n----\n"
317319

320+
# Fetch toolchain & filesystem utils
318321
pushd tools
319322
python3 get.py -q
320323

321324
popd
322325
popd
323326

327+
# todo: windows runners are using copied tree
324328
local core_dir
325329
core_dir=$(dirname "$hardware_core_path")
326330
mkdir -p "$core_dir"

tools/warnings/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
These are the warning options for the compiler at different levels.
22

3-
Because G++ 10 produces code which crashes when a function is declared
3+
Because GCC produces code which crashes when a function is declared
44
to return a value but doesn't (this is undefined per the C++ specs, but legal
55
for C11 and above code as long as the [non]returned value is ignored), we
66
cannot warn them if we use "-w" to disable all warnings, and instead have
77
to delete every warning but "-Wreturn-type"
88

9-
Generate the "none-g++" file with the following command:
10-
````
11-
./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++
12-
````
9+
Generate the C++ variant with the [`make_none-cxxflags.sh`](make_none-cxxflags.sh) script
10+
11+
Modify [`patterns_none-cxxflags.txt`](patterns_none-cxxflags.txt) patterns to ignore incompatible warning types
File renamed without changes.
File renamed without changes.

tools/warnings/make_none-cxxflags.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env sh
2+
3+
root=$(git rev-parse --show-toplevel)
4+
${CC:-xtensa-lx106-elf-gcc} --help=warnings -Q |\
5+
grep '\[enabled\]' |\
6+
grep -v 'return-type' |\
7+
awk '{print $1}' |\
8+
sed 's/-W/-Wno-/' |\
9+
grep -v = |\
10+
grep -v -f ${root}/tools/warnings/patterns_none-cxxflags.txt |\
11+
sort -u > ${root}/tools/warnings/none-cxxflags
File renamed without changes.

tools/warnings/none-cppflags renamed to tools/warnings/none-cxxflags

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
-Wno-address-of-packed-member
22
-Wno-aggressive-loop-optimizations
3+
-Wno-analyzer-double-fclose
4+
-Wno-analyzer-double-free
5+
-Wno-analyzer-exposure-through-output-file
6+
-Wno-analyzer-file-leak
7+
-Wno-analyzer-free-of-non-heap
38
-Wno-analyzer-malloc-leak
49
-Wno-analyzer-null-argument
510
-Wno-analyzer-null-dereference
@@ -8,18 +13,19 @@
813
-Wno-analyzer-stale-setjmp-buffer
914
-Wno-analyzer-tainted-array-index
1015
-Wno-analyzer-unsafe-call-within-signal-handler
11-
-Wno-attribute-warning
16+
-Wno-analyzer-use-after-free
17+
-Wno-analyzer-use-of-pointer-in-stale-stack-frame
1218
-Wno-attributes
19+
-Wno-attribute-warning
1320
-Wno-builtin-declaration-mismatch
1421
-Wno-builtin-macro-redefined
1522
-Wno-cannot-profile
1623
-Wno-coverage-mismatch
1724
-Wno-cpp
18-
-Wno-deprecated
19-
-Wno-deprecated-declarations
2025
-Wno-div-by-zero
2126
-Wno-endif-labels
2227
-Wno-enum-compare
28+
-Wno-free-nonheap-object
2329
-Wno-hsa
2430
-Wno-if-not-aligned
2531
-Wno-ignored-attributes
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=
2+
NSObject-attribute
3+
c11-c2x-compat
4+
c90-c99-compat
5+
c99-c11-compat
6+
compare-distinct-pointer-types
7+
complain-wrong-lang
8+
declaration-after-statement
9+
declaration-missing-parameter-type
10+
deprecated
11+
deprecated-declarations
12+
designated-init
13+
discarded-array-qualifiers
14+
discarded-qualifiers
15+
implicit-function-declaration
16+
implicit-int
17+
incompatible-pointer-types
18+
int-conversion
19+
old-style-definition
20+
override-init-side-effects
21+
pointer-to-int-cast
22+
return-mismatch

0 commit comments

Comments
 (0)
0