[commit: ghc] ghc-7.10: AsmCodeGen: Ensure LLVM .line directives are sorted (951eec6)

git at git.haskell.org git at git.haskell.org
Thu Oct 22 15:06:44 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/951eec6a826f7db1b83d3639f279efa1dc3f50c5/ghc

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

commit 951eec6a826f7db1b83d3639f279efa1dc3f50c5
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Tue Oct 6 18:29:03 2015 +0200

    AsmCodeGen: Ensure LLVM .line directives are sorted
    
    Apparently some Clang 3.6 expects these to be sorted.
    
    Patch due to Peter Wortmann.
    
    Fixes #10687.


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

951eec6a826f7db1b83d3639f279efa1dc3f50c5
 compiler/nativeGen/AsmCodeGen.hs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs
index 9c57e76..ac657dd 100644
--- a/compiler/nativeGen/AsmCodeGen.hs
+++ b/compiler/nativeGen/AsmCodeGen.hs
@@ -82,6 +82,7 @@ import qualified Stream
 
 import Data.List
 import Data.Maybe
+import Data.Ord         ( comparing )
 import Control.Exception
 #if __GLASGOW_HASKELL__ < 709
 import Control.Applicative (Applicative(..))
@@ -428,12 +429,15 @@ cmmNativeGens dflags this_mod modLoc ncgImpl h dbgMap us
              cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap
                           cmm count
 
-        let newFileIds = fileIds' `minusUFM` fileIds
+        -- Generate .file directives for every new file that has been
+        -- used. Note that it is important that we generate these in
+        -- ascending order, as Clang's 3.6 assembler complains.
+        let newFileIds = sortBy (comparing snd) $ eltsUFM $ fileIds' `minusUFM` fileIds
             pprDecl (f,n) = ptext (sLit "\t.file ") <> ppr n <+>
                             doubleQuotes (ftext f)
 
         emitNativeCode dflags h $ vcat $
-          map pprDecl (eltsUFM newFileIds) ++
+          map pprDecl newFileIds ++
           map (pprNatCmmDecl ncgImpl) native
 
         -- force evaluation all this stuff to avoid space leaks



More information about the ghc-commits mailing list