Re: macppc: Unbreak www/webkitgtk4 2.24

2019-03-25 Thread Jeremie Courreges-Anglas
On Thu, Mar 21 2019, Charlene Wendling  wrote:
> Hi ports,
>
> This update causes various issues on powerpc (ports-clang is used
> for this one): 
>
> 1) "There's nowhere that max_align_t is defined"
>
>bcallah@ found this during an attempt to build webkigtk4 on macppc
>with gcc-8.2 as ports-gcc [0]. I still use gcc-4.9 on my side,
>same thing. I'll let him address this issue as he's working on it.
>
>Temporarily i made a quick fix in webkitgtk4's code itself. 

This has been fixed in g++-4.9.4p18.

> 2) Unsigned char by default
>
>There are a few occurences of narrowing to signed char that
>breaks the build on macppc.
>
>I fixed them as clang++ told me where they were. 
>
> 3) __mulodi4 generated by ports-clang on powerpc
>
>This is a follow-up of my diff against v2.22. Code changed, and so
>is the patch.
>
> Testing: 
>
> - nothing is broken on amd64 (the build log is here, 
>   ¡28 Mbytes! [1]), i used surf without issues.
> - on macppc, it indeed builds, the runtime is still meh. 
>   According to various tests i did, the network code may be to 
>   blame [2].
>   I can display a prefetched OpenBSD homepage, even run basic 
>   javascript. As soon as i really want to browse online, i've the 
>   classical "Internal webkit error". 
>
>
> Given that no webkitgtk4 means no Gnome, i felt like sharing early,
> as iirc arm* will be hit by 2).

Looks likely indeed.

> Opinions, comments, testing [...] welcome :) 

The unsigned char fixes and the relocation overflow flags look fine.
For 3) I'm wondering which other architectures might be affected,
at least sparc64 isn't.  Maybe 32 bits architectures only, like hppa?
We may have to refine the #ifdef test later.

ok jca@

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



macppc: Unbreak www/webkitgtk4 2.24

2019-03-21 Thread Charlene Wendling
Hi ports,

This update causes various issues on powerpc (ports-clang is used
for this one): 

1) "There's nowhere that max_align_t is defined"
   
   bcallah@ found this during an attempt to build webkigtk4 on macppc
   with gcc-8.2 as ports-gcc [0]. I still use gcc-4.9 on my side,
   same thing. I'll let him address this issue as he's working on it.

   Temporarily i made a quick fix in webkitgtk4's code itself. 

2) Unsigned char by default

   There are a few occurences of narrowing to signed char that
   breaks the build on macppc.

   I fixed them as clang++ told me where they were. 

3) __mulodi4 generated by ports-clang on powerpc

   This is a follow-up of my diff against v2.22. Code changed, and so
   is the patch.

Testing: 

- nothing is broken on amd64 (the build log is here, 
  ¡28 Mbytes! [1]), i used surf without issues.
- on macppc, it indeed builds, the runtime is still meh. 
  According to various tests i did, the network code may be to 
  blame [2].
  I can display a prefetched OpenBSD homepage, even run basic 
  javascript. As soon as i really want to browse online, i've the 
  classical "Internal webkit error". 


Given that no webkitgtk4 means no Gnome, i felt like sharing early,
as iirc arm* will be hit by 2).

Opinions, comments, testing [...] welcome :) 


Charlène.


[0] https://bsd.network/@bcallah/101784192360684678
[1] http://0x0.st/z8Un.txt
[2] https://bsd.network/@julianaito/101788954290460434


Index: Makefile
===
RCS file: /cvs/ports/www/webkitgtk4/Makefile,v
retrieving revision 1.98
diff -u -p -u -p -r1.98 Makefile
--- Makefile14 Mar 2019 09:48:28 -  1.98
+++ Makefile21 Mar 2019 19:02:58 -
@@ -13,6 +13,7 @@ PORTROACH =   limitw:1,even
 COMMENT =  GTK+ port of the WebKit rendering engine
 
 V =2.24.0
+REVISION = 0
 DISTNAME = webkitgtk-${V}
 PKGNAME =  webkitgtk4-${V}
 EXTRACT_SUFX = .tar.xz
@@ -110,6 +111,12 @@ LDFLAGS += -Wl,--no-keep-memory
 .if ${MACHINE_ARCH} == "i386"
 CFLAGS +=  -march=i686
 CXXFLAGS +=-march=i686
+.endif
+
+.if ${MACHINE_ARCH} == "powerpc"
+CFLAGS +=  -mlongcall
+CXXFLAGS +=-mlongcall
+LDFLAGS += -Wl,--relax
 .endif
 
 post-extract:
Index: patches/patch-Source_JavaScriptCore_runtime_CachedTypes_cpp
===
RCS file: patches/patch-Source_JavaScriptCore_runtime_CachedTypes_cpp
diff -N patches/patch-Source_JavaScriptCore_runtime_CachedTypes_cpp
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-Source_JavaScriptCore_runtime_CachedTypes_cpp 21 Mar 2019 
19:02:58 -
@@ -0,0 +1,27 @@
+$OpenBSD$
+
+ports-clang: std::max_align_t cannot be found.
+
+Index: Source/JavaScriptCore/runtime/CachedTypes.cpp
+--- Source/JavaScriptCore/runtime/CachedTypes.cpp.orig
 Source/JavaScriptCore/runtime/CachedTypes.cpp
+@@ -44,6 +44,10 @@
+ #include 
+ #include 
+ 
++// ports-clang require this:
++#include 
++using ::max_align_t;
++
+ namespace JSC {
+ 
+ template 
+@@ -160,7 +164,7 @@ class Encoder { (private)
+ 
+ bool malloc(size_t size, ptrdiff_t& result)
+ {
+-size_t alignment = std::min(alignof(std::max_align_t), 
static_cast(WTF::roundUpToPowerOfTwo(size)));
++size_t alignment = std::min(alignof(::max_align_t), 
static_cast(WTF::roundUpToPowerOfTwo(size)));
+ ptrdiff_t offset = WTF::roundUpToMultipleOf(alignment, m_offset);
+ size = WTF::roundUpToMultipleOf(alignment, size);
+ if (static_cast(offset + size) > m_capacity)
Index: patches/patch-Source_WTF_wtf_CheckedArithmetic_h
===
RCS file: patches/patch-Source_WTF_wtf_CheckedArithmetic_h
diff -N patches/patch-Source_WTF_wtf_CheckedArithmetic_h
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-Source_WTF_wtf_CheckedArithmetic_h21 Mar 2019 19:02:58 
-
@@ -0,0 +1,52 @@
+$OpenBSD$
+
+macppc linking fix: with ports-clang, libgcc is used instead of compiler-rt,
+and it does not provide the __mulodi4 symbol used by clang for
+__builtin_mul_overflow.
+
+Other !base-clang archs should be added if they can
+go up to the final linking parts.
+
+see https://bugs.webkit.org/show_bug.cgi?id=190208
+
+Index: Source/WTF/wtf/CheckedArithmetic.h
+--- Source/WTF/wtf/CheckedArithmetic.h.orig
 Source/WTF/wtf/CheckedArithmetic.h
+@@ -31,6 +31,10 @@
+ #include 
+ #include 
+ 
++#if COMPILER(GCC_COMPATIBLE) && !(defined(__clang__) && defined(__powerpc__))
++#define USE_MUL_OVERFLOW 1
++#endif
++
+ /* Checked
+  *
+  * This class provides a mechanism to perform overflow-safe integer arithmetic
+@@ -360,7 +364,7 @@ template  struct ArithmeticOperat
+ 
+ static inline bool multiply(int64_t lhs, int64_t rhs, ResultType& result)
+ {
+-#if COMPILER(GCC_COMPATIBLE)
++#if