~alpine/aports

main/gcc: add libgccjit subpackage v1 REJECTED

Alex McGrath <amk@amk.ie>
Alex McGrath: 1
 main/gcc: add libgccjit subpackage

 2 files changed, 117 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/aports/patches/3715/mbox | git am -3
Learn more about email & git

[PATCH] main/gcc: add libgccjit subpackage Export this patch

Alex McGrath <amk@amk.ie>
---

This adds a subpackage for libgccjit. I've tested it with the hello
world sample and it appeared to function. Its recommended to have
separate builds when `--enable-host-shared` is present as otherwise
the compiler gets slowed down which is why there is the slightly
complicated second build with a separate make install in the
subpackage.

Thanks for any feedback, I don't have much experience with the cross
compiler toolchain stuff so I may have made some mistakes.

 .../gcc/0043-fix-poisoned-calloc-gccjit.patch | 63 +++++++++++++++++++
 main/gcc/APKBUILD                             | 54 ++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 main/gcc/0043-fix-poisoned-calloc-gccjit.patch

diff --git a/main/gcc/0043-fix-poisoned-calloc-gccjit.patch b/main/gcc/0043-fix-poisoned-calloc-gccjit.patch
new file mode 100644
index 0000000000..b4fa277c59
--- /dev/null
+++ b/main/gcc/0043-fix-poisoned-calloc-gccjit.patch
@@ -0,0 +1,63 @@
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 5bccf591a..35f5e35ef 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#include <pthread.h>
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "stmt.h"
 
-#include <pthread.h>
-
 #include "jit-playback.h"
 #include "jit-result.h"
 #include "jit-builtins.h"
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index a237d574f..5785e3269 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#include <pthread.h>
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "pretty-print.h"
 #include "toplev.h"
 
-#include <pthread.h>
-
 #include "jit-builtins.h"
 #include "jit-recording.h"
 #include "jit-playback.h"
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index f9c33c63c..75f21d275 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -18,12 +18,13 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#include <pthread.h>
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "timevar.h"
 #include "typed-splay-tree.h"
 #include "cppbuiltin.h"
-#include <pthread.h>
 
 #include "libgccjit.h"
diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index 9f44332a05..96c38b8f59 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -27,6 +27,7 @@ replaces="libstdc++ binutils"
: "${LANG_GO:=true}"
: "${LANG_FORTRAN:=true}"
: "${LANG_ADA:=true}"
: "${LANG_JIT:=true}"

_libgomp=true
_libgcc=true
@@ -46,6 +47,7 @@ if [ "$CHOST" != "$CTARGET" ]; then
	LANG_GO=false
	LANG_FORTRAN=false
	LANG_D=false
	LANG_JIT=false
	_libgomp=false
	_libatomic=false
	_libitm=false
@@ -83,6 +85,7 @@ elif [ "$CBUILD" != "$CHOST" ]; then
	LANG_GO=false
	LANG_FORTRAN=false
	LANG_D=false
	LANG_JIT=false

	STRIP_FOR_TARGET=${CROSS_COMPILE}strip
	_builddir="$srcdir/build-cross-native"
@@ -162,6 +165,9 @@ if $LANG_ADA; then
	[ "$CBUILD" = "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat-bootstrap"
	[ "$CBUILD" != "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross"
fi
if $LANG_JIT; then
	subpackages="$subpackages libgccjit::$CTARGET_ARCH libgccjit$_target:libgccjit"
fi
makedepends="$makedepends_build $makedepends_host"

# when using upstream releases, use this URI template
@@ -214,6 +220,7 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz
	0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch
	0041-Use-generic-errstr.go-implementation-on-musl.patch
	0042-configure-fix-detection-of-atomic-builtins-in-libato.patch
	0043-fix-poisoned-calloc-gccjit.patch
	"

# we build out-of-tree
@@ -317,6 +324,38 @@ build() {

	export CFLAGS="$CFLAGS -O2"

	if $LANG_JIT; then
		mkdir -p "$_builddir"
	    cd "$_builddir"
		"$_gccdir"/configure --prefix=/usr \
      		--mandir=/usr/share/man \
			--infodir=/usr/share/info \
			--build=${CBUILD} \
			--host=${CHOST} \
			--target=${CTARGET} \
			--with-pkgversion="Alpine $pkgver" \
			--enable-checking=release \
			--disable-fixed-point \
			--disable-libstdcxx-pch \
			--disable-multilib \
			--disable-nls \
			--disable-werror \
			$_symvers \
			--enable-__cxa_atexit \
			--enable-default-pie \
			--enable-default-ssp \
			--enable-cloog-backend \
			--enable-languages=jit \
			$_arch_configure \
			$_libc_configure \
			$_cross_configure \
			$_bootstrap_configure \
			--with-system-zlib \
			--enable-host-shared \
			$_hash_style_configure
		make
		mv "$_builddir" "$srcdir"/gccjitbuild
	fi
	mkdir -p "$_builddir"
	cd "$_builddir"
	"$_gccdir"/configure --prefix=/usr \
@@ -661,6 +700,20 @@ gnat() {
	mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/
}

libgccjit() {
	mkdir -p "$subpkgdir"/$_gcclibdir/include
	mkdir -p "$subpkgdir"/build

	cd $srcdir/gccjitbuild
	make -j1 DESTDIR="$subpkgdir"/build install

	mv "$subpkgdir"/build/usr/include/libgccjit*.h \
	   "$subpkgdir"/$_gcclibdir/include
	mv "$subpkgdir"/build/usr/lib/libgccjit.so* \
	   "$subpkgdir"/usr/lib/
	rm -rf "$subpkgdir"/build
}

sha512sums="
93dfd2d92cd9ff61d288df85f588907286108f9524c46bcb1c09010ed051dec18cc04ddaec2e0194fb4236ad2df3202b27eee8536c4b9818cf31504eea97dbeb  gcc-10.3.1_git20210921.tar.xz
eb9e3b118e327dd241cb0ce453f659ddfdbcba2069d85ec5095a0125b397feac03ca340b41519bd44372ff61ed9de5159cdd7bcd060e26a8704f7437f9402f0c  0001-posix_memalign.patch
@@ -705,4 +758,5 @@ d415c887d281b24694deec41a445edf4d48add45caf8e3431c49528f2cfbf1f8a029f03af768ac02
932900fabd81671d403e55b0c19a7a4af46d482ee6cb90463861236b14b66a3a0fdcf5f9583e2ea45a5549e2bedf95307d5f6609c9af9cf92af3e5d2ade315cd  0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch
03b56f4d62af44000c11c5c3dc7a83225392cfbae2a08035cafe4f915710944a04dfc6af106f9371b4fa2167e03da222b38c7b9cebd64493575431543ae3c453  0041-Use-generic-errstr.go-implementation-on-musl.patch
2624a6c862e0804e0a1163d2d2a4e4fb563ae1f66d9ea8aea40b851c8d31c4764bb1ff6241478a9c23c019e8bd7d351d2cd9b8f746bb3debc29104130937f2b0  0042-configure-fix-detection-of-atomic-builtins-in-libato.patch
5a15a1c7514e7d979dd4bd2b50ad6e9fa66242cb1819f2ea4dc16223236267dd549fa61b9a070daeb4328059c88d0b0d46d1081b8e308f3652fa0378ed7f8f57  0043-fix-poisoned-calloc-gccjit.patch
"
-- 
2.33.0
It needs significant changes to be included in the next gcc update.  Please also submit changes to GCC via GitLab, not the aports mailing list, which is intended for simpler changes.

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185366
Sorry I didnt realize about the mailinglist vs gitlab, i'll move stuff over and submit the gcc patch

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185368