Commit 71aca77c authored by Erik de Castro Lopo's avatar Erik de Castro Lopo Committed by Marge Bot

Fixes for LLVM 7

LLVM version numberinf changed recently. Previously, releases were numbered
4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0".

Fix requires for Llvm detection and some code.
parent 9bbcc3be
Pipeline #7527 failed with stages
in 148 minutes and 26 seconds
......@@ -3,7 +3,7 @@
-- -----------------------------------------------------------------------------
-- | This is the top-level module in the LLVM code generator.
--
module LlvmCodeGen ( llvmCodeGen, llvmFixupAsm ) where
module LlvmCodeGen ( LlvmVersion (..), llvmCodeGen, llvmFixupAsm ) where
#include "HsVersions.h"
......
......@@ -13,7 +13,7 @@ module LlvmCodeGen.Base (
LiveGlobalRegs,
LlvmUnresData, LlvmData, UnresLabel, UnresStatic,
LlvmVersion, supportedLlvmVersion, llvmVersionStr,
LlvmVersion (..), supportedLlvmVersion, llvmVersionStr,
LlvmM,
runLlvm, liftStream, withClearVars, varLookup, varInsert,
......@@ -177,14 +177,25 @@ llvmPtrBits dflags = widthInBits $ typeWidth $ gcWord dflags
--
-- | LLVM Version Number
type LlvmVersion = (Int, Int)
data LlvmVersion
= LlvmVersion Int
| LlvmVersionOld Int Int
deriving Eq
-- Custom show instance for backwards compatibility.
instance Show LlvmVersion where
show (LlvmVersion maj) = show maj
show (LlvmVersionOld maj min) = show maj ++ "." ++ show min
-- | The LLVM Version that is currently supported.
supportedLlvmVersion :: LlvmVersion
supportedLlvmVersion = sUPPORTED_LLVM_VERSION
supportedLlvmVersion = LlvmVersion sUPPORTED_LLVM_VERSION
llvmVersionStr :: LlvmVersion -> String
llvmVersionStr (major, minor) = show major ++ "." ++ show minor
llvmVersionStr v =
case v of
LlvmVersion maj -> show maj
LlvmVersionOld maj min -> show maj ++ "." ++ show min
-- ----------------------------------------------------------------------------
-- * Environment Handling
......
......@@ -56,7 +56,7 @@ import StringBuffer ( hGetStringBuffer, hPutStringBuffer )
import BasicTypes ( SuccessFlag(..) )
import Maybes ( expectJust )
import SrcLoc
import LlvmCodeGen ( llvmFixupAsm )
import LlvmCodeGen ( LlvmVersion (..), llvmFixupAsm )
import MonadUtils
import GHC.Platform
import TcRnTypes
......@@ -2038,7 +2038,8 @@ getBackendDefs :: DynFlags -> IO [String]
getBackendDefs dflags | hscTarget dflags == HscLlvm = do
llvmVer <- figureLlvmVersion dflags
return $ case llvmVer of
Just n -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format n ]
Just (LlvmVersion n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (n,0) ]
Just (LlvmVersionOld m n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m,n) ]
_ -> []
where
format (major, minor)
......
......@@ -23,7 +23,7 @@ import System.IO
import System.Process
import GhcPrelude
import LlvmCodeGen.Base (llvmVersionStr, supportedLlvmVersion)
import LlvmCodeGen.Base (LlvmVersion (..), llvmVersionStr, supportedLlvmVersion)
import SysTools.Process
import SysTools.Info
......@@ -200,7 +200,7 @@ runClang dflags args = do
)
-- | Figure out which version of LLVM we are running this session
figureLlvmVersion :: DynFlags -> IO (Maybe (Int, Int))
figureLlvmVersion :: DynFlags -> IO (Maybe LlvmVersion)
figureLlvmVersion dflags = do
let (pgm,opts) = pgm_lc dflags
args = filter notNull (map showOpt opts)
......@@ -222,8 +222,10 @@ figureLlvmVersion dflags = do
vline <- dropWhile (not . isDigit) `fmap` hGetLine pout
v <- case span (/= '.') vline of
("",_) -> fail "no digits!"
(x,y) -> return (read x
, read $ takeWhile isDigit $ drop 1 y)
(x,"") -> return $ LlvmVersion (read x)
(x,y) -> return $ LlvmVersionOld
(read x)
(read $ takeWhile isDigit $ drop 1 y)
hClose pin
hClose pout
......
......@@ -628,7 +628,7 @@ AC_SUBST([LibtoolCmd])
# tools we are looking for. In the past, GHC supported a number of
# versions of LLVM simultaneously, but that stopped working around
# 3.5/3.6 release of LLVM.
LlvmVersion=7.0
LlvmVersion=7
AC_SUBST([LlvmVersion])
sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
......
  • mentioned in merge request !1250 (closed)

    Toggle commit list
  • mentioned in commit 7a889cdd

    Toggle commit list
  • mentioned in commit a02172be

    Toggle commit list
  • mentioned in commit 8dd80930

    Toggle commit list
  • mentioned in issue #16912 (closed)

    Toggle commit list
  • I think I need to revert this change on Fedora, since it breaks llvm-7.0 detection in ghc-8.8.1 RC1.

    It would be better if we could detect both llvm-7 and llvm-7.0, etc

    http://releases.llvm.org/

    When I tried just changing LlvmVersion back to 7.0 I got:

    BUILDSTDERR: echo 'export LD_LIBRARY_PATH="/builddir/build/BUILD/ghc-8.8.0.20190721/libraries/terminfo/dist-boot/build:/builddir/build/BUILD/ghc-8.8.0.20190721/libraries/ghc-boot/dist-boot/build:/builddir/build/BUILD/ghc-8.8.0.20190721/libraries/ghc-boot-th/dist-boot/build:/builddir/build/BUILD/ghc-8.8.0.20190721/libraries/Cabal/Cabal/dist-boot/build:/usr/lib/ghc
    BUILDSTDERR: compiler/llvmGen/LlvmCodeGen/Base.hs:191:36: error:
    BUILDSTDERR:     • Couldn't match expected type ‘Int’
    BUILDSTDERR:                   with actual type ‘(Integer, Integer)’
    BUILDSTDERR:     • In the first argument of ‘LlvmVersion’, namely ‘(7, 0)’
    BUILDSTDERR:       In the expression: LlvmVersion (7, 0)
    BUILDSTDERR:       In an equation for ‘supportedLlvmVersion’:
    BUILDSTDERR:           supportedLlvmVersion = LlvmVersion (7, 0)
    BUILDSTDERR:     |
    BUILDSTDERR: 191 | supportedLlvmVersion = LlvmVersion sUPPORTED_LLVM_VERSION
    BUILDSTDERR:     |                                    ^^^^^
    BUILDSTDERR: <<ghc: 100046092 bytes, 38 GCs, 6401122/13617328 avg/max bytes residency (5 samples), 34M in use, 0.003 INIT (0.003 elapsed), 0.666 MUT (0.759 elapsed), 0.599 GC (0.619 elapsed) :ghc>>
    BUILDSTDERR: make[1]: *** [compiler/ghc.mk:444: compiler/stage1/build/LlvmCodeGen/Base.o] Error 1
    Edited by Jens Petersen
  • The version numbering I was following is the version numbering that is use both upstream and in Debian. For some reason Fedora chose to do something different to upstream.

  • Does upstream really version bindir/llc and bindir/opt? I haven't seen that.

  • mentioned in issue #16990 (closed)

    Toggle commit list
  • The way this is supposed to work is that it tests for the existence of the versioned binaries first and if that fails, tries the un-versioned ones to see if they are compatible.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment