From 12fa2d2ac22ef3ddbc8c5efaf55064fe1a19fd29 Mon Sep 17 00:00:00 2001 From: Neha Bhende Date: Thu, 26 Nov 2020 08:47:10 -0800 Subject: [PATCH] meson.build: Use SSE math for MinGW X86 build as per sse2 option This patch adds missing compiler flags to build 32bit driver. It helps to build 32bit using mingw successfully Generated GL driver is tested using piglit, glretrace, conform and some opengl apps Reviewed-by: Brian Paul Reviewed-by: Charmaine Lee Reviewed-by: Jose Fonseca Reviewed-by: Erik Faye-Lund Part-of: --- meson.build | 15 +++++++++++++++ meson_options.txt | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/meson.build b/meson.build index d6cd3136b36..6089a620eaf 100644 --- a/meson.build +++ b/meson.build @@ -1129,6 +1129,21 @@ if host_machine.system() == 'windows' endif endif +if get_option('sse2') and host_machine.system() == 'windows' and host_machine.cpu_family() == 'x86' and cc.get_id() == 'gcc' + # These settings make generated MinGW code match MSVC and follow + # GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note + # + # NOTE: We need to ensure stack is realigned given that we + # produce shared objects, and have no control over the stack + # alignment policy of the application. Therefore we need + # -mstackrealign or -mincoming-stack-boundary=2. + # + # XXX: We could have SSE without -mstackrealign if we always used + # __attribute__((force_align_arg_pointer)), but that's not + # always the case. + c_args += ['-msse', '-msse2', '-mfpmath=sse', '-mstackrealign'] +endif + if host_machine.cpu_family().startswith('x86') and cc.get_id() != 'msvc' pre_args += '-DUSE_SSE41' with_sse41 = true diff --git a/meson_options.txt b/meson_options.txt index 8bc3a228f25..949d7d39774 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -441,3 +441,9 @@ option( value : 'auto', description : 'Use ZSTD instead of ZLIB in some cases.' ) +option( + 'sse2', + type : 'boolean', + value : true, + description : 'use msse2 flag for mingw x86. Default: true', +)