[gimp/wip/nielsdg/conditional-cpu-exts: 633/633] meson: Always enable CPU extensions
- From: Michael Schumacher <schumaml src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/nielsdg/conditional-cpu-exts: 633/633] meson: Always enable CPU extensions
- Date: Mon, 19 Oct 2020 10:40:10 +0000 (UTC)
commit 779ef4f987a57f9a92fa47755ea6cd4d318105e4
Author: Niels De Graef <nielsdegraef gmail com>
Date: Tue May 12 12:47:00 2020 +0200
meson: Always enable CPU extensions
Don't enable conditionally based on the buildtype.
Further, don't use `add_project_arguments()` to enable the instructions:
this will lead to crashes within g-ir-scanner, which can't properly
parse these instructions.
https://gitlab.gnome.org/GNOME/gimp/-/issues/5053
app/gegl/meson.build | 18 +++++++-
app/operations/layer-modes/meson.build | 40 +++++++++++++++---
libgimpbase/meson.build | 1 +
meson.build | 76 ++++++++++++++--------------------
4 files changed, 83 insertions(+), 52 deletions(-)
---
diff --git a/app/gegl/meson.build b/app/gegl/meson.build
index 6cfd438f4a..60ac76525f 100644
--- a/app/gegl/meson.build
+++ b/app/gegl/meson.build
@@ -16,11 +16,22 @@ appgeglenums = custom_target('gimp-gegl-enums.c',
capture: true,
)
+libappgegl_loops = simd.check('gimp-gegl-loops-simd',
+ sse2: 'gimp-gegl-loops-sse2.c',
+ compiler: cc,
+ include_directories: [ rootInclude, rootAppInclude, ],
+ c_args: cpu_exts_defines,
+ dependencies: [
+ cairo,
+ gegl,
+ gdk_pixbuf,
+ ],
+)
+
libappgegl_sources = [
'gimp-babl-compat.c',
'gimp-babl.c',
'gimp-gegl-apply-operation.c',
- 'gimp-gegl-loops-sse2.c',
'gimp-gegl-loops.cc',
'gimp-gegl-mask-combine.cc',
'gimp-gegl-mask.c',
@@ -35,9 +46,12 @@ libappgegl_sources = [
libappgegl = static_library('appgegl',
libappgegl_sources,
+ link_with: libappgegl_loops[0],
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Gimp-GEGL"',
dependencies: [
- cairo, gegl, gdk_pixbuf,
+ cairo,
+ gegl,
+ gdk_pixbuf,
],
)
diff --git a/app/operations/layer-modes/meson.build b/app/operations/layer-modes/meson.build
index 5031c4a344..109efff547 100644
--- a/app/operations/layer-modes/meson.build
+++ b/app/operations/layer-modes/meson.build
@@ -1,27 +1,55 @@
-libapplayermodes_sources = [
+libapplayermodes_composite = simd.check('gimpoperationlayermode-composite-simd',
+ sse2: 'gimpoperationlayermode-composite-sse2.c',
+ compiler: cc,
+ include_directories: [ rootInclude, rootAppInclude, ],
+ c_args: cpu_exts_defines,
+ dependencies: [
+ cairo,
+ gegl,
+ gdk_pixbuf,
+ ],
+)
+
+libapplayermodes_normal = simd.check('gimpoperationnormal-simd',
+ sse2: 'gimpoperationnormal-sse2.c',
+ sse41: 'gimpoperationnormal-sse4.c',
+ compiler: cc,
+ include_directories: [ rootInclude, rootAppInclude, ],
+ c_args: cpu_exts_defines,
+ dependencies: [
+ cairo,
+ gegl,
+ gdk_pixbuf,
+ ],
+)
+
+libapplayermodes_sources = files(
'gimp-layer-modes.c',
'gimpoperationantierase.c',
'gimpoperationbehind.c',
'gimpoperationdissolve.c',
'gimpoperationerase.c',
'gimpoperationlayermode-blend.c',
- 'gimpoperationlayermode-composite-sse2.c',
'gimpoperationlayermode-composite.c',
'gimpoperationlayermode.c',
'gimpoperationmerge.c',
- 'gimpoperationnormal-sse2.c',
- 'gimpoperationnormal-sse4.c',
'gimpoperationnormal.c',
'gimpoperationpassthrough.c',
'gimpoperationreplace.c',
'gimpoperationsplit.c',
-]
+)
libapplayermodes = static_library('applayermodes',
libapplayermodes_sources,
+ link_with: [
+ libapplayermodes_composite[0],
+ libapplayermodes_normal[0],
+ ],
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Gimp-Layer-Modes"',
dependencies: [
- cairo, gegl, gdk_pixbuf,
+ cairo,
+ gegl,
+ gdk_pixbuf,
],
)
diff --git a/libgimpbase/meson.build b/libgimpbase/meson.build
index a688785df2..0b5d0f1953 100644
--- a/libgimpbase/meson.build
+++ b/libgimpbase/meson.build
@@ -110,6 +110,7 @@ libgimpbase = library('gimpbase-' + gimp_api_version,
c_args: [
'-DG_LOG_DOMAIN="LibGimpBase"',
'-DGIMP_BASE_COMPILATION',
+ cpu_exts_defines,
],
vs_module_defs: 'gimpbase.def',
install: true,
diff --git a/meson.build b/meson.build
index 08caeb0e8f..28e1876c10 100644
--- a/meson.build
+++ b/meson.build
@@ -91,6 +91,7 @@ pkgconfig = import('pkgconfig')
i18n = import('i18n')
gnome = import('gnome')
pythonmod = import('python')
+simd = import('unstable-simd')
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
@@ -178,54 +179,41 @@ endif
################################################################################
# Compiler CPU extensions for optimizations
+# -- Don't enable these project-wide, since some tools like g-ir-scanner,
+# will crash on them.
+
+# Note that Meson has a SIMD module which can also do this for us, but it gives
+# its own #defines and we want to stay backwards compatible with autotools build
+cpu_exts = [
+ { 'flag': '-mmmx', 'define': '-DUSE_MMX' },
+ { 'flag': '-msse', 'define': '-DUSE_SSE' },
+ { 'flag': '-msse2', 'define': '-DCOMPILE_SSE2_INTRINISICS=1' },
+ { 'flag': '-msse4.1', 'define': '-DCOMPILE_SSE4_1_INTRINISICS=1' },
+]
-if (get_option('buildtype') == 'release' or
- get_option('buildtype') == 'debugoptimized')
+cpu_exts_defines = []
+foreach cpu_ext : cpu_exts
+ if cc.has_argument(cpu_ext['flag'])
+ cpu_exts_defines += [ cpu_ext['define'] ]
+ endif
+endforeach
- # Check for compiler CPU extensions
- existing_cpu_exts = [
- '-mfpmath=sse',
- '-mmmx',
- '-msse',
- '-msse2',
- '-msse4.1',
- ]
- supported_cpu_exts = cc.get_supported_arguments(existing_cpu_exts)
-
- compiler_args += supported_cpu_exts
-
- conf.set ('USE_MMX', '-mmmx' in supported_cpu_exts)
- conf.set ('USE_SSE', '-msse' in supported_cpu_exts)
- conf.set10('COMPILE_SSE2_INTRINISICS', '-msse2' in supported_cpu_exts)
- conf.set10('COMPILE_SSE4_1_INTRINISICS','-msse4.1' in supported_cpu_exts)
-
-
- have_altivec = false
- have_altivec_sysctl = false
- if host_cpu_family == 'ppc'
- altivec_args = cc.get_supported_arguments([
- '-faltivec',
- '-maltivec',
- '-mabi=altivec',
- ])
-
- if altivec_args != []
- compiler_args += altivec_args
- linker_args += altivec_args
-
- if host_os.contains('darwin')
- have_altivec = true
- have_altivec_sysctl = true
- elif cc.compiles('''
- int main() { asm ("vand %v0, %v0, %v0"); return 0; }
- ''')
- have_altivec = true
- endif
+if host_cpu_family == 'ppc'
+ altivec_args = cc.get_supported_arguments([
+ '-faltivec',
+ '-maltivec',
+ '-mabi=altivec',
+ ])
+
+ if altivec_args != []
+ if host_os.contains('darwin')
+ cpu_exts_defines += [ '-DUSE_ALTIVEC', '-DHAVE_ALTIVEC_SYSCTL' ]
+ elif cc.compiles('''
+ int main() { asm ("vand %v0, %v0, %v0"); return 0; }
+ ''')
+ cpu_exts_defines += [ '-DUSE_ALTIVEC' ]
endif
endif
- conf.set('HAVE_ALTIVEC_SYSCTL', have_altivec_sysctl)
- conf.set('USE_ALTIVEC', have_altivec)
-
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]