cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Allow-building-with-Clang-too.patch

a83cc2
From 9da71839fdc4e8b9d034998b0ed8a7ee9dfe7645 Mon Sep 17 00:00:00 2001
a83cc2
From: Thomas Huth <thuth@redhat.com>
a83cc2
Date: Sun, 2 May 2021 13:22:21 +0200
a83cc2
Subject: [PATCH 34/39] pc-bios/s390-ccw: Allow building with Clang, too
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Jon Maloy <jmaloy@redhat.com>
a83cc2
RH-MergeRequest: 24: v7:  Add support for building qemu-kvm with clang and safe-stack
a83cc2
RH-Commit: [7/11] d7c510f1e5f6434f6b3e4bab5b5f75403cbc7e1b (jmaloy/qemu-kvm-centos-jon)
a83cc2
RH-Bugzilla: 1939509 1940132
a83cc2
RH-Acked-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
a83cc2
RH-Acked-by: Thomas Huth <thuth@redhat.com>
a83cc2
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a83cc2
a83cc2
Clang unfortunately does not support generating code for the z900
a83cc2
architecture level and starts with the z10 instead. Thus to be able
a83cc2
to support compiling with Clang, we have to check for the supported
a83cc2
compiler flags. The disadvantage is of course that the bios image
a83cc2
will only run with z10 guest CPUs upwards (which is what most people
a83cc2
use anyway), so just in case let's also emit a warning in that case
a83cc2
(we will continue to ship firmware images that have been pre-built
a83cc2
with GCC in future releases, so this should not impact normal users,
a83cc2
too).
a83cc2
a83cc2
Message-Id: <20210502174836.838816-5-thuth@redhat.com>
a83cc2
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a83cc2
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
a83cc2
Signed-off-by: Thomas Huth <thuth@redhat.com>
a83cc2
(cherry picked from commit a5b2afd522dde375c38cf94b7c696ffa3faba2fb)
a83cc2
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 configure                 | 9 ++++++++-
a83cc2
 pc-bios/s390-ccw/Makefile | 3 ++-
a83cc2
 2 files changed, 10 insertions(+), 2 deletions(-)
a83cc2
a83cc2
diff --git a/configure b/configure
a83cc2
index 7edc08afb3..83d8af7fe4 100755
a83cc2
--- a/configure
a83cc2
+++ b/configure
a83cc2
@@ -5424,9 +5424,16 @@ if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
a83cc2
 fi
a83cc2
 
a83cc2
 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
a83cc2
+# or -march=z10 (which is the lowest architecture level that Clang supports)
a83cc2
 if test "$cpu" = "s390x" ; then
a83cc2
   write_c_skeleton
a83cc2
-  if compile_prog "-march=z900" ""; then
a83cc2
+  compile_prog "-march=z900" ""
a83cc2
+  has_z900=$?
a83cc2
+  if [ $has_z900 = 0 ] || compile_prog "-march=z10" ""; then
a83cc2
+    if [ $has_z900 != 0 ]; then
a83cc2
+      echo "WARNING: Your compiler does not support the z900!"
a83cc2
+      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
a83cc2
+    fi
a83cc2
     roms="$roms s390-ccw"
a83cc2
     # SLOF is required for building the s390-ccw firmware on s390x,
a83cc2
     # since it is using the libnet code from SLOF for network booting.
a83cc2
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
a83cc2
index 83fb1afb73..cee9d2c63b 100644
a83cc2
--- a/pc-bios/s390-ccw/Makefile
a83cc2
+++ b/pc-bios/s390-ccw/Makefile
a83cc2
@@ -34,7 +34,8 @@ QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow)
a83cc2
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
a83cc2
 QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
a83cc2
 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
a83cc2
-QEMU_CFLAGS += -msoft-float -march=z900
a83cc2
+QEMU_CFLAGS += -msoft-float
a83cc2
+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10)
a83cc2
 QEMU_CFLAGS += -std=gnu99
a83cc2
 LDFLAGS += -Wl,-pie -nostdlib
a83cc2
 
a83cc2
-- 
a83cc2
2.27.0
a83cc2