[commit: ghc] master: nativeGen: Fix string merging on Windows (55361b3)

git at git.haskell.org git at git.haskell.org
Thu Dec 8 23:45:12 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/55361b381d14d8752f00d90868fcbe82f86c6b2d/ghc

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

commit 55361b381d14d8752f00d90868fcbe82f86c6b2d
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu Dec 8 16:33:42 2016 -0500

    nativeGen: Fix string merging on Windows
    
    D1290 places string constants in the `.rodata.str` section with `aMS`
    section flags so that the linker can merge them. However, it seems that
    ld doesn't understand these flags. It appears that `gcc
    -fmerge-constants` uses the `dr` flags on Windows. Make GHC do the same.
    
    Test Plan: Validate on Windows
    
    Reviewers: xnyhps, austin, Phyx
    
    Reviewed By: Phyx
    
    Subscribers: thomie, trommler
    
    Differential Revision: https://phabricator.haskell.org/D2797
    
    GHC Trac Issues: #9577


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

55361b381d14d8752f00d90868fcbe82f86c6b2d
 compiler/nativeGen/PprBase.hs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/compiler/nativeGen/PprBase.hs b/compiler/nativeGen/PprBase.hs
index e7feb8a..10ed2fb 100644
--- a/compiler/nativeGen/PprBase.hs
+++ b/compiler/nativeGen/PprBase.hs
@@ -98,16 +98,19 @@ pprGNUSectionHeader t suffix = sdocWithDynFlags $ \dflags ->
   let splitSections = gopt Opt_SplitSections dflags
       subsection | splitSections = char '.' <> ppr suffix
                  | otherwise     = empty
-  in  text ".section " <> ptext header <> subsection
+  in  text ".section " <> ptext (header dflags) <> subsection
   where
-    header = case t of
+    header dflags = case t of
       Text -> sLit ".text"
       Data -> sLit ".data"
       ReadOnlyData -> sLit ".rodata"
       RelocatableReadOnlyData -> sLit ".data.rel.ro"
       UninitialisedData -> sLit ".bss"
       ReadOnlyData16 -> sLit ".rodata.cst16"
-      CString -> sLit ".rodata.str1.1,\"aMS\", at progbits,1"
+      CString
+        | OSMinGW32 <- platformOS (targetPlatform dflags)
+          -> sLit ".rdata,\"dr\""
+        | otherwise -> sLit ".rodata.str1.1,\"aMS\", at progbits,1"
       OtherSection _ ->
         panic "PprBase.pprGNUSectionHeader: unknown section type"
 



More information about the ghc-commits mailing list