Allow to build libgccjit with a soname bound to the GCC major version

When configuring GCC with --program-suffix=-$(BASE_VERSION) to allow
installation multiple GCC versions in parallel, the executable of the
driver (gcc-$(BASE_VERSION)) gets recorded in the libgccjit.so.0
library.  Assuming, that you only install the libgccjit.so.0 library
from the newest GCC, you have a libgccjit installed, which always calls
back to the newest installed version of GCC.  I'm not saying that the
ABI is changing, but I'd like to see the libgccjit calling out to the
corresponding compiler, and therefore installing a libgccjit with a
soname that matches the GCC major version.

The downside is having to rebuild packages built against libgccjit with
each major GCC version, but looking at the reverse dependencies, at
least for package builds, only emacs is using libgccjit.

My plan to use this feature is to build a libgccjit0 using the default
GCC (e.g. gcc-14), and a libgccjit15, when building a newer GCC. When
changing the GCC default to 15, building a libgccjit0 from gcc-15, and a
libgccjit14 from gcc-14.

When configuring without --enable-versioned-jit, the behavior is unchanged.

2025-03-13  Matthias Klose  <doko@ubuntu.com>

gcc/
	* configure.ac: Add option --enable-versioned-jit.
	* configure: Regenerate.
	* Makefile.in: Move from jit/Make-lang.in, setting value from
	configure.ac.
	* doc/install.texi: Document option --enable-versioned-jit.

gcc/jit/
	* Make-lang.in (LIBGCCJIT_VERSION_NUM): Move to ../Makefile.in.
This commit is contained in:
Matthias Klose 2025-03-13 07:22:02 +01:00
parent 4e6967aba1
commit f1baee38ff
5 changed files with 43 additions and 3 deletions

View file

@ -1218,6 +1218,7 @@ LANG_CONFIGUREFRAGS = @all_lang_configurefrags@
LANG_MAKEFRAGS = @all_lang_makefrags@
# Used by gcc/jit/Make-lang.in
LIBGCCJIT_VERSION_NUM = @libgccjit_version@
LD_VERSION_SCRIPT_OPTION = @ld_version_script_option@
LD_SONAME_OPTION = @ld_soname_option@
@ENABLE_DARWIN_AT_RPATH_TRUE@DARWIN_RPATH = @rpath

24
gcc/configure vendored
View file

@ -636,6 +636,7 @@ CET_HOST_FLAGS
LD_PICFLAG
PICFLAG
enable_default_pie
libgccjit_version
enable_host_bind_now
LIBGDIAGNOSTICS
enable_libgdiagnostics
@ -1059,6 +1060,7 @@ enable_libquadmath_support
with_linker_hash_style
with_diagnostics_color
with_diagnostics_urls
enable_versioned_jit
enable_default_pie
enable_cet
enable_s390_excess_float_precision
@ -1834,6 +1836,7 @@ Optional Features:
--enable-host-bind-now link host code as BIND_NOW
--disable-libquadmath-support
disable libquadmath support for Fortran
--enable-versioned-jit enable versioned libgccjit build
--enable-default-pie enable Position Independent Executable as default
--enable-cet enable Intel CET in host libraries [default=auto]
--enable-s390-excess-float-precision
@ -21477,7 +21480,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 21480 "configure"
#line 21483 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -21583,7 +21586,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 21586 "configure"
#line 21589 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -34428,6 +34431,23 @@ cat > gcc-driver-name.h <<EOF
#define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_driver_version}${exeext}"
EOF
# Check whether --enable-versioned-jit was given.
# Check whether --enable-versioned-jit was given.
if test "${enable_versioned_jit+set}" = set; then :
enableval=$enable_versioned_jit; enable_versioned_jit=$enableval
else
enable_versioned_jit=no
fi
if test x$enable_versioned_jit = xyes ; then
libgccjit_version=$gcc_driver_version
elif test x$enable_versioned_jit = xno ; then
libgccjit_version=0
else
as_fn_error $? "bad value ${enableval} given for --enable-versioned-jit option" "$LINENO" 5
fi
# Check whether --enable-default-pie was given.
# Check whether --enable-default-pie was given.
if test "${enable_default_pie+set}" = set; then :

View file

@ -7704,6 +7704,21 @@ cat > gcc-driver-name.h <<EOF
#define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_driver_version}${exeext}"
EOF
# Check whether --enable-versioned-jit was given.
AC_ARG_ENABLE(versioned-jit,
[AS_HELP_STRING([--enable-versioned-jit],
[enable versioned libgccjit build])],
enable_versioned_jit=$enableval,
enable_versioned_jit=no)
if test x$enable_versioned_jit = xyes ; then
libgccjit_version=$gcc_driver_version
elif test x$enable_versioned_jit = xno ; then
libgccjit_version=0
else
AC_MSG_ERROR(bad value ${enableval} given for --enable-versioned-jit option)
fi
AC_SUBST([libgccjit_version])
# Check whether --enable-default-pie was given.
AC_ARG_ENABLE(default-pie,
[AS_HELP_STRING([--enable-default-pie],

View file

@ -1148,6 +1148,10 @@ This option is required when building the libgccjit.so library.
Contrast with @option{--enable-shared}, which affects @emph{target}
libraries.
@item --enable-versioned-jit
Specify that the @samp{libgccjit} library is built with a soname matching
the GCC major version.
@item --enable-host-pie
Specify that the @emph{host} executables should be built into
position-independent executables (with @option{-fPIE} and @option{-pie}),

View file

@ -40,7 +40,7 @@
# into the jit rule, but that needs a little bit of work
# to do the right thing within all.cross.
LIBGCCJIT_VERSION_NUM = 0
# LIBGCCJIT_VERSION_NUM is set in ../Makefile.in
LIBGCCJIT_MINOR_NUM = 0
LIBGCCJIT_RELEASE_NUM = 1