mbox series

[0/2] Automate creation of -O2 and -Os multilib variants

Message ID 20241014233350.1625639-1-keithp@keithp.com
Headers show
Series Automate creation of -O2 and -Os multilib variants | expand

Message

Keith Packard Oct. 14, 2024, 11:18 p.m. UTC
When building toolchains for embedded development, some projects will
want to optimize for speed while others are much more concerned about
overall code size. We can do this using the existing GCC multilib
infrastructure, adding suitable speed and size variants as another
dimension of the multilib table.

This could replace the current Debian arm-none-eabi toolchain practice
of duplicating the C library build into 'regular' and 'release'
variants and then requiring application developers select which to use
with a new GCC flag, --picolibc-buildtype=release, which is processed
in a custom .specs file. This mechanism only provides space/speed
optimized versions of the C library, and not libgcc or libstdc++.

The first patch in this series allows multilib configurations to
enable -Os or -Oz while building libgcc by pulling any -Os or -Oz
setting out of the CC and CFLAGS variables and appending them to the
end of the compiler flags used for libgcc and other targets,
overriding numerous uses of -O2 throughout the build system.

The second patch enables a new configuration option,
--enable-multilib-space, which adds -Os as one of the multilib options
and then extends any existing MULTILIB_EXCEPTIONS and
MULTILIB_REQUIRED settings, adding Os variants of each entry.

This has been tested by building all 28 Zephyr toolchains and running
a set of Zephyr tests using the resulting compilers.

As an alternative, we could alter the multilib settings for each
target, but that would touch many more files. If this is the preferred
approach, we'll still need the first patch in this series which allows
a multilib configuration that includes -Os to override the existing
optimization settings used while building libgcc.