[commit: ghc] ghc-7.4: Store the word size as determined by configure, in the settings file (#5735) (cd0df38)

Ian Lynagh igloo at earth.li
Fri Jan 6 14:20:21 CET 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : ghc-7.4

http://hackage.haskell.org/trac/ghc/changeset/cd0df384950a6e31a4e0e9843e907202bc6e03f9

>---------------------------------------------------------------

commit cd0df384950a6e31a4e0e9843e907202bc6e03f9
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Jan 4 11:37:47 2012 +0000

    Store the word size as determined by configure, in the settings file (#5735)
    
    Now target32bit works for all targets without any manual intervention,
    as it should do.  #5735 was a portability regression.

>---------------------------------------------------------------

 compiler/main/SysTools.lhs |    2 ++
 compiler/utils/Platform.hs |   11 ++---------
 configure.ac               |    4 ++++
 distrib/configure.ac.in    |    5 +++++
 settings.in                |    1 +
 5 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 4a51b31..b3c8826 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -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"
         ; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
         ; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
@@ -256,6 +257,7 @@ initSysTools mbMinusB
                         sTargetPlatform = Platform {
                                               platformArch = targetArch,
                                               platformOS   = targetOS,
+                                              platformWordSize = targetWordSize,
                                               platformHasGnuNonexecStack = targetHasGnuNonexecStack,
                                               platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
                                           },
diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs
index 027c510..89c79eb 100644
--- a/compiler/utils/Platform.hs
+++ b/compiler/utils/Platform.hs
@@ -22,6 +22,7 @@ data Platform
         = Platform {
               platformArch                     :: Arch,
               platformOS                       :: OS,
+              platformWordSize                 :: {-# UNPACK #-} !Int,
               platformHasGnuNonexecStack       :: Bool,
               platformHasSubsectionsViaSymbols :: Bool
           }
@@ -76,15 +77,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
diff --git a/configure.ac b/configure.ac
index a3ab391..ca05138 100644
--- a/configure.ac
+++ b/configure.ac
@@ -576,6 +576,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)
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index a9fc134..458f5f4 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -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'
 #
diff --git a/settings.in b/settings.in
index c54fcfb..c2c2ec5 100644
--- a/settings.in
+++ b/settings.in
@@ -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 subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")
  ]





More information about the Cvs-ghc mailing list