Add "have subsections via symbols" to the Platform type
authorIan Lynagh <igloo@earth.li>
Wed, 19 Oct 2011 15:36:40 +0000 (16:36 +0100)
committerIan Lynagh <igloo@earth.li>
Wed, 19 Oct 2011 15:36:40 +0000 (16:36 +0100)
aclocal.m4
compiler/cmm/CLabel.hs
compiler/main/SysTools.lhs
compiler/nativeGen/PIC.hs
compiler/utils/Platform.hs
configure.ac
settings.in

index df51167..674ba16 100644 (file)
@@ -225,6 +225,20 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
         esac
     }
 
+    dnl ** check for Apple-style dead-stripping support
+    dnl    (.subsections-via-symbols assembler directive)
+
+    AC_MSG_CHECKING(for .subsections_via_symbols)
+    AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
+        [AC_MSG_RESULT(yes)
+         HaskellHaveSubsectionsViaSymbols=True
+         AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
+                   [Define to 1 if Apple-style dead-stripping is supported.])
+        ],
+        [HaskellHaveSubsectionsViaSymbols=False
+         AC_MSG_RESULT(no)])
+
     checkArch "$BuildArch" ""
     checkVendor "$BuildVendor"
     checkOS "$BuildOS" ""
@@ -239,6 +253,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
 
     AC_SUBST(HaskellTargetArch)
     AC_SUBST(HaskellTargetOs)
+    AC_SUBST(HaskellHaveSubsectionsViaSymbols)
 ])
 
 
index a96f78c..717a38a 100644 (file)
@@ -1103,37 +1103,38 @@ asmTempLabelPrefix platform =
 
 pprDynamicLinkerAsmLabel :: Platform -> DynamicLinkerLabelInfo -> CLabel -> SDoc
 pprDynamicLinkerAsmLabel platform dllInfo lbl
- = if platform == Platform ArchX86_64 OSDarwin
-   then case dllInfo of
-        CodeStub        -> char 'L' <> pprCLabel platform lbl <> text "$stub"
-        SymbolPtr       -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
-        GotSymbolPtr    -> pprCLabel platform lbl <> text "@GOTPCREL"
-        GotSymbolOffset -> pprCLabel platform lbl
-   else if platformOS platform == OSDarwin
-   then case dllInfo of
-        CodeStub  -> char 'L' <> pprCLabel platform lbl <> text "$stub"
-        SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
-        _         -> panic "pprDynamicLinkerAsmLabel"
-   else if platformArch platform == ArchPPC && osElfTarget (platformOS platform)
-   then case dllInfo of
-        CodeStub  -> pprCLabel platform lbl <> text "@plt"
-        SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
-        _         -> panic "pprDynamicLinkerAsmLabel"
-   else if platformArch platform == ArchX86_64 && osElfTarget (platformOS platform)
-   then case dllInfo of
-        CodeStub        -> pprCLabel platform lbl <> text "@plt"
-        GotSymbolPtr    -> pprCLabel platform lbl <> text "@gotpcrel"
-        GotSymbolOffset -> pprCLabel platform lbl
-        SymbolPtr       -> text ".LC_" <> pprCLabel platform lbl
+ = if platformOS platform == OSDarwin
+   then if platformArch platform == ArchX86_64
+        then case dllInfo of
+             CodeStub        -> char 'L' <> pprCLabel platform lbl <> text "$stub"
+             SymbolPtr       -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
+             GotSymbolPtr    -> pprCLabel platform lbl <> text "@GOTPCREL"
+             GotSymbolOffset -> pprCLabel platform lbl
+        else case dllInfo of
+             CodeStub  -> char 'L' <> pprCLabel platform lbl <> text "$stub"
+             SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
+             _         -> panic "pprDynamicLinkerAsmLabel"
+
    else if osElfTarget (platformOS platform)
-   then case dllInfo of
-        CodeStub        -> pprCLabel platform lbl <> text "@plt"
-        SymbolPtr       -> text ".LC_" <> pprCLabel platform lbl
-        GotSymbolPtr    -> pprCLabel platform lbl <> text "@got"
-        GotSymbolOffset -> pprCLabel platform lbl <> text "@gotoff"
+        then if platformArch platform == ArchPPC
+             then case dllInfo of
+                  CodeStub  -> pprCLabel platform lbl <> text "@plt"
+                  SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
+                  _         -> panic "pprDynamicLinkerAsmLabel"
+             else if platformArch platform == ArchX86_64
+                  then case dllInfo of
+                       CodeStub        -> pprCLabel platform lbl <> text "@plt"
+                       GotSymbolPtr    -> pprCLabel platform lbl <> text "@gotpcrel"
+                       GotSymbolOffset -> pprCLabel platform lbl
+                       SymbolPtr       -> text ".LC_" <> pprCLabel platform lbl
+        else case dllInfo of
+             CodeStub        -> pprCLabel platform lbl <> text "@plt"
+             SymbolPtr       -> text ".LC_" <> pprCLabel platform lbl
+             GotSymbolPtr    -> pprCLabel platform lbl <> text "@got"
+             GotSymbolOffset -> pprCLabel platform lbl <> text "@gotoff"
    else if platformOS platform == OSMinGW32
-   then case dllInfo of
-        SymbolPtr -> text "__imp_" <> pprCLabel platform lbl
-        _         -> panic "pprDynamicLinkerAsmLabel"
+        then case dllInfo of
+             SymbolPtr -> text "__imp_" <> pprCLabel platform lbl
+             _         -> panic "pprDynamicLinkerAsmLabel"
    else panic "pprDynamicLinkerAsmLabel"
 
index 6f22d1a..0384179 100644 (file)
@@ -191,6 +191,7 @@ initSysTools mbMinusB
                                 Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
         ; targetArch <- readSetting "target arch"
         ; targetOS <- readSetting "target os"
+        ; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
         ; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
         -- On Windows, mingw is distributed with GHC,
         -- so we look in TopDir/../mingw/bin
@@ -252,7 +253,8 @@ initSysTools mbMinusB
         ; return $ Settings {
                         sTargetPlatform = Platform {
                                               platformArch = targetArch,
-                                              platformOS   = targetOS
+                                              platformOS   = targetOS,
+                                              platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
                                           },
                         sTmpDir = normalise tmpdir,
                         sGhcUsagePath = ghc_usage_msg_path,
index da83678..a8f65ba 100644 (file)
@@ -510,7 +510,7 @@ pprGotDeclaration _ _
 -- the splitter in driver/split/ghc-split.lprl recognizes the new output
 
 pprImportedSymbol :: Platform -> CLabel -> Doc
-pprImportedSymbol platform@(Platform ArchPPC OSDarwin) importedLbl
+pprImportedSymbol platform@(Platform { platformArch = ArchPPC, platformOS = OSDarwin }) importedLbl
        | Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
        = case opt_PIC of
            False ->
@@ -564,7 +564,7 @@ pprImportedSymbol platform@(Platform ArchPPC OSDarwin) importedLbl
        = empty
 
                
-pprImportedSymbol platform@(Platform ArchX86 OSDarwin) importedLbl
+pprImportedSymbol platform@(Platform { platformArch = ArchX86, platformOS = OSDarwin }) importedLbl
        | Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
        = case opt_PIC of
            False ->
@@ -617,7 +617,7 @@ pprImportedSymbol platform@(Platform ArchX86 OSDarwin) importedLbl
        = empty
 
 
-pprImportedSymbol (Platform _ OSDarwin) _
+pprImportedSymbol (Platform { platformOS = OSDarwin }) _
        = empty
        
 
@@ -650,12 +650,12 @@ pprImportedSymbol (Platform _ OSDarwin) _
 -- the NCG will keep track of all DynamicLinkerLabels it uses
 -- and output each of them using pprImportedSymbol.
 
-pprImportedSymbol (Platform ArchPPC_64 os) _
-       | osElfTarget os
+pprImportedSymbol platform@(Platform { platformArch = ArchPPC_64 }) _
+       | osElfTarget (platformOS platform)
        = empty
 
-pprImportedSymbol platform@(Platform _ os) importedLbl
-       | osElfTarget os
+pprImportedSymbol platform importedLbl
+       | osElfTarget (platformOS platform)
        = case dynamicLinkerLabelInfo importedLbl of
            Just (SymbolPtr, lbl)
              -> let symbolSize = case wordWidth of
index 373c7be..89d98e6 100644 (file)
@@ -19,9 +19,11 @@ import Panic
 -- | Contains enough information for the native code generator to emit
 --      code for this platform.
 data Platform
-        = Platform
-        { platformArch  :: Arch
-        , platformOS    :: OS }
+        = Platform {
+              platformArch                     :: Arch,
+              platformOS                       :: OS,
+              platformHasSubsectionsViaSymbols :: Bool
+          }
         deriving (Read, Show, Eq)
 
 
index efd2f26..f10b31f 100644 (file)
@@ -703,19 +703,6 @@ FP_PROG_LD_X
 FP_PROG_LD_IS_GNU
 FP_PROG_LD_BUILD_ID
 
-dnl ** check for Apple-style dead-stripping support
-dnl    (.subsections-via-symbols assembler directive)
-
-
-AC_MSG_CHECKING(for .subsections_via_symbols)
-AC_COMPILE_IFELSE(
-    [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
-    [AC_MSG_RESULT(yes)
-     AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
-               [Define to 1 if Apple-style dead-stripping is supported.])
-    ],
-    [AC_MSG_RESULT(no)])
-
 dnl *** check for GNU non-executable stack note support (ELF only)
 dnl     (.section .note.GNU-stack,"",@progbits)
 
index 6d0bd3d..ef65651 100644 (file)
@@ -9,6 +9,7 @@
  ("windres command", "@SettingsWindresCommand@"),
  ("perl command", "@SettingsPerlCommand@"),
  ("target os", "@HaskellTargetOs@"),
- ("target arch", "@HaskellTargetArch@")
+ ("target arch", "@HaskellTargetArch@"),
+ ("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")
  ]