]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow to build libgccjit with a soname bound to the GCC major version
authorMatthias Klose <doko@ubuntu.com>
Thu, 13 Mar 2025 06:22:02 +0000 (07:22 +0100)
committerMatthias Klose <doko@ubuntu.com>
Thu, 13 Mar 2025 06:22:02 +0000 (07:22 +0100)
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.

gcc/Makefile.in
gcc/configure
gcc/configure.ac
gcc/doc/install.texi
gcc/jit/Make-lang.in

index 5477aea882ab6d1df97e4aaadc37d7e664174642..9ca389a9c619fa54a23c95c7c91a8edf1c94c5af 100644 (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
index 86a5c75a146b1389ccbbaf15ba1a82b8d08d2310..a34ae586d9088329d191387957d94886846a73d1 100755 (executable)
@@ -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 :
index 86f2283a2080a2c60a07a5908727f29dbce5cf04..7e78ed6e1d9ef92e24163d2982f32ba999a1a87c 100644 (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],
index 994fadcecdab4c6f5d3c089118db4e11cacc9f62..308529669b15a1d205badae41a7b5d4c40aa507c 100644 (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}),
index b7fb650ae8aadcc6dfc737a6162a5c842d95d8b8..59afe264a856327f486f1156a1f5e02ddc204d24 100644 (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