https://gcc.gnu.org/g:f1baee38ffe044ab0a7ecbacad965bbeafae7fc4
commit r15-8018-gf1baee38ffe044ab0a7ecbacad965bbeafae7fc4 Author: Matthias Klose <d...@ubuntu.com> Date: Thu Mar 13 07:22:02 2025 +0100 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 <d...@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. Diff: --- gcc/Makefile.in | 1 + gcc/configure | 24 ++++++++++++++++++++++-- gcc/configure.ac | 15 +++++++++++++++ gcc/doc/install.texi | 4 ++++ gcc/jit/Make-lang.in | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5477aea882ab..9ca389a9c619 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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 diff --git a/gcc/configure b/gcc/configure index 86a5c75a146b..a34ae586d908 100755 --- a/gcc/configure +++ b/gcc/configure @@ -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 : diff --git a/gcc/configure.ac b/gcc/configure.ac index 86f2283a2080..7e78ed6e1d9e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -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], diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 994fadcecdab..308529669b15 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -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}), diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index b7fb650ae8aa..59afe264a856 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -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