Repository navigation
WIP: foreign-library RTS Selection - #5118
TravisWhitaker wants to merge 8 commits into
Conversation
…ce or absence of "-threaded".
|
/cc @edsko |
|
Code looks fine, though the approach of making Would be nice if @dcoutts could provide some input.
Do you think it'll be possible to implement using the same "magic |
|
I agree that it feels hacky, but from the user's perspective it's consistent with with how one would choose the threaded runtime when building other targets, and that outweighs the hackiness in my estimation. An Some of the RTS flavors have existing cabal flags, e.g. |
Naturally |
|
I’ve been thinking about this a bit as well. We used to hack the rts package together as the idea of multiple libraries in a single package just wasn’t representable with cabal until very recently. And even then cabal can’t build the rts, because we do not have a concept of flavours... At this point I wonder if we really need and want this setup, or if we could just have multiple rts packages? We might need backpack though? @ezyang might be able to tell us if we could use backpack here. What we definitely want is to be able to just relink with with a different rts and get profiling/threading,... |
|
I don't think Backpack will work here since you need a module to instantiate a signature and the rts package has no modules. I agree that this is a very strange special case that doesn't fit in the current package model; I'd rather special-case rts (which, btw, is binary compatible between different variants; not true for most packages) than try to work out some general mechanism for selecting one or another. |
|
Thanks @ezyang; yes the rts is a funny library in that respect. This PR has finally brought (and made me understand foreign-library). As I've been adding and using the This then makes me wonder if we really want to replicate any rts-selection logic in cabal, or if we should just not pass the @TravisCardwell did you check what |
|
If no RTS is linked against explicitly then the resulting shared object won't depend on any RTS at load time. This is perfectly reasonable behavior; perhaps downstream I'm building a binary that depends on multiple Haskell shared libraries and I'd like to choose which RTS to link against at that point. A.hs: Yields: With no load-time dependency on any RTS: The argument that GHC should handle RTS selection seems reasonable. It's a little like GCC's |
|
I see. In that case I still believe teaching ghc a |
|
What's the status of this PR, please? Maybe it needs help with something? I am just another user that would like to be able to produce shared libraries with threaded runtime. Regarding points raised before, namely whether |
|
I've been using this PR branch internally for a while without issue. I'd be interested in assembling some sort of consensus around abuse of the Thoughts? |
|
I suggest we do the following:
|
|
Is the only blocker here the need for a clean rebase? |
|
Yes, looks like it. |
|
I'm a little hesitant to destroy this branch, since at least a few people outside of my organization are using it. Perhaps I'll open a fresh PR. |
|
That's fine. |
|
This has been merged, see #5431. |
This PR attempts to address #4815. GHC seems to ignore the "-threaded" flag when "-shared" is used, and one needs to decide which linker flag to use to get the desired RTS flavor. With this change, cabal checks if the "-threaded" flag is provided via ghc-options when building a foreign-library. If it is, we link against the threaded RTS, otherwise we link against the vanilla RTS. The current behavior when "-threaded" is provided is to decide to pass "-lHSrts-ghc***" and "-threaded" to GHC, which confusingly results in a foreign library that's linked against the vanilla RTS even if the user explicitly asks for the threaded one.
It'd be nice hook up the plumbing to link against the other RTS flavors too, but I haven't done enough spelunking to work that out yet.
This is my first time peeking at the Cabal source, so if I've broken some rules please do let me know. This seems to work locally on my machine, but it should be fairly straightforward to test if the tests already include mock builds.
[ci skip]is used to avoid triggering the build bots.