haskell / haskell/cabal

Profiling executables which use Template Haskell fails

Open
#5,961 6 comments 1 reaction 0 assignees View on GitHub
documentation
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Repro:

```
$ cat EmbedString.hs
module EmbedString (embedStr) where

import Language.Haskell.TH
import Language.Haskell.TH.Syntax (lift)

embedStr :: IO String -> ExpQ
embedStr readStr = lift =<< runIO readStr
$ cat Main.hs
{-# LANGUAGE TemplateHaskell #-}

import EmbedString (embedStr)

main :: IO ()
main = putStr $(embedStr (readFile "Setup.hs"))
$ cat profth.cabal
cabal-version: 2.0
name: profth
version: 0.1.0.0
build-type: Simple

executable profth
main-is: Main.hs
other-modules: EmbedString
build-depends: base, template-haskell
default-language: Haskell2010
$ cabal new-build --enable-profiling
Resolving dependencies...
Build profile: -w ghc-8.6.4 -O1
In order, the following will be built (use -v for more details):
- profth-0.1.0.0 (exe:profth) --enable-profiling (first run)
Configuring executable 'profth' for profth-0.1.0.0..
Preprocessing executable 'profth' for profth-0.1.0.0..
Building executable 'profth' for profth-0.1.0.0..
[1 of 2] Compiling EmbedString ( EmbedString.hs, /Users/michael/Desktop/profth/dist-newstyle/build/x86_64-osx/ghc-8.6.4/profth-0.1.0.0/x/profth/build/profth/profth-tmp/EmbedString.p_o )
[2 of 2] Compiling Main ( Main.hs, /Users/michael/Desktop/profth/dist-newstyle/build/x86_64-osx/ghc-8.6.4/profth-0.1.0.0/x/profth/build/profth/profth-tmp/Main.p_o )
Main.hs:6:15: fatal:
cannot find object file ‘/Users/michael/Desktop/profth/dist-newstyle/build/x86_64-osx/ghc-8.6.4/profth-0.1.0.0/x/profth/build/profth/profth-tmp/EmbedString.dyn_o’
while linking an interpreted expression
$ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.4
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using profth.cabal, EmbedString.hs, and Main.hs with cabal new-build --enable-profiling. Start by tracing the Template Haskell build and linking step that seeks EmbedString.dyn_o; done means the profiled executable builds successfully without the missing-object error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.