On 2025-04-28 02:43, Bruno Haible wrote:
Paul Eggert wrote:
Remove -Wdisabled-optimization, as this is a warning about the
compiler not the program.

Does gcc's warning message give a hint how the compiler options could
be adjusted, so as to enable the optimization?

Unfortunately not, at least not to me. Here's the diagnostic:

bytecode.c: In function ‘exec_byte_code’:
bytecode.c:1792:1: error: fold-mem-offsets: 419 basic blocks and 52 edges/basic block [-Werror=disabled-optimization]
 1792 | }
      | ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:444: bytecode.o] Error 1

This is with gcc-15 (Ubuntu 15-20250404-0ubuntu1) 15.0.1 20250404 (experimental) [master r15-9193-g08e803aa9be] on Ubuntu 25.04 with Emacs master commit b06046edcfceb6ba426880444894373f21ea4a79 configured via "./configure --enable-gcc-warnings 'CC=gcc-15 -Wdisabled-optimization'".

I do not get the diagnostic with gcc (GCC) 15.1.1 20250425 (Red Hat 15.1.1-1) on Fedora 42 with the same Emacs commit configured via "./configure --enable-gcc-warnings 'CC=gcc -Wdisabled-optimization'". Since the Ubuntu failure is with an experimental compiler, if it were the only issue I suppose we could enable -Wdisabled-optimization for now and see whether there are problems on non-experimental GCCs. However, if the -Wdisabled-optimization diagnostics are useless in practice, this kind of experimentation won't be worth the hassle.

For what it's worth, in 2017 libvirt ran into the same problem I did in Emacs, and disabled the warning for the same reason[1].

My impression from looking at Google hits is that the warning is more useful in C++ which has more of a code-bloat problem, and where one can use the diagnostic as an idiot light meaning "overuse of templates". So it might make sense to omit it for C but enable it for C++. I'm no C++ expert though.

Also there is precedent for for not enabling this sort of warning, as we don't enable -Wanalyzer-symbol-too-complex either.

[1]: https://lists.libvirt.org/archives/list/[email protected]/message/PJZ52SOEHXF3RULW26BKDIGJNXTCDRFP/

Reply via email to