[gimp/wip/nielsdg/conditional-cpu-exts] meson: Always enable CPU extensions
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/nielsdg/conditional-cpu-exts] meson: Always enable CPU extensions
- Date: Tue, 12 May 2020 10:58:20 +0000 (UTC)
commit 57dd1a9f9c46d639aa3555c196e9b4ba10650d24
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 | 5 +-
app/operations/layer-modes/meson.build | 5 +-
libgimpbase/meson.build | 6 ++-
meson.build | 85 ++++++++++++++++------------------
4 files changed, 54 insertions(+), 47 deletions(-)
---
diff --git a/app/gegl/meson.build b/app/gegl/meson.build
index 6cfd438f4a..154e931b33 100644
--- a/app/gegl/meson.build
+++ b/app/gegl/meson.build
@@ -38,6 +38,9 @@ libappgegl = static_library('appgegl',
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Gimp-GEGL"',
dependencies: [
- cairo, gegl, gdk_pixbuf,
+ cairo,
+ gegl,
+ gdk_pixbuf,
+ cpu_exts_dep,
],
)
diff --git a/app/operations/layer-modes/meson.build b/app/operations/layer-modes/meson.build
index 5031c4a344..f5151199ad 100644
--- a/app/operations/layer-modes/meson.build
+++ b/app/operations/layer-modes/meson.build
@@ -22,6 +22,9 @@ libapplayermodes = static_library('applayermodes',
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Gimp-Layer-Modes"',
dependencies: [
- cairo, gegl, gdk_pixbuf,
+ cairo,
+ gegl,
+ gdk_pixbuf,
+ cpu_exts_dep,
],
)
diff --git a/libgimpbase/meson.build b/libgimpbase/meson.build
index a688785df2..fd39cb2af7 100644
--- a/libgimpbase/meson.build
+++ b/libgimpbase/meson.build
@@ -105,7 +105,10 @@ libgimpbase = library('gimpbase-' + gimp_api_version,
libgimpbase_sources,
include_directories: rootInclude,
dependencies: [
- gexiv2, gio, math,
+ gexiv2,
+ gio,
+ math,
+ cpu_exts_dep,
],
c_args: [
'-DG_LOG_DOMAIN="LibGimpBase"',
@@ -127,6 +130,7 @@ executable('test-cpu-accel',
include_directories: rootInclude,
dependencies: [
glib,
+ cpu_exts_dep,
],
c_args: [
'-DG_LOG_DOMAIN="LibGimpBase"',
diff --git a/meson.build b/meson.build
index 304c79fe4f..c401cdcdd1 100644
--- a/meson.build
+++ b/meson.build
@@ -178,56 +178,53 @@ endif
################################################################################
# Compiler CPU extensions for optimizations
+# -- Don't enable these project-wide since some tools, like gtk-doc,
+# will crash on them.
-if (get_option('buildtype') == 'release' or
- get_option('buildtype') == 'debugoptimized')
+cpu_exts_c_args = []
+cpu_exts_link_args = []
- # 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
- endif
+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' },
+]
+
+cpu_exts_c_args += cc.get_supported_arguments(['-mfpmath=sse'])
+foreach cpu_ext : cpu_exts
+ if cc.has_argument(cpu_ext['flag'])
+ cpu_exts_c_args += [ cpu_ext['flag'], cpu_ext['define'] ]
endif
- conf.set('HAVE_ALTIVEC_SYSCTL', have_altivec_sysctl)
- conf.set('USE_ALTIVEC', have_altivec)
+endforeach
+if host_cpu_family == 'ppc'
+ altivec_args = cc.get_supported_arguments([
+ '-faltivec',
+ '-maltivec',
+ '-mabi=altivec',
+ ])
+
+ if altivec_args != []
+ cpu_exts_c_args += altivec_args
+ cpu_exts_link_args += altivec_args
+
+ if host_os.contains('darwin')
+ cpu_exts_c_args += [ '-DUSE_ALTIVEC', '-DHAVE_ALTIVEC_SYSCTL' ]
+ elif cc.compiles('''
+ int main() { asm ("vand %v0, %v0, %v0"); return 0; }
+ ''')
+ cpu_exts_c_args += [ '-DUSE_ALTIVEC' ]
+ endif
+ endif
endif
+# Add this dependency to each target that needs CPU extensions
+cpu_exts_dep = declare_dependency(
+ c_args: cpu_exts_c_args,
+ link_args: cpu_exts_link_args,
+)
+
################################################################################
# CFlags
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]