[commit: ghc] ghc-7.10: Dump files always use UTF8 encoding #10762 (dedc2f3)

git at git.haskell.org git at git.haskell.org
Thu Oct 22 15:07:55 UTC 2015


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

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

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

commit dedc2f3dc3d3ebbb8471ebd7fff599e52925aa4f
Author: Michael Snoyman <michael at snoyman.com>
Date:   Tue Aug 18 17:58:36 2015 +0200

    Dump files always use UTF8 encoding #10762
    
    When the Windows codepage or *nix LANG variable is something besides
    UTF-8, dumping to file can cause GHC to exit currently. This changes the
    output encoding for files to match the defined input encoding for
    Haskell source code (UTF-8), making it easier for users and build tools
    to capture this output.
    
    Test Plan:
    Create a Haskell source file with non-Latin characters for identifier
    names and
    compile with:
    
    LANG=C ghc -ddump-to-file -ddump-hi filename.hs -fforce-recomp
    
    Without this patch, it will fail. With this patch, it succeeds
    
    Reviewers: austin, rwbarton, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1151
    
    GHC Trac Issues: #10762


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

dedc2f3dc3d3ebbb8471ebd7fff599e52925aa4f
 compiler/main/ErrUtils.hs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs
index 6dbf60a..2a3b4c7 100644
--- a/compiler/main/ErrUtils.hs
+++ b/compiler/main/ErrUtils.hs
@@ -291,6 +291,13 @@ dumpSDoc dflags print_unqual flag hdr doc
                             writeIORef gdref (Set.insert fileName gd)
                         createDirectoryIfMissing True (takeDirectory fileName)
                         handle <- openFile fileName mode
+
+                        -- We do not want the dump file to be affected by
+                        -- environment variables, but instead to always use
+                        -- UTF8. See:
+                        -- https://ghc.haskell.org/trac/ghc/ticket/10762
+                        hSetEncoding handle utf8
+
                         doc' <- if null hdr
                                 then return doc
                                 else do t <- getCurrentTime



More information about the ghc-commits mailing list