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

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