Bug#1082740: webkit2gtk-2.46.0: Fix ./Source/ThirdParty/skia compile bugs on loong64
Zou Kai
zoukai at loongson.cn
Wed Sep 25 10:55:34 BST 2024
Package: webkit2gtk
Version: 2.46.0
Severity: normal
Tags: patch
User: debian-loongarch at lists.debian.org
Usertags: loong64
Dear maintainers:
Compiling the webkit2gts-2.46.0 failed for loong64 in the Debian Package
Auto-Building environment.
1. There exists some obvious bugs in ./Source/WTF/wtf/simde/arm/neon.h.
```
92874c92874
< r_.lsx_i64 = __lsx_vfrintrne_s(a_.lsx_f32);
---
> r_.lsx_f32 = __lsx_vfrintrne_s(a_.lsx_f32);
92893c92893
< r_.lsx_i64 = __lsx_vfrintrm_s(a_.lsx_f32);
---
> r_.lsx_f32 = __lsx_vfrintrm_s(a_.lsx_f32);
92912c92912
< r_.lsx_i64 = __lsx_vfrintrp_s(a_.lsx_f32);
---
> r_.lsx_f32 = __lsx_vfrintrp_s(a_.lsx_f32);
92931c92931
< r_.lsx_i64 = __lsx_vfrintrz_s(a_.lsx_f32);
---
> r_.lsx_f32 = __lsx_vfrintrz_s(a_.lsx_f32);
```
2. There exists some compile bugs in ./Source/ThirdParty/skia.
```
/home/webkit2gtk/webkit2gtk-2.46.0/Source/ThirdParty/skia/src/core/SkBlurEngine.cpp:333:22:
error: cannot convert ‘__m128i’ to ‘v4u32’ in initialization
333 | v4u32 sum0 = __lsx_vld(fSum0, 0); // same as
skvx::Vec<4, uint32_t>::Load(fSum0);
| ^~~~~~~~~
| |
| __m128i
/home/webkit2gtk/webkit2gtk-2.46.0/Source/ThirdParty/skia/src/core/SkBlurEngine.cpp:334:22:
error: cannot convert ‘__m128i’ to ‘v4u32’ in initialization
334 | v4u32 sum1 = __lsx_vld(fSum1, 0);
| ^~~~~~~~~
| |
| __m128i
......
```
Please consider the patch I attached.
Based on the attached patch, I have built webkit2gtk-2.46.0 successfully
on my local ENV.
```
......
libwebkitgtk-6.0-4_2.46.0-2_loong64.deb
libwebkitgtk-6.0-dev_2.46.0-2_loong64.deb
libwebkitgtk-doc_2.46.0-2_all.deb
webkit2gtk-2.46.0
webkit2gtk-driver_2.46.0-2_all.deb
webkit2gtk_2.46.0-2.debian.tar.xz
webkit2gtk_2.46.0-2.dsc
webkit2gtk_2.46.0-2_loong64.buildinfo
webkit2gtk_2.46.0-2_loong64.changes
webkit2gtk_2.46.0.orig.tar.xz
webkit2gtk_2.46.0.orig.tar.xz.asc
webkitgtk-webdriver-dbgsym_2.46.0-2_loong64.deb
webkitgtk-webdriver_2.46.0-2_loong64.deb
......
```
Your opinions are welcome.
Thanks,
Zou Kai
-------------- next part --------------
Signed-Off-By: zoukai <zoukai at loongson.cn>
Last-Update: 2024-09-25
--- webkit2gtk-2.46.0.orig/Source/ThirdParty/skia/CMakeLists.txt
+++ webkit2gtk-2.46.0/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
@@ -1035,6 +1039,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 ()
--- webkit2gtk-2.46.0.orig/Source/ThirdParty/skia/src/opts/SkRasterPipeline_opts.h
+++ webkit2gtk-2.46.0/Source/ThirdParty/skia/src/opts/SkRasterPipeline_opts.h
@@ -943,22 +943,26 @@ 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, 2.0f); }
+ SI F rcp_precise (F v) { F e = rcp_approx(v); return e * nmad(v, e, (F){2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 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.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
return __lasx_xvftintrz_w_s(v + t);
}
SI U32 round(F v) {
- F t = F(0.5);
+ //F t = F(0.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
return __lasx_xvftintrz_w_s(v + t);
}
SI U32 round(F v, F scale) {
- F t = F(0.5);
+ //F t = F(0.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
return __lasx_xvftintrz_w_s(mad(v, scale, t));
}
@@ -993,8 +997,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 +1151,24 @@ 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, 2.0f); }
+ SI F rcp_precise (F v) { F e = rcp_approx(v); return e * nmad(v, e, (F){2.0f, 2.0f, 2.0f, 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.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5};
return __lsx_vftintrz_w_s(v + t); }
SI U32 round(F v) {
- F t = F(0.5);
+ //F t = F(0.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5};
return __lsx_vftintrz_w_s(v + t); }
SI U32 round(F v, F scale) {
- F t = F(0.5);
+ //F t = F(0.5);
+ F t = (F){0.5, 0.5, 0.5, 0.5};
return __lsx_vftintrz_w_s(mad(v, scale, t)); }
SI U16 pack(U32 v) {
@@ -1196,15 +1204,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;
}
--- webkit2gtk-2.46.0.orig/Source/WTF/wtf/simde/arm/neon.h
+++ webkit2gtk-2.46.0/Source/WTF/wtf/simde/arm/neon.h
@@ -92871,7 +92871,7 @@ simde_x_mm_round_ps (simde__m128 a, int
#elif defined(SIMDE_ARM_NEON_A32V8_NATIVE)
r_.neon_f32 = vrndnq_f32(a_.neon_f32);
#elif defined(SIMDE_LOONGARCH_LSX_NATIVE)
- r_.lsx_i64 = __lsx_vfrintrne_s(a_.lsx_f32);
+ r_.lsx_f32 = __lsx_vfrintrne_s(a_.lsx_f32);
#elif defined(SIMDE_WASM_SIMD128_NATIVE)
r_.wasm_v128 = wasm_f32x4_nearest(a_.wasm_v128);
#elif defined(simde_math_roundevenf)
@@ -92890,7 +92890,7 @@ simde_x_mm_round_ps (simde__m128 a, int
#elif defined(SIMDE_ARM_NEON_A32V8_NATIVE)
r_.neon_f32 = vrndmq_f32(a_.neon_f32);
#elif defined(SIMDE_LOONGARCH_LSX_NATIVE)
- r_.lsx_i64 = __lsx_vfrintrm_s(a_.lsx_f32);
+ r_.lsx_f32 = __lsx_vfrintrm_s(a_.lsx_f32);
#elif defined(SIMDE_WASM_SIMD128_NATIVE)
r_.wasm_v128 = wasm_f32x4_floor(a_.wasm_v128);
#elif defined(simde_math_floorf)
@@ -92909,7 +92909,7 @@ simde_x_mm_round_ps (simde__m128 a, int
#elif defined(SIMDE_ARM_NEON_A32V8_NATIVE)
r_.neon_f32 = vrndpq_f32(a_.neon_f32);
#elif defined(SIMDE_LOONGARCH_LSX_NATIVE)
- r_.lsx_i64 = __lsx_vfrintrp_s(a_.lsx_f32);
+ r_.lsx_f32 = __lsx_vfrintrp_s(a_.lsx_f32);
#elif defined(SIMDE_WASM_SIMD128_NATIVE)
r_.wasm_v128 = wasm_f32x4_ceil(a_.wasm_v128);
#elif defined(simde_math_ceilf)
@@ -92928,7 +92928,7 @@ simde_x_mm_round_ps (simde__m128 a, int
#elif defined(SIMDE_ARM_NEON_A32V8_NATIVE)
r_.neon_f32 = vrndq_f32(a_.neon_f32);
#elif defined(SIMDE_LOONGARCH_LSX_NATIVE)
- r_.lsx_i64 = __lsx_vfrintrz_s(a_.lsx_f32);
+ r_.lsx_f32 = __lsx_vfrintrz_s(a_.lsx_f32);
#elif defined(SIMDE_WASM_SIMD128_NATIVE)
r_.wasm_v128 = wasm_f32x4_trunc(a_.wasm_v128);
#elif defined(simde_math_truncf)
--- webkit2gtk-2.46.0.orig/Source/cmake/WebKitCommon.cmake
+++ webkit2gtk-2.46.0/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)
--- webkit2gtk-2.46.0.orig/Source/cmake/WebKitCompilerFlags.cmake
+++ webkit2gtk-2.46.0/Source/cmake/WebKitCompilerFlags.cmake
@@ -138,6 +138,7 @@ endif ()
if (COMPILER_IS_GCC_OR_CLANG)
WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-fno-strict-aliasing)
+ WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-flax-vector-conversions)
# Split debug information in ".debug_types" / ".debug_info" sections - this leads
# to a smaller overall size of the debug information, and avoids linker relocation
More information about the Pkg-webkit-maintainers
mailing list