fix ghci build on ArchUnknown targets
authorSergei Trofimovich <siarheit@google.com>
Thu, 31 Dec 2015 10:32:40 +0000 (10:32 +0000)
committerSergei Trofimovich <siarheit@google.com>
Thu, 31 Dec 2015 10:38:58 +0000 (10:38 +0000)
Observed failure on ia64 as:

    "inplace/bin/hsc2hs" \
         ... \
         --cflag=-Dia64_HOST_ARCH=1 --cflag=-Dlinux_HOST_OS=1 \
         ... \
         libraries/ghci/./GHCi/InfoTable.hsc \
         -o libraries/ghci/dist-install/build/GHCi/InfoTable.hs

    InfoTable.hsc:84:2: error: #error Unknown architecture

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
libraries/ghci/GHCi/InfoTable.hsc

index 14e1698..0244990 100644 (file)
@@ -56,8 +56,16 @@ type ItblCodes = Either [Word8] [Word32]
 funPtrToInt :: FunPtr a -> Int
 funPtrToInt (FunPtr a) = I## (addr2Int## a)
 
-data Arch = ArchSPARC | ArchPPC | ArchX86 | ArchX86_64 | ArchAlpha | ArchARM
-          | ArchARM64 | ArchPPC64 | ArchPPC64LE
+data Arch = ArchSPARC
+          | ArchPPC
+          | ArchX86
+          | ArchX86_64
+          | ArchAlpha
+          | ArchARM
+          | ArchARM64
+          | ArchPPC64
+          | ArchPPC64LE
+          | ArchUnknown
  deriving Show
 
 platform :: Arch
@@ -81,7 +89,11 @@ platform =
 #elif defined(powerpc64le_HOST_ARCH)
        ArchPPC64LE
 #else
-#error Unknown architecture
+#    if defined(TABLES_NEXT_TO_CODE)
+#        error Unimplemented architecture
+#    else
+       ArchUnknown
+#    endif
 #endif
 
 mkJumpToAddr :: EntryFunPtr -> ItblCodes
@@ -245,6 +257,11 @@ mkJumpToAddr a = case platform of
                    0x618C0000 .|. lo16 w32,
                    0x7D8903A6, 0x4E800420 ]
 
+    -- This code must not be called. You either need to
+    -- add your architecture as a distinct case or
+    -- use non-TABLES_NEXT_TO_CODE mode
+    ArchUnknown -> error "mkJumpToAddr: ArchUnknown is unsupported"
+
 byte0 :: (Integral w) => w -> Word8
 byte0 w = fromIntegral w