summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2015-10-06 18:29:03 +0200
committerBen Gamari <ben@smart-cactus.org>2015-10-07 08:49:22 +0200
commit36811bfd3bd981d3cd3cc7280e1a815ba1ed42e9 (patch)
tree3a7d27b73a91f5cdb53466148e96b7eb156d4938
parent59883ae370b50f7b59a9bc57b76291fc31937967 (diff)
downloadhaskell-36811bfd3bd981d3cd3cc7280e1a815ba1ed42e9.tar.gz
AsmCodeGen: Ensure LLVM .line directives are sorted
Apparently some Clang 3.6 expects these to be sorted. Patch due to Peter Wortmann. Fixes #10687.
-rw-r--r--compiler/nativeGen/AsmCodeGen.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs
index 2e5caf4b74..2ea63eec47 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