Skip to content

Commit

Permalink
Build with GHC 9.4.1 on llvm-12 branch.
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <sighingnow@gmail.com>
  • Loading branch information
sighingnow committed Nov 5, 2022
1 parent 423220b commit a0db9e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm-hs-pure/llvm-hs-pure.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ library
build-depends:
base >= 4.9 && < 5,
attoparsec >= 0.13,
bytestring >= 0.10 && < 0.11,
bytestring >= 0.10 && < 0.12,
fail,
transformers >= 0.3 && < 0.6,
mtl >= 2.1,
Expand Down
2 changes: 1 addition & 1 deletion llvm-hs-pure/src/LLVM/IRBuilder/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Control.Monad.Fail (MonadFail)
#endif

import Data.Bifunctor
import Data.ByteString.Short as BS
import Data.ByteString.Short (ShortByteString)
import Data.Char
import Data.Data
import Data.Foldable
Expand Down
2 changes: 1 addition & 1 deletion llvm-hs-pure/src/LLVM/Triple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Control.Monad.Trans.Except
import Data.Attoparsec.ByteString
import Data.Attoparsec.ByteString.Char8
import Data.ByteString.Char8 as ByteString hiding (map, foldr)
import Data.ByteString.Short hiding (pack)
import Data.ByteString.Short hiding (pack, foldr)

import Data.Map (Map, (!))
import qualified Data.Map as Map
Expand Down
6 changes: 6 additions & 0 deletions llvm-hs/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import System.Environment
#if MIN_VERSION_Cabal(2,0,0)
#define MIN_VERSION_Cabal_2_0_0
#endif
#if MIN_VERSION_Cabal(3,8,1)
#define MIN_VERSION_Cabal_3_8_1
#endif
#endif

-- define these selectively in C files (we are _not_ using HsFFI.h),
Expand Down Expand Up @@ -171,6 +174,9 @@ main = do
#endif
PreProcessor {
platformIndependent = platformIndependent (origHsc buildInfo),
#ifdef MIN_VERSION_Cabal_3_8_1
ppOrdering = \_ _ modules -> pure modules,
#endif
runPreProcessor = \inFiles outFiles verbosity -> do
llvmConfig <- getLLVMConfig (configFlags localBuildInfo)
llvmCFlags <- do
Expand Down
15 changes: 13 additions & 2 deletions llvm-hs/src/LLVM/Internal/Operand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,19 @@ instance EncodeM EncodeAST A.DILocalVariable (Ptr FFI.DILocalVariable) where

instance EncodeM EncodeAST A.DITemplateParameter (Ptr FFI.DITemplateParameter) where
encodeM p = do
name' <- encodeM (A.name (p :: A.DITemplateParameter)) :: EncodeAST (Ptr FFI.MDString)
ty <- encodeM (A.type' (p :: A.DITemplateParameter))
-- As of GHC 9.4.1, selector names have to be entirely unambiguous (under the
-- usual name resolution rules)
-- However, this type is ambiguous for reason not yet understood.
-- One solution would be to use OverloadedRecordDot, using p.name and p.type',
-- but it requires GHC 9.2.
-- The solution here is to just extract the values
--
-- (Referred from: https://github.com/llvm-hs/llvm-hs/pull/406)
let (name, type') = case p of
A.DITemplateTypeParameter{name, type'} -> (name, type')
A.DITemplateValueParameter{name, type'} -> (name, type')
name' <- encodeM name :: EncodeAST (Ptr FFI.MDString)
ty <- encodeM type'
Context c <- gets encodeStateContext
case p of
A.DITemplateTypeParameter {} ->
Expand Down

0 comments on commit a0db9e9

Please sign in to comment.