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
foreign-libraries break with --enable-profiling #4243
Comments
Similarly, you get lots of linking errors when enabling library profiling on the |
If you add
we get a slightly more sensible error message:
I believe this might make sense: GHC ships with a static variant of every haskell library interface, a dynamic variant, and a profiling variant (this is assuming that the |
So to rephrase this: should we add |
Well, according to the documentation and @edsko's original design, it was also intended that static foreign libraries eventually be supported. I guess there is probably something missing in our build planning, which is when a foreign library is found, we need to plan to build shared versions of all dependencies of that library. Is that actually true? If so, I am a bit surprised this works at all today. |
@ezyang I'm not sure I follow you entirely. In any case, on linux we are now normally using the dynamic interface files to build foreign libraries. So if we enable profiling, we'll need dynamic profiling variants. Now I don't know why GHC would choose static profiling variants instead - perhaps this is a mistake in GHC. |
It seems to me that the build logic for foreign libraries is interacting with some extra logic for profiling. Notice in the logs, GHC is re-building all of the modules because flags changed (you can see this in the original logs when you see The crux of the matter is that when we invoke GHC to link the foreign library, we do so with a command line that looks like this:
Notably,
Here, there is no reference to I think what happens is that when we pass |
(By the way, I found all this info by running |
@ezyang: So does your analysis imply that this could be fixed by passing |
The code that does this is in Distribution.Simple.GHC in |
If I add |
Well, I'm doubtful this is the correct approach, as the current semantics of --enable-profiling --enable-shared seem to be (1) build static with profiling, and (2) build dynamic without profiling. |
Is there any update on this? It's really annoying not being able to profile foreign libraries. |
When I compile a project with
foreign-library
sections with--enable-profiling
ld
complains about impossible relocations when compiling the flib component. I am using Cabal/cabal-install from master.The errors look suspiciously simmilar to the ones from the GHC bug report about Debian/Ubuntu enabling PIE by default, not sure if that's actually related. I'm pretty sure my compilers aren't affected by that since I can also reproduce it in jessie, see below.
To reproduce:
On Debian jessie (using the ghc-7.8.4 bindist):
On Debian sid:
Verbose output with
-v
here: Sid log, Jessie log.The text was updated successfully, but these errors were encountered: