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.

Ok for the trunk?

Matthias
	* configure.ac: Add option --enable-versioned-jit.
	* jit/Make-lang.in (LIBGCCJIT_VERSION_NUM): Move to ...
	* Makefile.in: ... here, setting value from configure.ac.
	* doc/install.texi: Document option --enable-versioned-jit.

--- a/src/gcc/configure.ac
+++ b/src/gcc/configure.ac
@@ -7738,6 +7738,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],
--- a/src/gcc/jit/Make-lang.in
+++ b/src/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
 
--- a/src/gcc/Makefile.in
+++ b/src/gcc/Makefile.in
@@ -1216,6 +1216,7 @@ LANG_CONFIGUREFRAGS  = @all_lang_configu
 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
--- a/src/gcc/doc/install.texi
+++ b/src/gcc/doc/install.texi
@@ -1111,6 +1111,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}),

Reply via email to