Bug 1977549: Refine -mlasx usage for LoongArch a=RyanVM

To allow running Firefox on processors without LASX (for example
Loongson 2K3000; note that LSX is guaranteed for LoongArch desktop
processors but LASX is not), only use -mlasx on the source files those a
runtime check for LASX guards.

The runtime check is in SkOpts.cpp and it's enabled after removing
-mlasx for this translation unit, if LASX is available at runtime the
code in SkOpts_lasx.cpp will be needed to configure Skia to use LASX.
Thus we need to add SkOpts_lasx.cpp into the list of sources to build.

Original Revision: https://phabricator.services.mozilla.com/D257490

Differential Revision: https://phabricator.services.mozilla.com/D257825
This commit is contained in:
Xi Ruoyao
2025-07-23 03:33:54 +00:00
committed by rvandermeulen@mozilla.com
parent a3995ac4f5
commit 99b2c5786c
2 changed files with 14 additions and 4 deletions

View File

@@ -28,8 +28,6 @@ if CONFIG['MOZ_OPTIMIZE']:
skia_opt_flags += ['-O2']
elif CONFIG['CC_TYPE'] in ('clang', 'gcc'):
skia_opt_flags += ['-O3']
if CONFIG['TARGET_CPU'] == 'loongarch64':
skia_opt_flags += ['-mlasx']
"""
@@ -123,6 +121,13 @@ if CONFIG['TARGET_CPU'] == 'loongarch64':
else:
# gcc, clang8 for loongarch64.
CXXFLAGS += ['-flax-vector-conversions']
SOURCES += ['skia/src/opts/SkOpts_lasx.cpp']
SOURCES['skia/src/opts/SkOpts_lasx.cpp'].flags += skia_opt_flags
SOURCES['skia/src/core/SkBitmapProcState_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/core/SkBlitRow_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/core/SkSwizzler_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/opts/SkOpts_lasx.cpp'].flags += ['-mlasx']
"""
import json

View File

@@ -21,8 +21,6 @@ if CONFIG['MOZ_OPTIMIZE']:
skia_opt_flags += ['-O2']
elif CONFIG['CC_TYPE'] in ('clang', 'gcc'):
skia_opt_flags += ['-O3']
if CONFIG['TARGET_CPU'] == 'loongarch64':
skia_opt_flags += ['-mlasx']
UNIFIED_SOURCES += [
'skia/src/base/SkArenaAlloc.cpp',
@@ -670,3 +668,10 @@ if CONFIG['TARGET_CPU'] == 'loongarch64':
else:
# gcc, clang8 for loongarch64.
CXXFLAGS += ['-flax-vector-conversions']
SOURCES += ['skia/src/opts/SkOpts_lasx.cpp']
SOURCES['skia/src/opts/SkOpts_lasx.cpp'].flags += skia_opt_flags
SOURCES['skia/src/core/SkBitmapProcState_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/core/SkBlitRow_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/core/SkSwizzler_opts_lasx.cpp'].flags += ['-mlasx']
SOURCES['skia/src/opts/SkOpts_lasx.cpp'].flags += ['-mlasx']