From a424229da7cdf2ffca910ee0dd2af250f62ba5c3 Mon Sep 17 00:00:00 2001
From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date: Mon, 4 Nov 2019 14:18:25 +0100
Subject: [PATCH] For s390x issue a warning if LLVM 9 or older is used

For s390x the GHC calling convention is only supported since LLVM
version 10.  Issue a warning in case an older version of LLVM is used.
---
 compiler/llvmGen/LlvmCodeGen.hs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs
index 49b24e888527..ad6aebeb5a3c 100644
--- a/compiler/llvmGen/LlvmCodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen.hs
@@ -27,6 +27,7 @@ import PprCmm
 
 import BufWrite
 import DynFlags
+import GHC.Platform ( platformArch, Arch(..) )
 import ErrUtils
 import FastString
 import Outputable
@@ -64,6 +65,11 @@ llvmCodeGen dflags h us cmm_stream
            "Currently only " <> text (llvmVersionStr supportedLlvmVersion) <> " is supported." <+>
            "System LLVM version: " <> text (llvmVersionStr ver) $$
            "We will try though..."
+         let isS390X = platformArch (targetPlatform dflags) == ArchS390X
+         let major_ver = head . llvmVersionList $ ver
+         when (isS390X && major_ver < 10 && doWarn) $ putMsg dflags $
+           "Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+>
+           "You are using LLVM version: " <> text (llvmVersionStr ver)
 
        -- run code generation
        a <- runLlvm dflags (fromMaybe supportedLlvmVersion mb_ver) bufh us $
-- 
GitLab