On 3/5/19 12:11 AM, Jeremie Courreges-Anglas wrote:
webkitgtk4 fails to build on sparc64 and powerpc.

   http://build-failures.rhaalovely.net//sparc64/2019-02-03/www/webkitgtk4.log
   http://build-failures.rhaalovely.net/powerpc/2019-02-04/www/webkitgtk4.log

With the diff below I can successfully build the port on sparc64.
Rationale for the diff:
- patches/patch-Source_WTF_wtf_Platform_h: sparc64 MD code doesn't
   expose enough registers to use the HAVE_MACHINE_CONTEXT code path.
- patches/patch-Source_JavaScriptCore_runtime_MachineContext_h: see above
- patches/patch-Source_WTF_wtf_RAMSize_cpp: Linux-only method to get the
   amount of ram, use sysctl(2) instead.
- patches/patch-Source_WebCore_platform_graphics_FontSelectionAlgorithm_h:
   std::min/std::max from libestdc++ aren't annotated with "constexpr"
   yet so using them in a "constexpr" function fails.  This workaround
   shouldn't be needed with lang/gcc/8.
- Makefile: I doubt that webkit's JIT works on sh...  While here, switch
   to https HOMEPAGE/MASTER_SITES.

I haven't tested runtime yet but intend to do so in the next days.  The
original motivation is to unlock a bunch of ports:

   http://build-failures.rhaalovely.net//sparc64/2019-02-03/summary.log

--8<--
ritchie ~$ grep -c webkitgtk4 summary.log
114
ritchie ~$ wc -l summary.log
      296 summary.log
-->8--

The diff could also fix powerpc (cc Charlene).

I don't have a sparc64 machine but a bit ago cwen and I came up with a similar diff to RAMSize.cpp to fix webkit on macppc (I think we used sysconf). JavaScript failed at runtime but I think it's better to get a successful build than not. Same for the gcc-4.9 bits. Those bits are good.

~Brian

ok?


Index: Makefile
===================================================================
RCS file: /cvs/ports/www/webkitgtk4/Makefile,v
retrieving revision 1.95
diff -u -p -r1.95 Makefile
--- Makefile    2 Mar 2019 17:08:51 -0000       1.95
+++ Makefile    5 Mar 2019 04:53:07 -0000
@@ -13,6 +13,7 @@ PORTROACH =           limitw:1,even
  COMMENT =             GTK+ port of the WebKit rendering engine
V = 2.22.7
+REVISION =             0
  DISTNAME =            webkitgtk-${V}
  PKGNAME =             webkitgtk4-${V}
  EXTRACT_SUFX =                .tar.xz
@@ -25,7 +26,7 @@ SHARED_LIBS +=  webkit2gtk-${API}
CATEGORIES = www -HOMEPAGE = http://webkitgtk.org/
+HOMEPAGE =             https://webkitgtk.org/
MAINTAINER = Antoine Jacoutot <[email protected]> @@ -42,7 +43,7 @@ WANTLIB += icui18n icuuc intl jpeg m not
  WANTLIB += png16 secret-1 soup-2.4 sqlite3 tasn1 webp webpdemux
  WANTLIB += woff2dec xml2 xslt z
-MASTER_SITES = http://webkitgtk.org/releases/
+MASTER_SITES =         https://webkitgtk.org/releases/
MODULES = devel/cmake \
                        lang/python \
@@ -91,8 +92,7 @@ CONFIGURE_ARGS +=     -DENABLE_PLUGIN_PROCES
  # sync with Source/JavaScriptCore/assembler/MacroAssembler.h
  .if ${MACHINE_ARCH} != "aarch64" && ${MACHINE_ARCH} != "amd64" && \
      ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "i386" && \
-    ${MACHINE_ARCH} != "mips64" && ${MACHINE_ARCH} != "mips64el" && \
-    ${MACHINE_ARCH} != "sh"
+    ${MACHINE_ARCH} != "mips64" && ${MACHINE_ARCH} != "mips64el"
  # #error "The MacroAssembler is not supported on this platform."
  CONFIGURE_ARGS +=     -DENABLE_JIT=OFF
  CONFIGURE_ARGS +=     -DENABLE_LLINT_C_LOOP=ON
Index: patches/patch-Source_JavaScriptCore_runtime_MachineContext_h
===================================================================
RCS file: 
/cvs/ports/www/webkitgtk4/patches/patch-Source_JavaScriptCore_runtime_MachineContext_h,v
retrieving revision 1.4
diff -u -p -r1.4 patch-Source_JavaScriptCore_runtime_MachineContext_h
--- patches/patch-Source_JavaScriptCore_runtime_MachineContext_h        4 Sep 
2018 07:12:47 -0000       1.4
+++ patches/patch-Source_JavaScriptCore_runtime_MachineContext_h        5 Mar 
2019 04:53:07 -0000
@@ -3,7 +3,7 @@ $OpenBSD: patch-Source_JavaScriptCore_ru
  Index: Source/JavaScriptCore/runtime/MachineContext.h
  --- Source/JavaScriptCore/runtime/MachineContext.h.orig
  +++ Source/JavaScriptCore/runtime/MachineContext.h
-@@ -188,6 +188,24 @@ static inline void*& stackPointerImpl(mcontext_t& mach
+@@ -188,6 +188,22 @@ static inline void*& stackPointerImpl(mcontext_t& mach
   #error Unknown Architecture
   #endif
@@ -19,8 +19,6 @@ Index: Source/JavaScriptCore/runtime/Mac
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.sc_sp);
  +#elif CPU(MIPS)
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[29]);
-+#elif CPU(SPARC64)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_rsp);
  +#else
  +#error Unknown Architecture
  +#endif
@@ -28,7 +26,7 @@ Index: Source/JavaScriptCore/runtime/Mac
   #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#if CPU(X86)
-@@ -335,6 +353,24 @@ static inline void*& framePointerImpl(mcontext_t& mach
+@@ -335,6 +351,22 @@ static inline void*& framePointerImpl(mcontext_t& mach
   #error Unknown Architecture
   #endif
@@ -44,8 +42,6 @@ Index: Source/JavaScriptCore/runtime/Mac
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.sc_x[29]);
  +#elif CPU(MIPS)
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[30]);
-+#elif CPU(SPARC64)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_rbp);
  +#else
  +#error Unknown Architecture
  +#endif
@@ -53,7 +49,7 @@ Index: Source/JavaScriptCore/runtime/Mac
   #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
// The following sequence depends on glibc's sys/ucontext.h.
-@@ -482,6 +518,24 @@ static inline void*& instructionPointerImpl(mcontext_t
+@@ -482,6 +514,22 @@ static inline void*& instructionPointerImpl(mcontext_t
   #error Unknown Architecture
   #endif
@@ -69,8 +65,6 @@ Index: Source/JavaScriptCore/runtime/Mac
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.sc_elr);
  +#elif CPU(MIPS)
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_pc);
-+#elif CPU(SPARC64)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_rip);
  +#else
  +#error Unknown Architecture
  +#endif
@@ -78,7 +72,7 @@ Index: Source/JavaScriptCore/runtime/Mac
   #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
// The following sequence depends on glibc's sys/ucontext.h.
-@@ -639,6 +693,24 @@ inline void*& argumentPointer<1>(mcontext_t& machineCo
+@@ -639,6 +687,22 @@ inline void*& argumentPointer<1>(mcontext_t& machineCo
   #error Unknown Architecture
   #endif
@@ -94,8 +88,6 @@ Index: Source/JavaScriptCore/runtime/Mac
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.sc_x[1]);
  +#elif CPU(MIPS)
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[5]);
-+#elif CPU(SPARC64)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_rsi);
  +#else
  +#error Unknown Architecture
  +#endif
@@ -103,10 +95,12 @@ Index: Source/JavaScriptCore/runtime/Mac
   #elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
// The following sequence depends on glibc's sys/ucontext.h.
-@@ -752,6 +824,24 @@ inline void*& llintInstructionPointer(mcontext_t& mach
+@@ -750,6 +814,22 @@ inline void*& llintInstructionPointer(mcontext_t& mach
+     return reinterpret_cast<void*&>((uintptr_t&) 
machineContext.__gregs[_REG_R8]);
+ #elif CPU(ARM64)
       return reinterpret_cast<void*&>((uintptr_t&) 
machineContext.mc_gpregs.gp_x[4]);
- #elif CPU(MIPS)
-     return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[12]);
++#elif CPU(MIPS)
++    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[12]);
  +#else
  +#error Unknown Architecture
  +#endif
@@ -121,10 +115,6 @@ Index: Source/JavaScriptCore/runtime/Mac
  +    return reinterpret_cast<void*&>((uintptr_t&) 
machineContext.__gregs[_REG_R8]);
  +#elif CPU(ARM64)
  +    return reinterpret_cast<void*&>((uintptr_t&) machineContext.sc_x[4]);
-+#elif CPU(MIPS)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[12]);
-+#elif CPU(SPARC64)
-+    return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_r8);
+ #elif CPU(MIPS)
+     return reinterpret_cast<void*&>((uintptr_t&) machineContext.mc_regs[12]);
   #else
- #error Unknown Architecture
- #endif
Index: patches/patch-Source_WTF_wtf_Platform_h
===================================================================
RCS file: /cvs/ports/www/webkitgtk4/patches/patch-Source_WTF_wtf_Platform_h,v
retrieving revision 1.13
diff -u -p -r1.13 patch-Source_WTF_wtf_Platform_h
--- patches/patch-Source_WTF_wtf_Platform_h     4 Sep 2018 07:12:47 -0000       
1.13
+++ patches/patch-Source_WTF_wtf_Platform_h     5 Mar 2019 04:53:07 -0000
@@ -33,7 +33,7 @@ Index: Source/WTF/wtf/Platform.h
   #endif
-#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || defined(__GLIBC__) || defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
-+#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(OPENBSD) || defined(__GLIBC__) 
|| defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) 
|| CPU(MIPS) || CPU(SPARC64)))
++#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(OPENBSD) || defined(__GLIBC__) 
|| defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) 
|| CPU(MIPS)))
   #define HAVE_MACHINE_CONTEXT 1
   #endif
Index: patches/patch-Source_WTF_wtf_RAMSize_cpp
===================================================================
RCS file: patches/patch-Source_WTF_wtf_RAMSize_cpp
diff -N patches/patch-Source_WTF_wtf_RAMSize_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Source_WTF_wtf_RAMSize_cpp    5 Mar 2019 04:53:07 -0000
@@ -0,0 +1,34 @@
+$OpenBSD$
+
+Index: Source/WTF/wtf/RAMSize.cpp
+--- Source/WTF/wtf/RAMSize.cpp.orig
++++ Source/WTF/wtf/RAMSize.cpp
+@@ -32,8 +32,10 @@
+ #if OS(WINDOWS)
+ #include <windows.h>
+ #elif defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC
+-#if OS(UNIX)
+-#include <sys/sysinfo.h>
++#if OS(OPENBSD)
++#include <sys/sysctl.h>
++#elif OS(UNIX)
++#include <sysinfo.h>
+ #endif // OS(UNIX)
+ #else
+ #include <bmalloc/bmalloc.h>
+@@ -55,7 +57,14 @@ static size_t computeRAMSize()
+         return ramSizeGuess;
+     return status.ullTotalPhys;
+ #elif defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC
+-#if OS(UNIX)
++#if OS(OPENBSD)
++    int mib[] = { CTL_HW, HW_USERMEM64 };
++    int64_t mem;
++    size_t len = sizeof(mem);
++    if (sysctl(mib, 2, &mem, &len, NULL, 0) == -1)
++        return 512 * MB; // guess
++    return mem;
++#elif OS(UNIX)
+     struct sysinfo si;
+     sysinfo(&si);
+     return si.totalram * si.mem_unit;
Index: patches/patch-Source_WebCore_platform_graphics_FontSelectionAlgorithm_h
===================================================================
RCS file: 
patches/patch-Source_WebCore_platform_graphics_FontSelectionAlgorithm_h
diff -N patches/patch-Source_WebCore_platform_graphics_FontSelectionAlgorithm_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Source_WebCore_platform_graphics_FontSelectionAlgorithm_h     
5 Mar 2019 04:53:07 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+XXX libstdc++ from gcc-4.9.4 doesn't yet decorate std::min/std::max
+with constexpr
+
+Index: Source/WebCore/platform/graphics/FontSelectionAlgorithm.h
+--- Source/WebCore/platform/graphics/FontSelectionAlgorithm.h.orig
++++ Source/WebCore/platform/graphics/FontSelectionAlgorithm.h
+@@ -50,7 +50,11 @@ class FontSelectionValue { (public)
+     explicit constexpr FontSelectionValue(float);
+
+     // Precision can be lost, but value will be clamped to the representable 
range.
++#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20160726L
++    static inline    FontSelectionValue clampFloat(float);
++#else
+     static constexpr FontSelectionValue clampFloat(float);
++#endif
+
+     // Since floats have 23 mantissa bits, every value can be represented 
losslessly.
+     constexpr operator float() const;
+@@ -101,7 +105,11 @@ constexpr FontSelectionValue FontSelectionValue::minim
+     return { std::numeric_limits<BackingType>::min(), RawTag::RawTag };
+ }
+
++#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20160726L
++inline    FontSelectionValue FontSelectionValue::clampFloat(float value)
++#else
+ constexpr FontSelectionValue FontSelectionValue::clampFloat(float value)
++#endif
+ {
+     return FontSelectionValue { std::max<float>(minimumValue(), 
std::min<float>(value, maximumValue())) };
+ }



Reply via email to