Timo Myyrä <timo.my...@bittivirhe.fi> writes:

> Hi,

Hello!

> The upcoming emacs 28 has native compilation feature which allows it to
> use gcc to compile emacs lisp files to loadable libraries by using the
> libgccjit library. This library is not currently provided by the lang/gcc port
> and I took first stab at getting it done.
>
> The --enable-host-shared flag is required by the jit LANG but I'm not
> sure if it is wise to put in generic CONFIGURE_ARGS.
>
> How does this look?

(Friendly remainder for testers that the emacs native compilation needs
to be explicitly enabled at configure time even if libgccjit is
installed.)

I've yet to test your diff, but I've used a similar one and can vouch
that Emacs from the master branch works fine with libgccjit on OpenBSD.
(I've actually come back to "regular" emacs after a while, it didn't
changed much for my use and the *Warnings* buffer popping up randomly
was annoying; yeah display-buffer-alist something, too lazy for that ;-)

Glancing at the diff, I'm unsure if we really need/want to enable
libgccjit for gcc 8 too: IIRC emacs' nativecomp doesn't work with that
old version (I tried around a year ago, maybe things changed in the
meantime.)

Anyway, thanks for working on this! :)

Cheers,

Omar Polo

> Timo
>
> diff 31bccecebaefd3b23c4e4dac76105b5dd0ae1159 /usr/ports
> blob - 0ce4997174291a22be0cc03ec2b258751be50afc
> file + lang/gcc/11/Makefile
> --- lang/gcc/11/Makefile
> +++ lang/gcc/11/Makefile
> @@ -19,8 +19,7 @@ DPB_PROPERTIES = parallel
>  V = 11.2.0
>  FULL_VERSION = $V
>  FULL_PKGVERSION = $V
> -REVISION = 0
> -REVISION-dlang = 1
> +REVISION = 1
>  
>  ADASTRAP-amd64 = adastrap-amd64-$V-0.tar.xz
>  ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz
> @@ -37,6 +36,7 @@ PKGNAME-f95 =   g95-${FULL_PKGVERSION}
>  PKGNAME-objc =  gobjc-${FULL_PKGVERSION}
>  PKGNAME-ada =   gnat-${FULL_PKGVERSION}
>  PKGNAME-dlang = gdc-${FULL_PKGVERSION}
> +PKGNAME-jit =   gcc-jit-${FULL_PKGVERSION}
>  PKGSPEC-main = gcc->=11,<12
>  
>  SHARED_LIBS =        estdc++         20.0 \
> @@ -50,12 +50,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 ?= 
> +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>
>  
> @@ -94,7 +95,7 @@ MASTER_SITES0 =     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 += ${ADASTRAP-${MACHINE_ARCH}}:0
> @@ -152,6 +153,7 @@ CONFIGURE_ARGS += \
>       --with-gnu-ld \
>       --with-gnu-as \
>       --enable-threads=posix \
> +     --enable-host-shared \
>       --enable-wchar_t \
>       --with-gmp="${LOCALBASE}" \
>       --enable-languages=${LANGS} \
> @@ -226,6 +228,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 \
> blob - /dev/null
> file + lang/gcc/11/patch-gcc_jit_Make-lang_in
> --- /dev/null
> +++ lang/gcc/11/patch-gcc_jit_Make-lang_in
> @@ -0,0 +1,37 @@
> +$OpenBSD$
> +
> +Index: gcc/jit/Make-lang.in
> +--- gcc/jit/Make-lang.in.orig
> ++++ gcc/jit/Make-lang.in
> +@@ -40,13 +40,15 @@
> + # into the jit rule, but that needs a little bit of work
> + # to do the right thing within all.cross.
> + 
> +-LIBGCCJIT_LINKER_NAME = libgccjit.so
> ++include $(top_srcdir)/../libversions
> ++
> ++LIBGCCJIT_LINKER_NAME = libgccjit.so.$(LIBGCCJIT_VERSION_NUM)
> + LIBGCCJIT_VERSION_NUM = 0
> + LIBGCCJIT_MINOR_NUM = 0
> + LIBGCCJIT_RELEASE_NUM = 1
> +-LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
> ++LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_FILENAME = \
> +-  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)
> ++  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_VERSION_NUM)
> + 
> + LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
> +@@ -275,12 +277,6 @@ check_jit_parallelize = 10
> + jit.install-common: installdirs
> +     $(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)
> +     $(INSTALL_DATA) $(srcdir)/jit/libgccjit.h \
> +       $(DESTDIR)/$(includedir)/libgccjit.h
> +     $(INSTALL_DATA) $(srcdir)/jit/libgccjit++.h \
> blob - /dev/null
> file + lang/gcc/11/patches/patch-gcc_jit_Make-lang_in
> --- /dev/null
> +++ lang/gcc/11/patches/patch-gcc_jit_Make-lang_in
> @@ -0,0 +1,45 @@
> +$OpenBSD$
> +
> +Index: gcc/jit/Make-lang.in
> +--- gcc/jit/Make-lang.in.orig
> ++++ gcc/jit/Make-lang.in
> +@@ -40,6 +40,8 @@
> + # into the jit rule, but that needs a little bit of work
> + # to do the right thing within all.cross.
> + 
> ++include $(top_srcdir)/../libversions
> ++
> + LIBGCCJIT_VERSION_NUM = 0
> + LIBGCCJIT_MINOR_NUM = 0
> + LIBGCCJIT_RELEASE_NUM = 1
> +@@ -53,11 +55,11 @@ jit: $(LIBGCCJIT_FILENAME) \
> + 
> + else
> + 
> +-LIBGCCJIT_LINKER_NAME = libgccjit.so
> ++LIBGCCJIT_LINKER_NAME = libgccjit.so.$(LIBGCCJIT_VERSION_NUM)
> + 
> +-LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
> ++LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_FILENAME = \
> +-  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)
> ++  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_VERSION_NUM)
> + 
> + LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
> +@@ -127,15 +129,6 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \
> +          $(EXTRA_GCC_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:
> blob - /dev/null
> file + lang/gcc/11/pkg/PLIST-jit
> --- /dev/null
> +++ lang/gcc/11/pkg/PLIST-jit
> @@ -0,0 +1,7 @@
> +@comment $OpenBSD$
> +include/libgccjit++.h
> +include/libgccjit.h
> +@info info/libgccjit.info
> +@so lib/libgccjit.so
> +lib/libgccjit.so.0
> +@bin lib/libgccjit.so.0.0.1
> blob - 5b5e2778f61201af5e80ae66e034b588f09ec5a9
> file + lang/gcc/8/Makefile
> --- lang/gcc/8/Makefile
> +++ lang/gcc/8/Makefile
> @@ -18,7 +18,7 @@ DPB_PROPERTIES = parallel
>  V = 8.4.0
>  FULL_VERSION = $V
>  FULL_PKGVERSION = $V
> -REVISION = 9
> +REVISION = 10
>  
>  ADASTRAP-amd64 = adastrap-amd64-8.3.0-2.tar.xz
>  ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz
> @@ -34,6 +34,7 @@ PKGNAME-c++ =   g++-${FULL_PKGVERSION}
>  PKGNAME-f95 =   g95-${FULL_PKGVERSION}
>  PKGNAME-objc =  gobjc-${FULL_PKGVERSION}
>  PKGNAME-ada =   gnat-${FULL_PKGVERSION}
> +PKGNAME-jit =   gcc-jit-${FULL_PKGVERSION}
>  PKGSPEC-main = gcc->=8,<9
>  
>  SHARED_LIBS =        estdc++         19.0 \
> @@ -45,12 +46,13 @@ SHARED_LIBS =     estdc++         19.0 \
>               quadmath        3.0 \
>               cc1             1.0 \
>               cc1plugin       1.0 \
> -             cp1plugin       0.0
> +             cp1plugin       0.0 \
> +             gccjit          0.0
>  
>  PSEUDO_FLAVORS = no_ada full
>  FLAVOR ?= 
>  
> -MULTI_PACKAGES = -main -libs -f95 -objc -c++ -ada
> +MULTI_PACKAGES = -main -libs -f95 -objc -c++ -ada -jit
>  
>  MAINTAINER = Pascal Stumpf <pas...@stumpf.co>
>  
> @@ -89,7 +91,7 @@ MASTER_SITES0 =     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 += ${ADASTRAP-${MACHINE_ARCH}}:0
> @@ -133,6 +135,7 @@ CONFIGURE_ARGS += \
>       --enable-threads=posix \
>       --enable-wchar_t \
>       --with-gmp="${LOCALBASE}" \
> +     --enable-host-shared \
>       --enable-languages=${LANGS} \
>       --disable-libstdcxx-pch \
>       --enable-default-ssp \
> @@ -197,6 +200,7 @@ RUN_DEPENDS-libs =
>  WANTLIB-main =               ${WANTLIB}
>  WANTLIB-ada =                ${WANTLIB} pthread util
>  WANTLIB-libs =               m pthread z
> +WANTLIB-jit =                gmp m mpc mpfr z
>  
>  LIB_DEPENDS +=               devel/gmp,no_cxx,bootstrap \
>                       devel/mpfr \
> blob - /dev/null
> file + lang/gcc/8/patches/patch-gcc_jit_Make-lang_in
> --- /dev/null
> +++ lang/gcc/8/patches/patch-gcc_jit_Make-lang_in
> @@ -0,0 +1,37 @@
> +$OpenBSD$
> +
> +Index: gcc/jit/Make-lang.in
> +--- gcc/jit/Make-lang.in.orig
> ++++ gcc/jit/Make-lang.in
> +@@ -40,13 +40,15 @@
> + # into the jit rule, but that needs a little bit of work
> + # to do the right thing within all.cross.
> + 
> +-LIBGCCJIT_LINKER_NAME = libgccjit.so
> ++include $(top_srcdir)/../libversions
> ++
> ++LIBGCCJIT_LINKER_NAME = libgccjit.so.$(LIBGCCJIT_VERSION_NUM)
> + LIBGCCJIT_VERSION_NUM = 0
> + LIBGCCJIT_MINOR_NUM = 0
> + LIBGCCJIT_RELEASE_NUM = 1
> +-LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
> ++LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_FILENAME = \
> +-  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)
> ++  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_VERSION_NUM)
> + 
> + LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
> + LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
> +@@ -275,12 +277,6 @@ check_jit_parallelize = 10
> + jit.install-common: installdirs
> +     $(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)
> +     $(INSTALL_DATA) $(srcdir)/jit/libgccjit.h \
> +       $(DESTDIR)/$(includedir)/libgccjit.h
> +     $(INSTALL_DATA) $(srcdir)/jit/libgccjit++.h \
> blob - /dev/null
> file + lang/gcc/8/pkg/PLIST-jit
> --- /dev/null
> +++ lang/gcc/8/pkg/PLIST-jit
> @@ -0,0 +1,5 @@
> +@comment $OpenBSD: PLIST-jit,v$
> +@lib lib/libgccjit.so.${LIBgccjit_VERSION}
> +include/libgccjit++.h
> +include/libgccjit.h
> +@info info/libgccjit.info
> blob - /dev/null
> file + lang/gcc/DESCR-jit
> --- /dev/null
> +++ lang/gcc/DESCR-jit
> @@ -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 Just-In-Time compiler plugin.
> blob - 9859085de151d690ce2ae655166a9f476104cba7
> file + lang/gcc/Makefile.inc
> --- lang/gcc/Makefile.inc
> +++ lang/gcc/Makefile.inc
> @@ -18,6 +18,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}
> @@ -28,6 +29,7 @@ PKGNAME-objc?=      gobjc-${FULL_PKGVERSION}
>  PKGNAME-ada?=        gnat-${FULL_PKGVERSION}
>  PKGNAME-go?= gccgo-${FULL_PKGVERSION}
>  PKGNAME-dlang?=      gdc-${FULL_PKGVERSION}
> +PKGNAME-jit?=        gcc-jit-${FULL_PKGVERSION}
>  
>  DESCR-main ?=        ${PORTSDIR}/lang/gcc/DESCR
>  DESCR-libs ?=        ${PORTSDIR}/lang/gcc/DESCR-libs
> @@ -38,6 +40,7 @@ DESCR-objc ?=       ${PORTSDIR}/lang/gcc/DESCR-objc
>  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/
>  

Reply via email to