Skip to content

Tools - none-cxxflags generator script & re-add -Wdeprecated and -Wdeprecated-declarations #9245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"\
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions tools/warnings/README.md
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions tools/warnings/make_none-cxxflags.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
12 changes: 9 additions & 3 deletions tools/warnings/none-cppflags → tools/warnings/none-cxxflags
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tools/warnings/patterns_none-cxxflags.txt
Original file line number Diff line number Diff line change
@@ -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