[commit: ghc] master: Detect cases where as(1) doesn't recognise .ident directive (#5408) (3640d37)

Simon Marlow marlowsd at gmail.com
Fri Dec 9 13:58:34 CET 2011


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

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3640d374f3501c0addb1be273ecc0f10f93be10d

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

commit 3640d374f3501c0addb1be273ecc0f10f93be10d
Author: PHO <pho at cielonegro.org>
Date:   Wed Nov 30 17:46:27 2011 +0900

    Detect cases where as(1) doesn't recognise .ident directive (#5408)
    
    .ident directives are usually ignored by as(1), and in some cases (like Darwin/PPC) they even raise an error.

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

 aclocal.m4                        |   11 +++++++++++
 compiler/main/SysTools.lhs        |    2 ++
 compiler/nativeGen/AsmCodeGen.lhs |   11 +++++++----
 compiler/utils/Platform.hs        |    1 +
 settings.in                       |    1 +
 5 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 4d65e4e..1d5d1f7 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -251,6 +251,16 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
         [HaskellHaveSubsectionsViaSymbols=False
          AC_MSG_RESULT(no)])
 
+    dnl ** check for .ident assembler directive
+
+    AC_MSG_CHECKING(whether your assembler supports .ident directive)
+    AC_COMPILE_IFELSE(
+        [AC_LANG_SOURCE([__asm__ (".ident \"GHC x.y.z\"");])],
+        [AC_MSG_RESULT(yes)
+         HaskellHaveIdentDirective=True],
+        [AC_MSG_RESULT(no)
+         HaskellHaveIdentDirective=False])
+
     dnl *** check for GNU non-executable stack note support (ELF only)
     dnl     (.section .note.GNU-stack,"", at progbits)
 
@@ -283,6 +293,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
     AC_SUBST(HaskellTargetArch)
     AC_SUBST(HaskellTargetOs)
     AC_SUBST(HaskellHaveSubsectionsViaSymbols)
+    AC_SUBST(HaskellHaveIdentDirective)
     AC_SUBST(HaskellHaveGnuNonexecStack)
 ])
 
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 4a51b31..23906c6 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -193,6 +193,7 @@ initSysTools mbMinusB
         ; targetArch <- readSetting "target arch"
         ; targetOS <- readSetting "target os"
         ; targetHasGnuNonexecStack <- readSetting "target has GNU nonexec stack"
+        ; targetHasIdentDirective <- readSetting "target has .ident directive"
         ; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
         ; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
         -- On Windows, mingw is distributed with GHC,
@@ -257,6 +258,7 @@ initSysTools mbMinusB
                                               platformArch = targetArch,
                                               platformOS   = targetOS,
                                               platformHasGnuNonexecStack = targetHasGnuNonexecStack,
+                                              platformHasIdentDirective = targetHasIdentDirective,
                                               platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
                                           },
                         sTmpDir = normalise tmpdir,
diff --git a/compiler/nativeGen/AsmCodeGen.lhs b/compiler/nativeGen/AsmCodeGen.lhs
index 0d8aab1..f9167f2 100644
--- a/compiler/nativeGen/AsmCodeGen.lhs
+++ b/compiler/nativeGen/AsmCodeGen.lhs
@@ -525,12 +525,15 @@ makeImportsDoc dflags imports
             (if platformHasGnuNonexecStack (targetPlatform dflags)
              then Pretty.text ".section .note.GNU-stack,\"\", at progbits"
              else Pretty.empty)
+            Pretty.$$
                 -- And just because every other compiler does, lets stick in
                 -- an identifier directive: .ident "GHC x.y.z"
-            Pretty.$$ let compilerIdent = Pretty.text "GHC" Pretty.<+>
-	                                  Pretty.text cProjectVersion
-                       in Pretty.text ".ident" Pretty.<+>
-                          Pretty.doubleQuotes compilerIdent
+            (if platformHasIdentDirective (targetPlatform dflags)
+             then let compilerIdent = Pretty.text "GHC" Pretty.<+>
+	                              Pretty.text cProjectVersion
+                   in Pretty.text ".ident" Pretty.<+>
+                      Pretty.doubleQuotes compilerIdent
+             else Pretty.empty)
 
  where
 	-- Generate "symbol stubs" for all external symbols that might
diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs
index 027c510..7253af1 100644
--- a/compiler/utils/Platform.hs
+++ b/compiler/utils/Platform.hs
@@ -23,6 +23,7 @@ data Platform
               platformArch                     :: Arch,
               platformOS                       :: OS,
               platformHasGnuNonexecStack       :: Bool,
+              platformHasIdentDirective        :: Bool,
               platformHasSubsectionsViaSymbols :: Bool
           }
         deriving (Read, Show, Eq)
diff --git a/settings.in b/settings.in
index c54fcfb..50062af 100644
--- a/settings.in
+++ b/settings.in
@@ -11,6 +11,7 @@
  ("target os", "@HaskellTargetOs@"),
  ("target arch", "@HaskellTargetArch@"),
  ("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"),
+ ("target has .ident directive", "@HaskellHaveIdentDirective@"),
  ("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")
  ]
 





More information about the Cvs-ghc mailing list