Blame SOURCES/0001-PATCH-Disable-AVX-instruction-set-on-IA32-and-x86_64.patch

d1fe48
From 99d94682de590719f9333fcf091910a9581b44c0 Mon Sep 17 00:00:00 2001
d1fe48
From: Nigel Croxon <ncroxon@redhat.com>
d1fe48
Date: Thu, 13 Jul 2017 08:43:16 -0400
d1fe48
Subject: [PATCH 01/25] [PATCH] Disable AVX instruction set on IA32 and x86_64
d1fe48
 platforms
d1fe48
d1fe48
If gnu-efi is compiled with "-march=native" on a host that supports AVX, both
d1fe48
gcc and clang will use AVX instructions freely which is currently not supported
d1fe48
and will result in a non-functional gnu-efi build (e.g. black screen, hangs).
d1fe48
d1fe48
For now, disable AVX on IA32 and x86_64 by checking first if the compiler does
d1fe48
actually support the appropriate flag (-mno-avx) and use it if possible.
d1fe48
d1fe48
Credit for the compiler command line to check if a flag is supported goes to
d1fe48
Gentoo's awesome flag-o-matic eclass, where it is taken from. Thanks.
d1fe48
d1fe48
Signed-off-by: Matthias Dahl <matthias.dahl@binary-island.eu>
d1fe48
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
d1fe48
---
d1fe48
 Make.defaults | 8 ++++++++
d1fe48
 1 file changed, 8 insertions(+)
d1fe48
d1fe48
diff --git a/Make.defaults b/Make.defaults
d1fe48
index 16f1fd21848..446e676dc14 100755
d1fe48
--- a/Make.defaults
d1fe48
+++ b/Make.defaults
d1fe48
@@ -120,6 +120,14 @@ ifeq ($(ARCH),x86_64)
d1fe48
   endif
d1fe48
 endif
d1fe48
 
d1fe48
+ifneq (,$(filter $(ARCH),ia32 x86_64))
d1fe48
+  # Disable AVX, if the compiler supports that.
d1fe48
+  CC_CAN_DISABLE_AVX=$(shell $(CC) -Werror -c -o /dev/null -xc -mno-avx - </dev/null >/dev/null 2>&1 && echo 1)
d1fe48
+  ifeq ($(CC_CAN_DISABLE_AVX), 1)
d1fe48
+    CFLAGS += -mno-avx
d1fe48
+  endif
d1fe48
+endif
d1fe48
+
d1fe48
 ifeq ($(ARCH),mips64el)
d1fe48
   CFLAGS += -march=mips64r2
d1fe48
   ARCH3264 = -mabi=64
d1fe48
-- 
d1fe48
2.15.0
d1fe48