Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I suppress certain ABI change notes (embedded C++)?

Tags:

c++

gcc

In my project, I am getting many warnings of the form "note: parameter passing for argument of type 'SomeClass<int, float>' when C++17 is enabled changed to match C++14 in GCC 10.1". This occurred after I updated to using a compiler that uses the C++17 standard instead of C++14 (gcc-arm-none-eabi from Arm GNU toolchain v11.2) .

As far as I can tell, this note is referring to changes to correct a bug involving the passing of particular C++ template objects. Please correct my understanding if I am wrong, but I don't think I need to pay any attention to the note because I compile all my dependencies in the project with the sample compiler (gcc 11.2) therefore there shouldn't be any ABI differences. I therefore want to get rid of these notes that come up as they swamp the terminal. I have found some possible solutions:

Set the -Wno-psabi flag

This works and will disable all psABI warnings. However, there may be times where I do want to be notified of ABI changes as explained here (What exactly does GCC's -Wpsabi option do? What are the implications of supressing it?). The answer to that question however also notes that I never need to be concerned with ABI changes if all parts of my program are built with the same compiler. I think this is the case in my project and want to confirm - all libraries and the application itself are compiled with gcc 11.2 except for libstd++ and newlib.

-fcompare-debug-second

This magically make notes go away, however I am unsure how or why. The man page states ' When this option is passed to the compiler driver, it causes the first compilation to be skipped, which makes it useful for little other than debugging the compiler proper.' (https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html) This appears to cause the first compilation pass to be skipped and will only display output from the second, which means that warnings and other output I do want to see may not appear? Hence I am apprehensive about using this also.

Find some way to silence all notes about the ABI parameter passing change between C++14 and C++17 but still leave other notes enabled

This is what I actually want to do but am unsure if there's a way.

like image 838
aduke202050 Avatar asked Jan 31 '26 06:01

aduke202050


1 Answers

There is no way to enable/disable this single ABI warning separately from the rest of -Wpsabi; see the actual code in GCC here.

I'd say the state-of-the-art approach is to simply pass -Wno-psabi but do a manual pass over the code every so often (every time you upgrade the compiler, every year, etc.) to check that all the -Wpsabi warnings you're getting continue to be pointless.

If you really really care, then you could write a simple wrapper script that invokes gcc and pipes the error output through grep -v. (Or through something more suitable like awk or sed, or through a bespoke script in your scripting language of choice, e.g. Python.) This is riskier, in the sense that -Wno-psabi will precisely turn off all ABI warnings but a fouled-up regular expression could conceivably hide arbitrarily many lines of the output without your realizing it.

like image 80
Quuxplusone Avatar answered Feb 01 '26 20:02

Quuxplusone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!