On Wed, 11 Nov 2020 01:38:04 +0100 Charlene Wendling <juliana...@posteo.jp> 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