Store the word size as determined by configure, in the settings file (#5735)
authorSimon Marlow <marlowsd@gmail.com>
Wed, 4 Jan 2012 11:37:47 +0000 (11:37 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 4 Jan 2012 12:47:28 +0000 (12:47 +0000)
Now target32bit works for all targets without any manual intervention,
as it should do.  #5735 was a portability regression.

compiler/main/SysTools.lhs
compiler/utils/Platform.hs
configure.ac
distrib/configure.ac.in
settings.in

index 23906c6..75b4d54 100644 (file)
@@ -192,6 +192,7 @@ initSysTools mbMinusB
                                 Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
         ; targetArch <- readSetting "target arch"
         ; targetOS <- readSetting "target os"
+        ; targetWordSize <- readSetting "target word size"
         ; targetHasGnuNonexecStack <- readSetting "target has GNU nonexec stack"
         ; targetHasIdentDirective <- readSetting "target has .ident directive"
         ; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
@@ -257,6 +258,7 @@ initSysTools mbMinusB
                         sTargetPlatform = Platform {
                                               platformArch = targetArch,
                                               platformOS   = targetOS,
+                                              platformWordSize = targetWordSize,
                                               platformHasGnuNonexecStack = targetHasGnuNonexecStack,
                                               platformHasIdentDirective = targetHasIdentDirective,
                                               platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
index 7253af1..68f46e7 100644 (file)
@@ -22,6 +22,7 @@ data Platform
         = Platform {
               platformArch                     :: Arch,
               platformOS                       :: OS,
+              platformWordSize                 :: {-# UNPACK #-} !Int,
               platformHasGnuNonexecStack       :: Bool,
               platformHasIdentDirective        :: Bool,
               platformHasSubsectionsViaSymbols :: Bool
@@ -77,15 +78,7 @@ data ArmISAExt
 
 
 target32Bit :: Platform -> Bool
-target32Bit p = case platformArch p of
-                ArchUnknown -> panic "Don't know if ArchUnknown is 32bit"
-                ArchX86     -> True
-                ArchX86_64  -> False
-                ArchPPC     -> True
-                ArchPPC_64  -> False
-                ArchSPARC   -> True
-                ArchARM _ _ -> True
-
+target32Bit p = platformWordSize p == 4
 
 -- | This predicates tells us whether the OS supports ELF-like shared libraries.
 osElfTarget :: OS -> Bool
index 8d74707..eda926b 100644 (file)
@@ -574,6 +574,10 @@ fi
 AC_CHECK_SIZEOF(unsigned short,     2)
 AC_CHECK_SIZEOF(void *,             4)
 
+dnl for use in settings.in
+WordSize=$ac_cv_sizeof_void_p
+AC_SUBST(WordSize)
+
 dnl ** what are alignment constraints on various types
 FP_CHECK_ALIGNMENT(char)
 FP_CHECK_ALIGNMENT(double)
index a9fc134..458f5f4 100644 (file)
@@ -90,6 +90,11 @@ FPTOOLS_SET_HASKELL_PLATFORM_VARS
 
 FP_SETTINGS
 
+dnl WordSize for settings.in
+AC_CHECK_SIZEOF(void *, 4)
+WordSize=$ac_cv_sizeof_void_p
+AC_SUBST(WordSize)
+
 #
 dnl ** how to invoke `ar' and `ranlib'
 #
index 50062af..baf04d5 100644 (file)
@@ -10,6 +10,7 @@
  ("perl command", "@SettingsPerlCommand@"),
  ("target os", "@HaskellTargetOs@"),
  ("target arch", "@HaskellTargetArch@"),
+ ("target word size", "@WordSize@"),
  ("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"),
  ("target has .ident directive", "@HaskellHaveIdentDirective@"),
  ("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")