On Fri, Nov 13, 2020 at 10:33:07PM -0500, Brad Smith wrote:
> On Fri, Nov 13, 2020 at 09:55:01PM -0500, George Koehler wrote:
> > On Wed, 11 Nov 2020 01:38:04 +0100
> > Charlene Wendling <[email protected]> wrote:
> >
> > > On Tue, 10 Nov 2020 07:50:26 +0100
> > > Charlene Wendling wrote:
> > >
> > > New diff with aja's and sthen's suggestions. I tested on macppc and, even
> > > if it has no impact there, amd64.
> >
> > I built webkitgtk4 on macppc after you committed your fixes, and with
> > one more change: I deleted the -mlongcall flag. I suggest to keep
> > -mlongcall for now, but the next person to edit webkitgtk4/Makefile
> > should remove -mlongcall at the same time.
> >
> > Below the diff, I explain -mlongcall and -Wl,--relax flags.
> >
> > Index: Makefile
> > ===================================================================
> > RCS file: /cvs/ports/www/webkitgtk4/Makefile,v
> > retrieving revision 1.130
> > diff -u -p -r1.130 Makefile
> > --- Makefile 11 Nov 2020 21:27:03 -0000 1.130
> > +++ Makefile 13 Nov 2020 20:45:24 -0000
> > @@ -119,8 +119,6 @@ LDFLAGS += -Wl,--no-keep-memory
> > .if ${MACHINE_ARCH} == "powerpc"
> > # XXX fix colors being off, it would be nice to fix the code
> > CONFIGURE_ARGS += -DENABLE_GRAPHICS_CONTEXT_GL=OFF
> > -CFLAGS += -mlongcall
> > -CXXFLAGS += -mlongcall
> > LDFLAGS += -Wl,--relax
> > PATCH_LIST = patch-* powerpc-patch-*
> > .endif
> >
> > In powerpc and powerpc64 code, the "bl" instruction for a direct
> > function call uses a signed 26-bit offset. This limits the branch
> > distance to plus or minus 32 megabytes. This works well when each
> > program or shared lib has less than 32M of code.
> >
> > libwebkit2gtk-4.0.so.3.3 is too big, because its LOAD segment with
> > the E flag (for code) has size > 32M = 0x2_000_000 bytes:
> >
> > $ readelf -l libwebkit2gtk-4.0.so.3.3|head
> > ...
> > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > LOAD 0x000000 0x00000000 0x00000000 0x2e979e4 0x2e979e4 R E
> > 0x10000
> >
> > With cc -mlongcall, each function call is indirect through a function
> > pointer. This would get around the 32M limit, but it doesn't work
> > because /usr/lib/crt*.o don't use -mlongcall. My test program with
> > code over 32M got linker errors from crtbegin.o and crt0.o.
> >
> > With cc -Wl,--relax, the linker ld.bfd can pass the 32M limit by
> > inserting a thunk (or branch island) between the "bl" and its
> > destination. This doesn't need -mlongcall and does work with crt*.o.
> > We use -Wl,--relax without -mlongcall in devel/llvm on powerpc.
> >
> > cc -Wl,--relax causes an error with ld.lld on powerpc64 (or with
> > cc -fuse-ld=lld on powerpc), but lld inserts thunks (branch islands)
> > by default. If macppc switches to lld, we would remove -Wl,--relax
> > from ports. --George
I also had something like the following..
Index: devel/llvm/Makefile
===================================================================
RCS file: /home/cvs/ports/devel/llvm/Makefile,v
retrieving revision 1.267
diff -u -p -u -p -r1.267 Makefile
--- devel/llvm/Makefile 10 Nov 2020 12:05:50 -0000 1.267
+++ devel/llvm/Makefile 15 Nov 2020 02:33:01 -0000
@@ -116,9 +114,11 @@ CXXFLAGS+= -mno-retpoline
CXXFLAGS+= -fomit-frame-pointer
.endif
-.if ${MACHINE_ARCH} == "powerpc"
-CONFIGURE_ARGS += -DCMAKE_EXE_LINKER_FLAGS="-Wl,-relax"
-CONFIGURE_ARGS += -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-relax"
+# --relax not supported by lld. Can be removed once powerpc switches to lld.
+.include <bsd.port.arch.mk>
+.if ${MACHINE_ARCH} == "powerpc" && !${PROPERTIES:Mlld}
+CONFIGURE_ARGS += -DCMAKE_EXE_LINKER_FLAGS="-Wl,--relax"
+CONFIGURE_ARGS += -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--relax"
.endif
TEST_TARGET = check check-clang
Index: games/godot/Makefile
===================================================================
RCS file: /home/cvs/ports/games/godot/Makefile,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 Makefile
--- games/godot/Makefile 15 Nov 2020 22:05:10 -0000 1.17
+++ games/godot/Makefile 15 Nov 2020 22:22:21 -0000
@@ -78,7 +78,9 @@ WANTLIB += atomic
.endif
# Fix relocation overflows
-.if ${MACHINE_ARCH:Mpowerpc}
+# --relax not supported by lld. Can be removed once powerpc switches to lld.
+.include <bsd.port.arch.mk>
+.if ${MACHINE_ARCH} == "powerpc" && !${PROPERTIES:Mlld}
LDFLAGS += -Wl,--relax
.endif
Index: www/webkitgtk4/Makefile
===================================================================
RCS file: /home/cvs/ports/www/webkitgtk4/Makefile,v
retrieving revision 1.131
diff -u -p -u -p -r1.131 Makefile
--- www/webkitgtk4/Makefile 15 Nov 2020 22:05:10 -0000 1.131
+++ www/webkitgtk4/Makefile 15 Nov 2020 22:47:02 -0000
@@ -119,8 +119,12 @@ LDFLAGS += -Wl,--no-keep-memory
.if ${MACHINE_ARCH} == "powerpc"
# XXX fix colors being off, it would be nice to fix the code
CONFIGURE_ARGS += -DENABLE_GRAPHICS_CONTEXT_GL=OFF
-LDFLAGS += -Wl,--relax
PATCH_LIST = patch-* powerpc-patch-*
+.endif
+
+# --relax not supported by lld. Can be removed once powerpc switches to lld.
+.if ${MACHINE_ARCH} == "powerpc" && !${PROPERTIES:Mlld}
+LDFLAGS += -Wl,--relax
.endif
post-extract: