DanielG/ghc-mod

ghc-mod crashes when checking template haskell sources

bonds opened this issue · 4 comments

bonds commented

ghc-mod crashes whenever I try to check a template haskell source file. I can repro it on a vanilla stack project just by adding the template haskell pragma to Main.hs:

~/src ❯❯❯ stack new --resolver lts-6 blue                                   Sun 2017-04-09 20:27:59 -0700
Downloading template "new-template" to create project "blue" in blue/ ...

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/scott/.stack/config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new blue new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- blue/blue.cabal

Selected resolver: lts-6.31
Selected resolver: lts-6.31
Downloaded lts-6.31 build plan.
Fetching package index ...remote: Counting objects: 4161, done.
remote: Compressing objects: 100% (3241/3241), done.
remote: Total 4161 (delta 1141), reused 3429 (delta 821), pack-reused 0
Receiving objects: 100% (4161/4161), 1.26 MiB | 762.00 KiB/s, done.
Resolving deltas: 100% (1141/1141), completed with 519 local objects.
From https://github.com/commercialhaskell/all-cabal-hashes
 - [tag update]      current-hackage -> current-hackage
Fetched package index.
Populated index cache.
Did not find .cabal file for feed-0.3.12.0 with Git SHA of 79ca07db28d5e5b22682b49d5984f921870a0f17
Right Nothing
Initialising configuration using resolver: lts-6.31
Total number of user packages considered: 1
Writing configuration to file: blue/stack.yaml
All done.
~/src ❯❯❯ cd blue                                                           Sun 2017-04-09 20:29:14 -0700
~/s/blue ❯❯❯ ls                                                             Sun 2017-04-09 20:30:23 -0700
LICENSE    README.md  Setup.hs   app        blue.cabal src        stack.yaml test
~/s/blue ❯❯❯ ghc-mod check app/Main.hs                                      Sun 2017-04-09 20:30:24 -0700
blue-0.1.0.0: configure
Configuring blue-0.1.0.0...
~/s/blue ❯❯❯ vim app/Main.hs                                                  Sun 2017-04-09 20:30:41 -0700
~/s/blue ❯❯❯ ghc-mod check app/Main.hs                                      Sun 2017-04-09 20:31:14 -0700
fish: Job 1, 'ghc-mod check app/Main.hs' terminated by signal SIGABRT (Abort)
~/s/blue  [1] ❯❯❯ ghc-mod check app/Main.hs --verbose 7                     Sun 2017-04-09 20:31:33 -0700
DEBUG: reading cache: /home/scott/src/blue/.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/setup-config.ghc-mod.cabal-components
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build","-isrc","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build","-optP-include","-optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp","-iapp","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp","-optP-include","-optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp","-itest","-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen","-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp","-optP-include","-optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint: []
DEBUG: making sure autogen files exist
DEBUG: reading cache: .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/setup-config.ghc-mod.resolved-components
VOMIT: Initializing GHC session with following options: "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-odir" ".stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-hidir" ".stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-stubdir" ".stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-i" "-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp" "-iapp" "-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-isrc" "-i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen" "-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp" "-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen" "-I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build" "-optP-include" "-optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h" "-hide-all-packages" "-no-user-package-db" "-package-db" "/home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb" "-package-db" "/home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb" "-package-id" "base-4.8.2.0-8dd7859ce039df9f3d3f4ff9dbf4bb93" "-XHaskell2010" "-threaded" "-rtsopts" "-with-rtsopts=-N" "-O0"
DEBUG: initSession: Session not initialized, creating new one
DEBUG: loadTargets: Loading: app/Main.hs
info: loadTargets:
      Target needs interpeter, switching to LinkInMemory/HscInterpreted. Perfectly normal if anything isusing TemplateHaskell, QuasiQuotes or PatternSynonyms.
fish: Job 1, 'ghc-mod check app/Main.hs --ver…' terminated by signal SIGABRT (Abort)
~/s/blue  [134] ❯❯❯ gdb (which ghc-mod) ghc-mod.core                        Sun 2017-04-09 20:31:37 -0700
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-unknown-openbsd6.0"...(no debugging symbols found)

Core was generated by `ghc-mod'.
Program terminated with signal 6, Aborted.
Reading symbols from /usr/lib/libpthread.so.22.0...done.
Loaded symbols for /usr/lib/libpthread.so.22.0
Reading symbols from /usr/lib/libutil.so.12.1...done.
Loaded symbols for /usr/lib/libutil.so.12.1
Symbols already loaded for /usr/lib/libpthread.so.22.0
Reading symbols from /usr/local/lib/libiconv.so.6.0...done.
Loaded symbols for /usr/local/lib/libiconv.so.6.0
Reading symbols from /usr/lib/libm.so.9.0...done.
Loaded symbols for /usr/lib/libm.so.9.0
Reading symbols from /usr/lib/libc.so.88.0...done.
Loaded symbols for /usr/lib/libc.so.88.0
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
#0  0x00000002e2ac46ea in _thread_sys___syscall () at <stdin>:2
2       <stdin>: No such file or directory.
        in <stdin>
(gdb) bt
#0  0x00000002e2ac46ea in _thread_sys___syscall () at <stdin>:2
#1  0x00000002e2ae056a in *_libc_mmap (addr=Variable "addr" is not available.
) at /usr/src/lib/libc/sys/mmap.c:47
#2  0x000000000450f0a4 in obscure_ccall_ret_code ()
#3  0x000000000450fad9 in obscure_ccall_ret_code ()
#4  0x0000000002d50046 in ?? ()
#5  0x000000000000000a in ?? ()
#6  0x000000000000000b in ?? ()
#7  0x0000000000000000 in ?? ()
Current language:  auto; currently asm
(gdb) ⏎~
~/s/blue ❯❯❯ ghc-mod debug                                                  Sun 2017-04-09 20:34:51 -0700
Root directory:       /home/scott/src/blue
Current directory:    /home/scott/src/blue
GHC Package flags:
    -fbuilding-cabal-package -O -outputdir
    .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -odir
    .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -hidir
    .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -stubdir
    .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -i
    -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -isrc
    -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
    -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
    -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build
    -optP-include
    -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
    -hide-all-packages -no-user-package-db -package-db
    /home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
    -package-db
    /home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
    -package-id base-4.8.2.0-8dd7859ce039df9f3d3f4ff9dbf4bb93
    -XHaskell2010
GHC System libraries: /usr/local/lib/ghc
GHC user options:

Stack ghc executable:    Just "/usr/local/bin/ghc"
Stack ghc-pkg executable:Just "/usr/local/bin/ghc-pkg"
Cabal file:           Just "/home/scott/src/blue/blue.cabal"
Project:   StackProject (StackEnv {seDistDir = ".stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0", seBinPath = ["/home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/bin","/home/scott/bin","/home/scott/.local/bin","/home/scott/.gocode/bin","/home/scott/.cabal/bin","/home/scott/.gem/ruby/2.3/bin","/usr/local/sbin","/home/scott/.fzf/bin","/home/scott/bin","/home/scott/.local/bin","/home/scott/.gocode/bin","/home/scott/.cabal/bin","/home/scott/.gem/ruby/2.3/bin","/usr/local/sbin","/home/scott/.stack/global-project/.stack-work/install/x86_64-openbsd/lts-6.30/7.10.3/bin","/home/scott/.stack/snapshots/x86_64-openbsd/lts-6.30/7.10.3/bin","/bin","/usr/bin","/sbin","/usr/sbin","/usr/X11R6/bin","/usr/local/bin","/usr/local/sbin","/usr/games","/usr/games"], seSnapshotPkgDb = "/home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb", seLocalPkgDb = "/home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb"})
Cabal entrypoints:
    Setup.hs
        Main (/home/scott/src/blue/Setup.hs)
    library
        Lib (/home/scott/src/blue/src/Lib.hs)
    exe:blue-exe
        Main (/home/scott/src/blue/app/Main.hs)
    test:blue-test
        Main (/home/scott/src/blue/test/Spec.hs)
Cabal components:
    Setup.hs
        Main (/home/scott/src/blue/Setup.hs)
    library
        Lib (/home/scott/src/blue/src/Lib.hs)
    exe:blue-exe
        Main (/home/scott/src/blue/app/Main.hs)
    test:blue-test
        Main (/home/scott/src/blue/test/Spec.hs)
GHC Cabal options:
    Setup.hs
    library
        -fbuilding-cabal-package -O -outputdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -odir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -hidir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -stubdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -i
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -isrc
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
        -hide-all-packages -no-user-package-db -package-db
        /home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-db
        /home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-id base-4.8.2.0-8dd7859ce039df9f3d3f4ff9dbf4bb93
        -XHaskell2010
    exe:blue-exe
        -fbuilding-cabal-package -O -outputdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -odir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -hidir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -stubdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -i
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp
        -iapp -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -isrc
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
        -hide-all-packages -no-user-package-db -package-db
        /home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-db
        /home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-id base-4.8.2.0-8dd7859ce039df9f3d3f4ff9dbf4bb93
        -XHaskell2010 -threaded -rtsopts -with-rtsopts=-N
    test:blue-test
        -fbuilding-cabal-package -O -outputdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -odir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -hidir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -stubdir
        .stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -i
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp
        -itest -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -isrc
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
        -hide-all-packages -no-user-package-db -package-db
        /home/scott/.stack/snapshots/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-db
        /home/scott/src/blue/.stack-work/install/x86_64-openbsd/lts-6.31/7.10.3/pkgdb
        -package-id base-4.8.2.0-8dd7859ce039df9f3d3f4ff9dbf4bb93
        -XHaskell2010 -threaded -rtsopts -with-rtsopts=-N
GHC search path options:
    Setup.hs
    library
        -i -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build -isrc
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
    exe:blue-exe
        -i
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp
        -iapp
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-exe/blue-exe-tmp
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
    test:blue-test
        -i
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp
        -itest
        -i.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen
        -I.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/blue-test/blue-test-tmp
        -optP-include
        -optP.stack-work/dist/x86_64-openbsd/Cabal-1.22.5.0/build/autogen/cabal_macros.h
~
~/s/blue ❯❯❯ cat app/Main.hs                                                Sun 2017-04-09 20:36:57 -0700
{-# LANGUAGE TemplateHaskell #-}

module Main where

import Lib

main :: IO ()
main = someFunc

Looks like a GHC crash to me. Please try loading the Main file with the testcase below. It expects the Main module to be in Main.hs in CWD. You might have to setup the load path which you can do by just passing GHC options to it on the command line.

GhcTestcase.hs:

-- $ ghc -package ghc -package ghc-paths GhcTestcase.hs
module Main where

import GHC
import GHC.Paths (libdir)
import DynFlags

import System.Environment

main :: IO ()
main = do
  args <- getArgs
  defaultErrorHandler defaultFatalMessager defaultFlushOut $
    runGhc (Just libdir) $ do
      dflags0 <- getSessionDynFlags
      let dflags1 = dflags0 {
          ghcMode   = CompManager
        , ghcLink   = LinkInMemory
        , hscTarget = HscInterpreted
        , optLevel  = 0
        }
      (dflags2, _, _) <- parseDynamicFlags dflags1 (map noLoc args)
      _ <- setSessionDynFlags dflags2

      target <- guessTarget "Main.hs" Nothing
      setTargets [target]

      _ <- load LoadAllTargets

      setContext [IIModule $ mkModuleName "Main"]

      return ()
bonds commented

Ok, I tried running that, here's what I got:

~/s/b/app ❯❯❯ ~/Downloads/GhcTestcase                                       Tue 2017-04-11 10:21:33 -0700
fish: '~/Downloads/GhcTestcase' terminated by signal SIGABRT (Abort)
~/s/b/app  [134] ❯❯❯ ls                                                     Tue 2017-04-11 10:21:36 -0700
GhcTestcase.core Main.hs
~/s/b/app ❯❯❯ gdb ~/Downloads/GhcTestcase GhcTestcase.core                  Tue 2017-04-11 10:21:50 -0700
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-unknown-openbsd6.0"...
Core was generated by `GhcTestcase'.
Program terminated with signal 6, Aborted.
Reading symbols from /usr/lib/libpthread.so.22.0...done.
Loaded symbols for /usr/lib/libpthread.so.22.0
Reading symbols from /usr/lib/libutil.so.12.1...done.
Loaded symbols for /usr/lib/libutil.so.12.1
Symbols already loaded for /usr/lib/libpthread.so.22.0
Reading symbols from /usr/local/lib/libiconv.so.6.0...done.
Loaded symbols for /usr/local/lib/libiconv.so.6.0
Reading symbols from /usr/lib/libm.so.9.0...done.
Loaded symbols for /usr/lib/libm.so.9.0
Reading symbols from /usr/lib/libc.so.88.0...done.
Loaded symbols for /usr/lib/libc.so.88.0
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
#0  0x000000023c7866ea in _thread_sys___syscall () at <stdin>:2
2       <stdin>: No such file or directory.
        in <stdin>
(gdb) bt
#0  0x000000023c7866ea in _thread_sys___syscall () at <stdin>:2
#1  0x000000023c7a256a in *_libc_mmap (addr=Variable "addr" is not available.
) at /usr/src/lib/libc/sys/mmap.c:47
#2  0x0000000002fc4154 in mmapForLinker (bytes=Variable "bytes" is not available.
) at rts/Linker.c:2248
#3  0x0000000002fc4b51 in loadObj (
    path=0x2e9724b80 "/usr/local/lib/ghc/ghcpr_8TmvWUcS1U1IKHT0levwg3/HSghc-prim-0.4.0.0-8TmvWUcS1U1IKHT0levwg3.o") at rts/Linker.c:3033
#4  0x0000000001229696 in c50R_info ()
#5  0x0000000000000000 in ?? ()
Current language:  auto; currently asm
(gdb) ⏎
~/s/b/app ❯❯❯ cat Main.hs                                                   Tue 2017-04-11 10:22:15 -0700
{-# LANGUAGE TemplateHaskell #-}

module Main where

main :: IO ()
main = putStrLn "hello, world"

FWIW, Main.hs builds and runs fine:

~/s/b/app ❯❯❯ ghc Main.hs                                                   Tue 2017-04-11 10:23:28 -0700
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking Main ...
/usr/local/lib/ghc/rts/libHSrts.a(RtsUtils.o): In function `showStgWord64':

rts/RtsUtils.c:204:0:
     warning: warning: sprintf() is often misused, please use snprintf()
/usr/local/lib/ghc/rts/libHSrts.a(RtsFlags.o): In function `copyArg':

rts/RtsFlags.c:1685:0:
     warning: warning: strcpy() is almost always misused, please use strlcpy()
~/s/b/app ❯❯❯ ls                                                            Tue 2017-04-11 10:25:54 -0700
GhcTestcase.core Main             Main.hi          Main.hs          Main.o
~/s/b/app ❯❯❯ ./Main                                                        Tue 2017-04-11 10:26:01 -0700
hello, world

Yeah thats a GHC bug then. You should report this bug over here: https://ghc.haskell.org/trac/ghc/wiki/ReportABug.

bonds commented

Done, thanks! Here's the new ticket: https://ghc.haskell.org/trac/ghc/ticket/13574#ticket