Hello,

Admittedly, this is mostly for Emacs.  As such, I don't think it makes
sense to enable it on gcc8 too (emacs doesn't seem like that libgccjit).

Anyway, my idea would be to first enable it in the gcc11 port and
disable it in emacs so that it's not picked up automatically, see how it
goes and then start to see if/how enable support in the emacs port.

Building libgccjit requires the whole compiler to be compile with
--enable-hosh-shared:

: Specify that the host code should be built into position-independent
: machine code (with -fPIC), allowing it to be used within shared
: libraries, but yielding a slightly slower compiler.

I don't know how much 'slightly' amounts to, but other repositories are
building libgccjit separateadly to avoid using --enable-host-shared on
gcc.

Other than that, the only point worth noticing is that ensuring that
libgccjit has the right version set by the ports infrastructure and that
no symlinks are installed requires some fiddling.

Ah, also note that this needs makeinfo.c rev. 1.9, otherwise base
makeinfo crashes handling libgccjit.info (due to an off-by-one spotted
by otto' malloc ;-)

I've been running Emacs with this enabled and, while I haven't noticed
any significant difference in my setup, it hasn't broke yet :)

Even if it's called "jit", emacs actually uses it to compile lisp to
shared objects in a per-user cache which are then loaded.  For e.g. this
is the compiled version of vc-got.el:

% file -b .emacs.d/eln-cache/29.1-09cbcfb6/vc-got-e9cf3f4d-5edd1876.eln
ELF 64-bit LSB shared object, x86-64, version 1


P.S.: how much of "you shouldn't skip bootstrap unless you know what
      you're doing" is true for 'normal' builds like these?  I've used
      FLAVOR='no_ada full' however.


Index: DESCR-jit
===================================================================
RCS file: DESCR-jit
diff -N DESCR-jit
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ DESCR-jit   2 Nov 2023 14:57:32 -0000
@@ -0,0 +1,12 @@
+The GNU Compiler Collection (GCC) includes front ends for C, C++,
+Objective-C, Fortran, Java, and Ada, as well as libraries for these
+languages (libstdc++, libgcj,...).
+
+GCC development is a part of the GNU Project and uses an open
+development environment. Its supports many other platforms in order to
+foster a world-class optimizing compiler, to attract a larger team of
+developers, to ensure that GCC and the GNU system work on multiple
+architectures and diverse environments, and to more thoroughly test and
+extend the features of GCC.
+
+This package contains the JIT compiler.
Index: Makefile.inc
===================================================================
RCS file: /home/cvs/ports/lang/gcc/Makefile.inc,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile.inc
--- Makefile.inc        11 Mar 2022 19:28:58 -0000      1.20
+++ Makefile.inc        2 Nov 2023 14:57:00 -0000
@@ -16,6 +16,7 @@ COMMENT-objc= ${COM}: obj C compiler
 COMMENT-ada=   ${COM}: Ada compiler
 COMMENT-go=    ${COM}: Go compiler
 COMMENT-dlang= ${COM}: D compiler
+COMMENT-jit=   ${COM}: JIT compiler
 
 PKGNAME?=      gcc-${FULL_PKGVERSION}
 PKGNAME-libs?= gcc-libs-${FULL_PKGVERSION}
@@ -26,6 +27,7 @@ PKGNAME-objc?=        gobjc-${FULL_PKGVERSION}
 PKGNAME-ada?=  gnat-${FULL_PKGVERSION}
 PKGNAME-go?=   gccgo-${FULL_PKGVERSION}
 PKGNAME-dlang?=        gdc-${FULL_PKGVERSION}
+PKGNAME-jit?=  libgccjit-${FULL_PKGVERSION}
 
 DESCR-main ?=  ${PORTSDIR}/lang/gcc/DESCR
 DESCR-libs ?=  ${PORTSDIR}/lang/gcc/DESCR-libs
@@ -36,6 +38,7 @@ DESCR-objc ?= ${PORTSDIR}/lang/gcc/DESCR
 DESCR-ada ?=   ${PORTSDIR}/lang/gcc/DESCR-ada
 DESCR-go ?=    ${PORTSDIR}/lang/gcc/DESCR-go
 DESCR-dlang ?= ${PORTSDIR}/lang/gcc/DESCR-dlang
+DESCR-jit ?=   ${PORTSDIR}/lang/gcc/DESCR-jit
 
 HOMEPAGE?=     https://gcc.gnu.org/
 
Index: 11/Makefile
===================================================================
RCS file: /home/cvs/ports/lang/gcc/11/Makefile,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile
--- 11/Makefile 25 Sep 2023 17:07:31 -0000      1.22
+++ 11/Makefile 3 Nov 2023 15:56:23 -0000
@@ -18,7 +18,7 @@ USE_NOEXECONLY = Yes
 V = 11.2.0
 FULL_VERSION = $V
 FULL_PKGVERSION = $V
-REVISION = 9
+REVISION = 10
 
 ADASTRAP-amd64 = adastrap-amd64-$V-3.tar.xz
 ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz
@@ -35,6 +35,7 @@ PKGNAME-f95 =   g95-${FULL_PKGVERSION}
 PKGNAME-objc =  gobjc-${FULL_PKGVERSION}
 PKGNAME-ada =   gnat-${FULL_PKGVERSION}
 PKGNAME-dlang = gdc-${FULL_PKGVERSION}
+PKGNAME-jit =  libgccjit-${FULL_PKGVERSION}
 PKGSPEC-main = gcc->=11,<12
 
 SHARED_LIBS =  estdc++         20.0 \
@@ -48,12 +49,13 @@ SHARED_LIBS =       estdc++         20.0 \
                cc1plugin       2.0 \
                cp1plugin       1.0 \
                gphobos         0.0 \
-               gdruntime       0.0
+               gdruntime       0.0 \
+               gccjit          0.0
 
 PSEUDO_FLAVORS = no_ada full
 FLAVOR ?= 
 
-MULTI_PACKAGES = -main -libs -f95 -objc -c++ -ada -dlang
+MULTI_PACKAGES = -main -libs -f95 -objc -c++ -ada -dlang -jit
 
 MAINTAINER =   Pascal Stumpf <pas...@stumpf.co>
 
@@ -92,7 +94,7 @@ SITES.boot =  https://distfiles.stumpf.co
                https://spacehopper.org/mirrors/ \
                https://distfiles.bsdfrog.org/
 
-LANGS = c,c++,fortran,objc
+LANGS = c,c++,fortran,objc,jit
 .if ${BUILD_PACKAGES:M-ada}
 LANGS := ${LANGS},ada
 DISTFILES.boot += ${ADASTRAP-${MACHINE_ARCH}}
@@ -121,6 +123,7 @@ EXTRA_ENV += ac_cv_prog_M4=/usr/bin/m4
 EXTRA_ENV += ac_cv_header_magic_h=no
 EXTRA_ENV += lt_cv_path_SED=/usr/bin/sed
 EXTRA_ENV += STRIP=/usr/bin/strip
+EXTRA_ENV += LIBgccjit_VERSION=${LIBgccjit_VERSION}
 MAKE_FLAGS +=   ac_cv_path_mkdir=/bin/mkdir
 
 CONFIGURE_ENV += ${EXTRA_ENV}
@@ -149,6 +152,7 @@ CONFIGURE_ARGS += \
        --disable-tls \
        --with-gnu-ld \
        --with-gnu-as \
+       --enable-host-shared \
        --enable-threads=posix \
        --enable-wchar_t \
        --with-gmp="${LOCALBASE}" \
@@ -230,6 +234,7 @@ WANTLIB-main =              ${WANTLIB}
 WANTLIB-ada =          ${WANTLIB} pthread util
 WANTLIB-dlang =                ${WANTLIB} pthread
 WANTLIB-libs =         m pthread
+WANTLIB-jit =          gmp m mpc mpfr z
 
 LIB_DEPENDS +=         devel/gmp,no_cxx,bootstrap \
                        devel/mpfr \
Index: 11/patches/patch-gcc_jit_Make-lang_in
===================================================================
RCS file: 11/patches/patch-gcc_jit_Make-lang_in
diff -N 11/patches/patch-gcc_jit_Make-lang_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 11/patches/patch-gcc_jit_Make-lang_in       2 Nov 2023 19:21:49 -0000
@@ -0,0 +1,72 @@
+don't install symlinks for libgccjit.so
+
+Index: gcc/jit/Make-lang.in
+--- gcc/jit/Make-lang.in.orig
++++ gcc/jit/Make-lang.in
+@@ -53,14 +53,11 @@ jit: $(LIBGCCJIT_FILENAME) \
+ 
+ else
+ 
+-LIBGCCJIT_LINKER_NAME = libgccjit.so
++LIBGCCJIT_LINKER_NAME = libgccjit.so.$(LIBgccjit_VERSION)
+ 
+-LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
+-LIBGCCJIT_FILENAME = \
+-  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)
++LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME)
++LIBGCCJIT_FILENAME = $(LIBGCCJIT_LINKER_NAME)
+ 
+-LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
+-LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
+ 
+ # Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
+ # LD_SONAME_OPTION depending if configure found them, using $(if)
+@@ -76,8 +73,6 @@ LIBGCCJIT_SONAME_OPTION = \
+            -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
+ 
+ jit: $(LIBGCCJIT_FILENAME) \
+-      $(LIBGCCJIT_SYMLINK) \
+-      $(LIBGCCJIT_LINKER_NAME_SYMLINK) \
+       $(FULL_DRIVER_NAME)
+ endif
+ 
+@@ -128,15 +123,6 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \
+            $(LIBGCCJIT_EXTRA_OPTS)
+       @$(call LINK_PROGRESS,$(INDEX.jit),end)
+ 
+-# Create symlinks when not building for Windows
+-ifeq (,$(findstring mingw,$(target)))
+-$(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME)
+-      ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
+-
+-$(LIBGCCJIT_LINKER_NAME_SYMLINK): $(LIBGCCJIT_SONAME_SYMLINK)
+-      ln -sf $(LIBGCCJIT_SONAME_SYMLINK) $(LIBGCCJIT_LINKER_NAME_SYMLINK)
+-endif
+-
+ #
+ # Build hooks:
+ 
+@@ -323,12 +309,6 @@ else
+ jit.install-common: installdirs jit.install-headers
+       $(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
+         $(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME)
+-      ln -sf \
+-        $(LIBGCCJIT_FILENAME) \
+-        $(DESTDIR)$(libdir)/$(LIBGCCJIT_SONAME_SYMLINK)
+-      ln -sf \
+-        $(LIBGCCJIT_SONAME_SYMLINK)\
+-        $(DESTDIR)$(libdir)/$(LIBGCCJIT_LINKER_NAME_SYMLINK)
+ endif
+ 
+ jit.install-man:
+@@ -343,8 +323,8 @@ jit.uninstall:
+ # We just have to delete files specific to us.
+ 
+ jit.mostlyclean:
+-      -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
+-      -rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
++      -rm -f $(LIBGCCJIT_FILENAME)
++      -rm -f $(FULL_DRIVER_NAME)
+       -rm -f $(LIBGCCJIT_SONAME)
+       -rm -f $(jit_OBJS)
+ 
Index: 11/patches/patch-gcc_jit_libgccjit_c
===================================================================
RCS file: 11/patches/patch-gcc_jit_libgccjit_c
diff -N 11/patches/patch-gcc_jit_libgccjit_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 11/patches/patch-gcc_jit_libgccjit_c        3 Nov 2023 20:08:54 -0000
@@ -0,0 +1,13 @@
+Index: gcc/jit/libgccjit.c
+--- gcc/jit/libgccjit.c.orig
++++ gcc/jit/libgccjit.c
+@@ -3474,3 +3474,9 @@ gcc_jit_context_add_top_level_asm (gcc_jit_context *ct
+   RETURN_IF_FAIL (asm_stmts, ctxt, NULL, "NULL asm_stmts");
+   ctxt->add_top_level_asm (loc, asm_stmts);
+ }
++
++const char *
++fname_as_string(int pretty_p __attribute__((__unused__)))
++{
++      return NULL;
++}
Index: 11/pkg/PLIST-jit
===================================================================
RCS file: 11/pkg/PLIST-jit
diff -N 11/pkg/PLIST-jit
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 11/pkg/PLIST-jit    3 Nov 2023 19:34:58 -0000
@@ -0,0 +1,4 @@
+include/libgccjit++.h
+include/libgccjit.h
+@info info/libgccjit.info
+@lib lib/libgccjit.so.${LIBgccjit_VERSION}

Reply via email to