Bug#1085312: wpewebkit-2.46.1: Fix ./Source/ThirdParty/skia bugs on loong64

Zou Kai zoukai at loongson.cn
Fri Oct 18 08:14:30 BST 2024


Package: wpewebkit
Version: 2.46.1
Severity: normal
Tags: patch
User: debian-loongarch at lists.debian.org
Usertags: loong64

Dear maintainers:
Compiling the wpewebkit-2.46.1 failed for loong64 in the Debian Package 
Auto-Building environment.
Please consider the patch I attached.
Based on the attached patch, I have built wpewebkit-2.46.1 successfully 
on my local ENV.
```
......
libwpewebkit-1.0-doc_2.46.1-1_all.deb
libwpewebkit-2.0-1-dbgsym_2.46.1-1_loong64.deb
libwpewebkit-2.0-1_2.46.1-1_loong64.deb
libwpewebkit-2.0-dev_2.46.1-1_loong64.deb
libwpewebkit-doc_2.46.1-1_all.deb
......
```
This patch is only for fixing skia in the third-party library of the 
current version, we will submit a patch to the skia community soon.
Your opinions are welcome.

Thanks,
Zou Kai



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-webkit-maintainers/attachments/20241018/c7c32cd0/attachment-0001.htm>
-------------- next part --------------
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 wpewebkit (2.46.1-1) unstable; urgency=medium
 .
   * New upstream release.
   * Remove the following patches:
     - prefer-pthread.patch: this should not be needed anymore.
     - reduce-memory-overheads.patch: Override LDFLAGS instead.
   * debian/patches/dont-detect-sse2.patch:
     - Update this patch.
   * Update copyright information of all files.
   * debian/libwpewebkit-2.0-1.symbols:
     - Update symbols.
   * debian/source/lintian-overrides:
     - Update source-is-missing overrides.
   * debian/rules:
     - Remove compiler overrides for sh4 (see #1082305).
     - Stop limiting parallel builds on Ubuntu.
Author: Alberto Garcia <berto at igalia.com>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-10-18

--- wpewebkit-2.46.1.orig/Source/ThirdParty/skia/CMakeLists.txt
+++ wpewebkit-2.46.1/Source/ThirdParty/skia/CMakeLists.txt
@@ -173,6 +173,7 @@ add_library(Skia STATIC
     src/core/SkBitmapProcState_matrixProcs.cpp
     src/core/SkBitmapProcState_opts.cpp
     src/core/SkBitmapProcState_opts_ssse3.cpp
+    src/core/SkBitmapProcState_opts_lasx.cpp
     src/core/SkBlendMode.cpp
     src/core/SkBlendModeBlender.cpp
     src/core/SkBlitMask_opts.cpp
@@ -180,6 +181,7 @@ add_library(Skia STATIC
     src/core/SkBlitRow_D32.cpp
     src/core/SkBlitRow_opts.cpp
     src/core/SkBlitRow_opts_hsw.cpp
+    src/core/SkBlitRow_opts_lasx.cpp
     src/core/SkBlitter.cpp
     src/core/SkBlitter_A8.cpp
     src/core/SkBlitter_ARGB32.cpp
@@ -335,6 +337,7 @@ add_library(Skia STATIC
     src/core/SkSwizzler_opts.cpp
     src/core/SkSwizzler_opts_hsw.cpp
     src/core/SkSwizzler_opts_ssse3.cpp
+    src/core/SkSwizzler_opts_lasx.cpp
     src/core/SkTaskGroup.cpp
     src/core/SkTextBlob.cpp
     src/core/SkTypeface.cpp
@@ -870,6 +873,7 @@ add_library(Skia STATIC
 
     src/opts/SkOpts_hsw.cpp
     src/opts/SkOpts_skx.cpp
+    src/opts/SkOpts_lasx.cpp
 
     src/ports/SkDebug_stdio.cpp
     src/ports/SkFontConfigInterface.cpp
@@ -1022,6 +1026,13 @@ if (WTF_CPU_X86 OR WTF_CPU_X86_64)
     WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE src/opts/SkOpts_skx.cpp "-march=skylake-avx512")
 endif ()
 
+if (WTF_CPU_LOONGARCH64)
+    WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE src/opts/SkOpts_lasx.cpp "-mlasx")
+    WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE src/core/SkBitmapProcState_opts_lasx.cpp "-mlasx")
+    WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE src/core/SkSwizzler_opts_lasx.cpp "-mlasx")
+    WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE src/core/SkBlitRow_opts_lasx.cpp "-mlasx")
+endif ()
+
 if (Skia_SkCMS_HSW_OPTS)
     WEBKIT_ADD_COMPILER_FLAGS(CXX SOURCE modules/skcms/src/skcms_TransformHsw.cc ${Skia_SkCMS_HSW_FLAGS})
 else ()
--- wpewebkit-2.46.1.orig/Source/ThirdParty/skia/src/opts/SkRasterPipeline_opts.h
+++ wpewebkit-2.46.1/Source/ThirdParty/skia/src/opts/SkRasterPipeline_opts.h
@@ -943,22 +943,22 @@ namespace SK_OPTS_NS {
     SI F   abs_  (F v)          { return (F)__lasx_xvand_v((I32)v, (I32)(0-v));     }
     SI I32 abs_(I32 v)          { return max(v, -v);                     }
     SI F   rcp_approx(F v)      { return __lasx_xvfrecip_s(v);           }
-    SI F   rcp_precise (F v)    { F e = rcp_approx(v); return e * nmad(v, e, 2.0f); }
+    SI F   rcp_precise (F v)    { F e = rcp_approx(v); return e * nmad(v, e, F() + 2.0f); }
     SI F   rsqrt_approx (F v)   { return __lasx_xvfrsqrt_s(v);           }
     SI F    sqrt_(F v)          { return __lasx_xvfsqrt_s(v);            }
 
     SI U32 iround(F v) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lasx_xvftintrz_w_s(v + t);
     }
 
     SI U32 round(F v) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lasx_xvftintrz_w_s(v + t);
     }
 
     SI U32 round(F v, F scale) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lasx_xvftintrz_w_s(mad(v, scale, t));
     }
 
@@ -993,8 +993,8 @@ namespace SK_OPTS_NS {
 
     template <typename T>
     SI V<T> gather(const T* p, U32 ix) {
-        return { p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]],
-                 p[ix[4]], p[ix[5]], p[ix[6]], p[ix[7]], };
+        return V<T>{ p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]],
+                     p[ix[4]], p[ix[5]], p[ix[6]], p[ix[7]], };
     }
 
     template <typename V, typename S>
@@ -1147,20 +1147,20 @@ namespace SK_OPTS_NS {
     SI F   abs_(F v)            { return (F)__lsx_vand_v((I32)v, (I32)(0-v));       }
     SI I32 abs_(I32 v)          { return max(v, -v);                     }
     SI F   rcp_approx (F v)     { return __lsx_vfrecip_s(v);             }
-    SI F   rcp_precise (F v)    { F e = rcp_approx(v); return e * nmad(v, e, 2.0f); }
+    SI F   rcp_precise (F v)    { F e = rcp_approx(v); return e * nmad(v, e, F() + 2.0f); }
     SI F   rsqrt_approx (F v)   { return __lsx_vfrsqrt_s(v);             }
     SI F    sqrt_(F v)          { return __lsx_vfsqrt_s (v);             }
 
     SI U32 iround(F v) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lsx_vftintrz_w_s(v + t); }
 
     SI U32 round(F v) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lsx_vftintrz_w_s(v + t); }
 
     SI U32 round(F v, F scale) {
-        F t = F(0.5);
+        F t = F() + 0.5f;
         return __lsx_vftintrz_w_s(mad(v, scale, t)); }
 
     SI U16 pack(U32 v) {
@@ -1196,15 +1196,15 @@ namespace SK_OPTS_NS {
 
     template <typename T>
     SI V<T> gather(const T* p, U32 ix) {
-        return {p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]]};
+        return V<T>{p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]]};
     }
     // Using 'int*' prevents data from passing through floating-point registers.
     SI F   gather(const int*    p, int ix0, int ix1, int ix2, int ix3) {
        F ret = {0.0};
-       ret = __lsx_vinsgr2vr_w(ret, p[ix0], 0);
-       ret = __lsx_vinsgr2vr_w(ret, p[ix1], 1);
-       ret = __lsx_vinsgr2vr_w(ret, p[ix2], 2);
-       ret = __lsx_vinsgr2vr_w(ret, p[ix3], 3);
+       ret = (F)__lsx_vinsgr2vr_w(ret, p[ix0], 0);
+       ret = (F)__lsx_vinsgr2vr_w(ret, p[ix1], 1);
+       ret = (F)__lsx_vinsgr2vr_w(ret, p[ix2], 2);
+       ret = (F)__lsx_vinsgr2vr_w(ret, p[ix3], 3);
        return ret;
     }
 
--- wpewebkit-2.46.1.orig/Source/cmake/WebKitCommon.cmake
+++ wpewebkit-2.46.1/Source/cmake/WebKitCommon.cmake
@@ -127,7 +127,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
         set(WTF_CPU_PPC64 1)
     elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
         set(WTF_CPU_PPC64LE 1)
-    elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
+    elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(^loongarch64|loong64)")
         set(WTF_CPU_LOONGARCH64 1)
     else ()
         set(WTF_CPU_UNKNOWN 1)
--- wpewebkit-2.46.1.orig/Source/cmake/WebKitCompilerFlags.cmake
+++ wpewebkit-2.46.1/Source/cmake/WebKitCompilerFlags.cmake
@@ -146,6 +146,7 @@ if (COMPILER_IS_GCC_OR_CLANG)
     endif ()
 
     WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-fno-strict-aliasing)
+    WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-flax-vector-conversions)
 
     # clang-cl.exe impersonates cl.exe so some clang arguments like -fno-rtti are
     # represented using cl.exe's options and should not be passed as flags, so


More information about the Pkg-webkit-maintainers mailing list