~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
6 2

[PATCH] main/gcc: add libgccjit subpackage

Alex McGrath <amk@amk.ie>
Details
Message ID
<20211013204214.11215-1-amk@amk.ie>
DKIM signature
missing
Download raw message
Patch: +117 -0
---

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
Details
Message ID
<163415887290.6885.12234842508659463926.gitlab.26404.923e5747f8cf6084e6cf3bcc23dc59229372d7df@listserv.local>
In-Reply-To
<20211013204214.11215-1-amk@amk.ie> (view parent)
DKIM signature
missing
Download raw message
On Wed, 13 Oct 2021 21:42:14 +0100, Alex McGrath wrote:
> +++ 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

Please submit all patches to gcc to my Alpine GCC patches tree first, as the ihstructions in the APKBUILD outline.  The patches should include a commit message which describes the rationale and upstream status of the patch.

At the very least, that metadata should be present so that I can import the patch myself.

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185364
Details
Message ID
<163415887307.6885.16198924620058104663.gitlab.26404.18730ab136b91c088f2f3181edbe758fe541d9bd@listserv.local>
In-Reply-To
<20211013204214.11215-1-amk@amk.ie> (view parent)
DKIM signature
missing
Download raw message
On Wed, 13 Oct 2021 21:42:14 +0100, Alex McGrath wrote:
>  	export CFLAGS="$CFLAGS -O2"
>  
> +	if $LANG_JIT; then

This should simply be added to the parent `--enable-languages` rather than doing a separate build.

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185365
Details
Message ID
<163415896044.6885.10755242401726644439.gitlab.26404.01cc3d1120c030dd0029b77f561cdd12576bbc4b@listserv.local>
In-Reply-To
<20211013204214.11215-1-amk@amk.ie> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<163415926128.6885.12515237036920774846.gitlab.26404.18730ab136b91c088f2f3181edbe758fe541d9bd@listserv.local>
In-Reply-To
<163415887307.6885.16198924620058104663.gitlab.26404.18730ab136b91c088f2f3181edbe758fe541d9bd@listserv.local> (view parent)
DKIM signature
missing
Download raw message
On Wed, 13 Oct 2021 21:42:14 +0100, Alex McGrath wrote:
>  	export CFLAGS="$CFLAGS -O2"
>  
> +	if $LANG_JIT; then

That works okay but adding `--enable-shared-host` is also required which causes the rest of the compiler to slow down.

>From https://gcc.gnu.org/install/configure.html:
```
--enable-host-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.

    This option is required when building the libgccjit.so library.

    Contrast with --enable-shared, which affects target libraries.

```

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185367
Details
Message ID
<163415929590.6885.5706257919765324547.gitlab.26404.7fe52a0087c1150f3cf2b9f7f1c1474a600c5741@listserv.local>
In-Reply-To
<20211013204214.11215-1-amk@amk.ie> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<163415944481.6885.7052739449898545868.gitlab.26404.18730ab136b91c088f2f3181edbe758fe541d9bd@listserv.local>
In-Reply-To
<163415926128.6885.12515237036920774846.gitlab.26404.18730ab136b91c088f2f3181edbe758fe541d9bd@listserv.local> (view parent)
DKIM signature
missing
Download raw message
On Wed, 13 Oct 2021 21:42:14 +0100, Alex McGrath wrote:
>  	export CFLAGS="$CFLAGS -O2"
>  
> +	if $LANG_JIT; then

Yes, I'd rather have the 1% performance penalty of `--enable-host-shared`, than build GCC twice.

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/26404#note_185369
Reply to thread Export thread (mbox)