-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build --profile fails with cannot find object file that lifts template haskell when no library #2903
Comments
With the EmbedString module in the library both |
Thanks for the report! I can indeed reproduce the issue. Not sure what's going on there. A bit of googling turns up this old cabal issue - haskell/cabal#1207 . While likely not exactly the same issue, it does seem likely that it's an upstream issue with cabal, as we delegate building to it. |
GHC documentation talks about this issue:
So here is a manual workaround for this issue: $ stack build
$ rm .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache
$ stack build --ghc-options="-osuf p_o" --profile
$ stack exec -- simple-exe +RTS -p |
Interesting! Perhaps stack should always do such a double build? Could make compilation take too long for the common case. |
I've run into the same issue when the
Maybe there is a way to detect that a normal build has already been performed for the relevant code in question. Maybe it's possible to just compile the module without profiling that is causing this issue with template haskell. Then after this all modules can be build with profiling. |
Edit: I fixed the issue in my case by setting -rtsopts as ghc-options in my package.yaml. Also have this issue. I get: Cannot find Object file .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/main/main-tmp/Commons.dyn_o, where Commons is a project file using some TH-based lens package functions. |
I've investigated this a bit:
I am able to reproduce this directly against the Cabal library, however.
Going further down the rabbit hole, I see in the |
Alright, this appears to be an upstream issue, either in Cabal or GHC. Closing in favor of haskell/cabal#5961 |
And I remembered the resolution for this problem: can you try adding |
General summary
I can build with
stack build
but withstack build --profile
the build fails withcannot find object file EmbedString.o
when all source files are for the executable. If instead, I have theEmbedString
module in a library, the build succeeds with and without--profile
.I'm following the docs ...
Steps to reproduce
For example:
stack new simple
stack build --profile
. This should work.stack build --profile
fails butstack build
succeeds.For the reproduction steps see stack-profile-embed-string.
The change that introduces the problem, dropping the library.
Expected
That the two commands
stack build
andstack build --profile
either both succeed or both fail.Actual
I can build with
stack build
but withstack build --profile
the build fails withcannot find object file EmbedString.o
.The earlier version with the library in the cabal file doesn't have this problem ...
Stack version
Method of installation
Official binary, downloaded from stackage.org followed by
stack upgrade
.The text was updated successfully, but these errors were encountered: