[Mesa-dev] [PATCH 1/4] meson: Enable SSE4.1 optimizations
Matt Turner
mattst88 at gmail.com
Fri Nov 17 20:46:03 UTC 2017
On Fri, Nov 17, 2017 at 12:34 PM, Dylan Baker <dylan at pnwbakers.com> wrote:
> Quoting Emil Velikov (2017-11-17 03:11:50)
>> On 16 November 2017 at 22:21, Dylan Baker <dylan at pnwbakers.com> wrote:
>> > Quoting Emil Velikov (2017-11-16 03:35:17)
>> >> Hi Dylan,
>> >>
>> >> On 16 November 2017 at 01:10, Dylan Baker <dylan at pnwbakers.com> wrote:
>> >> > This patch checks for an and then enables sse4.1 optimizations if the
>> >> > host machine will be x86/x86_64.
>> >> >
>> >> Hell yeah, SSE is coming to town :-)
>> >>
>> >> Will this work if the user disables SSE4.1, say via CFLAGS=-mno-sse4.1
>> >> meson ...?
>> >> My meson is still bit rough, so I could not quite grok ^^ by reading
>> >> through the patch.
>> >>
>> >> Thanks
>> >> Emil
>> >
>> > It'll explode horribly. Id didn't see any special handling of that in autotools
>> > build though either, did I miss something?
>> >
>> In autotools it's handled before the normal ld invocation.
>>
>> Namely: configure.ac does:
>> - construct a program using sse4.1 intrinsicts
>> Note: return _mm_...() is required otherwise the whole program will be
>> optimised away
>> - the -msse is passed first and then the user flags (-mno-sse and/or
>> anything else)
>> - the user -mno-sse takes precedence, hence the test program fails to build
>> - set see_supported=false and don't build the SSE optimised static library
>>
>> HTH
>> Emil
>
> That's an interesting question. So arguments passed via CFLAGS and friends will
> be passed to tests, but the arguments passed explicitly to those tests are
> appended, so -msse4.1 will take precedence. I'm also pretty sure there isn't a
> way to check the arguments passed via -Dc_args or CFLAGS (they're treated as
> default arguments, like the c_std in the project() argument). I asked on
> #mesonbuild, but I haven't gotten an answer yet (Fridays are pretty slow
> everywhere).
>
> I think currently the only way to control this would be to have a meson option
> to turn off optimizations, and I really don't like that.
The original bug report of "Mesa doesn't build with -mno-sse4.1" was
in Gentoo's bugzilla; https://bugs.gentoo.org/503828
There's no compelling reason to support that configuration because
since the -msseX flags are off by default... in order for the
-mno-sseX flag to do anything the user must be enabling them somehow
(likely via -march=...). Using -march=... only to disable particular
instruction sets seems pretty idiotic.
I can push back harder on such stupidity in the future if we can't
handle this case, but it would be nice to solve so I never have to
hear about it again.
More information about the mesa-dev
mailing list