https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124949

            Bug ID: 124949
           Summary: Automatic inlining does not respect
                    -Wframe-larger-than limit
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lukas at wunner dot de
  Target Milestone: ---
              Host: x86 64-bit
            Target: arm 32-bit

When compiling a contemporary Linux kernel version (such as v7.0) for arm
32-bit with CONFIG_KASAN_STACK=y, compilation of crypto/ecc.c fails:

      crypto/ecc.c: In function 'ecc_point_mult':
      crypto/ecc.c:1380:1: error: the frame size of 1360 bytes is larger than
12
80 bytes [-Werror=frame-larger-than=]

gcc aggressively inlines functions called by ecc_point_mult(). Those functions
are not annotated "inline", gcc does the inlining by itself.

Naturally the expectation is that gcc is smart enough to stop inlining when the
limit imposed by -Wframe-larger-than is reached. Unfortunately it is *not*
smart enough to do that by itself.

Compiling ecc.c with -finline-limit=101 (or a lower number) to explicitly limit
the inlining avoids the issue.

Disabling CONFIG_KASAN_STACK also avoids the issue.

clang 19.1.7 does not exhibit the issue.

FWIW, the limit of 1280 bytes is defined in lib/Kconfig.debug in the kernel
source tree.

The ask is that gcc stops inlining when reaching the -Wframe-larger-than limit.
In the interim we will work around the problem with -finline-limit=100:
https://lore.kernel.org/all/abfaede9ab2e963d784fb70598ed74935f7f8d93.1775628469.git.lu...@wunner.de/

How to reproduce:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
git checkout v7.0
make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=/tmp/kbuild allmodconfig
make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=/tmp/kbuild crypto/ecc.o

Thanks!

Reply via email to