[v2,0/2] gcc: xtensa: allow dynamic configuration

Message ID 20221129004551.2213723-1-jcmvbkbc@gmail.com
Headers
Series gcc: xtensa: allow dynamic configuration |

Message

Max Filippov Nov. 29, 2022, 12:45 a.m. UTC
  Hello,

this series addresses the long standing issue with xtensa configuration
support by adding a way to configure toolchain for a specific xtensa
core at runtime using the xtensa-dynconfig [1] library as a plugin.
On a platform with shared library support single toolchain binary
becomes capable of building code for arbitrary xtensa configuration.
At the same time it fully preserves the traditional way of configuring
the toolchain using the xtensa configuration overlay.

Currently xtensa toolchain needs to be patched and rebuilt for every
new xtensa processor configuration. This has a number of downsides:
- toolchain builders need to change the toolchain source code, and
  because xtensa configuration overlay is not a patch, this change is
  special, embedding it into the toolchain build process gets
  backpressure.
- toolchain built for one configuration is usually not usable for any
  other configuration. It's not possible for a distribution to provide
  reusable prebuilt xtensa toolchain.

This series allows building the toolchain (including target libraries)
without its source code modification. Built toolchain takes configuration
parameters from the shared object specified in the environment variable.
That shared object may be built by the xtensa-dynconfig project [1].

The same shared object is used for gcc, all binutils and for gdb.
Xtensa core specific information needed to build that shared object is
taken from the configuration overlay.

Both gcc and binutils-gdb get new shared header file
include/xtensa-dynconfig.h that provides definition of configuration
data structure, initialization macros, redefines XCHAL_* macros to
access this structure and declares function for loading configuration
dynamically.

This is not the first submission of this series, it was first
submitted in 2017 [2]. This version has improved configuration
versioning and GPL-compatibility check that was suggested in comments
for the v1.

[1] https://github.com/jcmvbkbc/xtensa-dynconfig
[2] https://gcc.gnu.org/pipermail/gcc-patches/2017-May/475109.html

Max Filippov (2):
  gcc: xtensa: allow dynamic configuration
  libgcc: xtensa: use built-in configuration

 gcc/config.gcc                               |   1 +
 gcc/config/xtensa/t-xtensa                   |   8 +-
 gcc/config/xtensa/xtensa-dynconfig.c         | 170 +++++++
 gcc/config/xtensa/xtensa-protos.h            |   1 +
 gcc/config/xtensa/xtensa.h                   |  22 +-
 include/xtensa-dynconfig.h                   | 442 +++++++++++++++++++
 libgcc/config/xtensa/crti.S                  |   2 +-
 libgcc/config/xtensa/crtn.S                  |   2 +-
 libgcc/config/xtensa/lib1funcs.S             |   2 +-
 libgcc/config/xtensa/lib2funcs.S             |   2 +-
 libgcc/config/xtensa/xtensa-config-builtin.h | 198 +++++++++
 11 files changed, 828 insertions(+), 22 deletions(-)
 create mode 100644 gcc/config/xtensa/xtensa-dynconfig.c
 create mode 100644 include/xtensa-dynconfig.h
 create mode 100644 libgcc/config/xtensa/xtensa-config-builtin.h
  

Comments

Max Filippov Dec. 7, 2022, 6:03 p.m. UTC | #1
On Mon, Nov 28, 2022 at 4:46 PM Max Filippov <jcmvbkbc@gmail.com> wrote:
>
> Hello,
>
> this series addresses the long standing issue with xtensa configuration
> support by adding a way to configure toolchain for a specific xtensa
> core at runtime using the xtensa-dynconfig [1] library as a plugin.
> On a platform with shared library support single toolchain binary
> becomes capable of building code for arbitrary xtensa configuration.
> At the same time it fully preserves the traditional way of configuring
> the toolchain using the xtensa configuration overlay.
>
> Currently xtensa toolchain needs to be patched and rebuilt for every
> new xtensa processor configuration. This has a number of downsides:
> - toolchain builders need to change the toolchain source code, and
>   because xtensa configuration overlay is not a patch, this change is
>   special, embedding it into the toolchain build process gets
>   backpressure.
> - toolchain built for one configuration is usually not usable for any
>   other configuration. It's not possible for a distribution to provide
>   reusable prebuilt xtensa toolchain.
>
> This series allows building the toolchain (including target libraries)
> without its source code modification. Built toolchain takes configuration
> parameters from the shared object specified in the environment variable.
> That shared object may be built by the xtensa-dynconfig project [1].
>
> The same shared object is used for gcc, all binutils and for gdb.
> Xtensa core specific information needed to build that shared object is
> taken from the configuration overlay.
>
> Both gcc and binutils-gdb get new shared header file
> include/xtensa-dynconfig.h that provides definition of configuration
> data structure, initialization macros, redefines XCHAL_* macros to
> access this structure and declares function for loading configuration
> dynamically.
>
> This is not the first submission of this series, it was first
> submitted in 2017 [2]. This version has improved configuration
> versioning and GPL-compatibility check that was suggested in comments
> for the v1.
>
> [1] https://github.com/jcmvbkbc/xtensa-dynconfig
> [2] https://gcc.gnu.org/pipermail/gcc-patches/2017-May/475109.html
>
> Max Filippov (2):
>   gcc: xtensa: allow dynamic configuration
>   libgcc: xtensa: use built-in configuration
>
>  gcc/config.gcc                               |   1 +
>  gcc/config/xtensa/t-xtensa                   |   8 +-
>  gcc/config/xtensa/xtensa-dynconfig.c         | 170 +++++++
>  gcc/config/xtensa/xtensa-protos.h            |   1 +
>  gcc/config/xtensa/xtensa.h                   |  22 +-
>  include/xtensa-dynconfig.h                   | 442 +++++++++++++++++++
>  libgcc/config/xtensa/crti.S                  |   2 +-
>  libgcc/config/xtensa/crtn.S                  |   2 +-
>  libgcc/config/xtensa/lib1funcs.S             |   2 +-
>  libgcc/config/xtensa/lib2funcs.S             |   2 +-
>  libgcc/config/xtensa/xtensa-config-builtin.h | 198 +++++++++
>  11 files changed, 828 insertions(+), 22 deletions(-)
>  create mode 100644 gcc/config/xtensa/xtensa-dynconfig.c
>  create mode 100644 include/xtensa-dynconfig.h
>  create mode 100644 libgcc/config/xtensa/xtensa-config-builtin.h

Series regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.