Commit 3640d374 authored by PHO's avatar PHO
Browse files

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.
parent 8b48562e
...@@ -251,6 +251,16 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ...@@ -251,6 +251,16 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
[HaskellHaveSubsectionsViaSymbols=False [HaskellHaveSubsectionsViaSymbols=False
AC_MSG_RESULT(no)]) 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 *** check for GNU non-executable stack note support (ELF only)
dnl (.section .note.GNU-stack,"",@progbits) dnl (.section .note.GNU-stack,"",@progbits)
...@@ -283,6 +293,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ...@@ -283,6 +293,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
AC_SUBST(HaskellTargetArch) AC_SUBST(HaskellTargetArch)
AC_SUBST(HaskellTargetOs) AC_SUBST(HaskellTargetOs)
AC_SUBST(HaskellHaveSubsectionsViaSymbols) AC_SUBST(HaskellHaveSubsectionsViaSymbols)
AC_SUBST(HaskellHaveIdentDirective)
AC_SUBST(HaskellHaveGnuNonexecStack) AC_SUBST(HaskellHaveGnuNonexecStack)
]) ])
......
...@@ -193,6 +193,7 @@ initSysTools mbMinusB ...@@ -193,6 +193,7 @@ initSysTools mbMinusB
; targetArch <- readSetting "target arch" ; targetArch <- readSetting "target arch"
; targetOS <- readSetting "target os" ; targetOS <- readSetting "target os"
; targetHasGnuNonexecStack <- readSetting "target has GNU nonexec stack" ; targetHasGnuNonexecStack <- readSetting "target has GNU nonexec stack"
; targetHasIdentDirective <- readSetting "target has .ident directive"
; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols" ; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
; myExtraGccViaCFlags <- getSetting "GCC extra via C opts" ; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
-- On Windows, mingw is distributed with GHC, -- On Windows, mingw is distributed with GHC,
...@@ -257,6 +258,7 @@ initSysTools mbMinusB ...@@ -257,6 +258,7 @@ initSysTools mbMinusB
platformArch = targetArch, platformArch = targetArch,
platformOS = targetOS, platformOS = targetOS,
platformHasGnuNonexecStack = targetHasGnuNonexecStack, platformHasGnuNonexecStack = targetHasGnuNonexecStack,
platformHasIdentDirective = targetHasIdentDirective,
platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
}, },
sTmpDir = normalise tmpdir, sTmpDir = normalise tmpdir,
......
...@@ -525,12 +525,15 @@ makeImportsDoc dflags imports ...@@ -525,12 +525,15 @@ makeImportsDoc dflags imports
(if platformHasGnuNonexecStack (targetPlatform dflags) (if platformHasGnuNonexecStack (targetPlatform dflags)
then Pretty.text ".section .note.GNU-stack,\"\",@progbits" then Pretty.text ".section .note.GNU-stack,\"\",@progbits"
else Pretty.empty) else Pretty.empty)
Pretty.$$
-- And just because every other compiler does, lets stick in -- And just because every other compiler does, lets stick in
-- an identifier directive: .ident "GHC x.y.z" -- an identifier directive: .ident "GHC x.y.z"
Pretty.$$ let compilerIdent = Pretty.text "GHC" Pretty.<+> (if platformHasIdentDirective (targetPlatform dflags)
Pretty.text cProjectVersion then let compilerIdent = Pretty.text "GHC" Pretty.<+>
in Pretty.text ".ident" Pretty.<+> Pretty.text cProjectVersion
Pretty.doubleQuotes compilerIdent in Pretty.text ".ident" Pretty.<+>
Pretty.doubleQuotes compilerIdent
else Pretty.empty)
where where
-- Generate "symbol stubs" for all external symbols that might -- Generate "symbol stubs" for all external symbols that might
......
...@@ -23,6 +23,7 @@ data Platform ...@@ -23,6 +23,7 @@ data Platform
platformArch :: Arch, platformArch :: Arch,
platformOS :: OS, platformOS :: OS,
platformHasGnuNonexecStack :: Bool, platformHasGnuNonexecStack :: Bool,
platformHasIdentDirective :: Bool,
platformHasSubsectionsViaSymbols :: Bool platformHasSubsectionsViaSymbols :: Bool
} }
deriving (Read, Show, Eq) deriving (Read, Show, Eq)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
("target os", "@HaskellTargetOs@"), ("target os", "@HaskellTargetOs@"),
("target arch", "@HaskellTargetArch@"), ("target arch", "@HaskellTargetArch@"),
("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"), ("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"),
("target has .ident directive", "@HaskellHaveIdentDirective@"),
("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@") ("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")
] ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment