-
Notifications
You must be signed in to change notification settings - Fork 711
Add support for platform libraries #2540
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
Conversation
Needs documentation. Will take a closer look soon. |
Ah yes, user guide. @edsko and I will do that. |
Also would be nice to have a test. And there's a Travis failure. |
@@ -224,6 +224,7 @@ haddock pkg_descr lbi suffixes flags = do | |||
version | |||
let libArgs' = commonArgs `mappend` libArgs | |||
runHaddock verbosity tmpFileOpts comp confHaddock libArgs' | |||
CPLib _ -> putStrLn "<<haddock CPLib>>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks suspicious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, whoops. Sorry about that. Will fix that (along with your other comments). Not yet sure why Travis is failing though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet sure why Travis is failing though.
Looks like a warning (we use -Werror
on Travis).
Some general comments:
If the problem is that /cc @tibbe -- you might want to comment on this. |
FYI: edsko's implementation here is based on my design. I'm happy to consider other names that make it clearer. Suggestions? "system-library", "native-library", "foreign-library"? As for whether it should be merged with normal libraries, no I think it should be a separate stanza, because it's building a qualitative different artefact. These system libs are inherently less portable, sometimes completely platform specific. They're also for a different purpose, they're not for consumption by more Haskell code, they don't actually export any Haskell symbols (in principle). They're for integration with other foreign code. About other libraries, yes I think we should have "private" Haskell libraries within a package, but I would keep those as portable Haskell libs. |
(Also, compared to "normal" libraries, other library specific flags such as |
These libs also cannot be listed in build-depends in other packages (though in principle could be listed as This new stanza is intended to be extensible with more |
Re: bikeshedding
None of this sounds quite right. "System library" feels like it refers to something like |
Of course, "foreign" doesn't necessary refer to non-Haskell code, we have both foreign imports and foreign exports, and a "platform-library" is typically one that has foreign exports. |
@23Skidoo I'm no claiming foreign is perfect, but the rationale is that it's for consumption by foreign code, the API it presents is an FFI one. |
Yes, "foreign" is probably the least bad sugggestion.
True, but usually unqualified "foreign" means non-Haskell, as in "foreign pointer". |
Such a Haskell-centric view of the world.. oh wait :-P |
I'm happy with "foreign-library" |
I sort of like "foreign export library", but it's a bit long. I looked into how other languages call this, but it appears that there's no accepted/widespread terminology. |
I realized that the naming of the generated library isn't quite right, and we are also missing an implementation of |
Started to look at implementing a test, but had some difficulty getting the existing package tests to work on my system. I've made some changes to the test driver so that they now work; they should also make it easier to modify these tests further later should we need to. However, with 7.4.2 I'm still getting one test error (with or without my changes):
I don't know what that's about. |
@23Skidoo happy enough with |
@dcoutts What do you think about |
Quick poll on |
foreign-library was also my first guess, based on other usage of "foreign" in Haskell. One very slight issue, it supports the perception that Haskellers view the rest of the world with suspicion. Better if it could communicate "Haskell plays nicely with everything". c-library, because library can be used by Haskell code, while this thing can be used by things which know the C ABI. Or portable-library/other-library, because C ABI is too limiting. platform-library is not bad, makes sense to folks who know software dev jargon. It might be read as "the platform we are building on" which might be wrong. native-library seems similar to platform-library, but clearer. It feels more capable and powerful than |
Your test seems to fail with GHC < 7.10 on Linux. |
Darn. Looking at this now. Seems some library paths are different. Bear with me. |
Ugh, what a @£@% mess. I think it should now work on Linux for all versions tested on Travis. Here's what was going wrong (I've also added this as a note in the source code itself): Suppose that the dynamic library depends on
However, on systems (like Ubuntu) where the linker gets called with Then when we attempt to link a C program against this dynamic library, the static linker will attempt to verify that all symbols can be resolved. The dynamic library itself does not require any symbols from Finding the
However, when it comes to resolving the dependency on
This specifies the location of Instead what we can do is make sure that the generated dynamic library has explicit top-level dependencies on these libraries. This means that the static linker knows where to find them, and when we have transitive dependencies on the same libraries the linker will only load them once, so we avoid needing to look at the Note that on older ghc (7.6 and before) the Haskell libraries don't have an RPATH set at all, which makes it even more important that we make these top-level dependencies. Finally, we have to explicitly link against |
So, the official status is now:
7.4 and 7.6 on OSX have some path problems, somewhere in the package DB there are hardcoded references to |
There should be a warning/error if the user tries to build a package containing platform libraries on Windows/OSX with GHC < 7.8. Aside from that, is there anything else to do here besides bikeshedding? |
Looking forward to merging this! |
I probably won't have time to revive this before the 1.24 release, so postponing for 1.26. |
@hvr told me that GHC 8 final will likely be delayed until the end of March, so maybe we'll have time to get this in. |
Just wanted to revive this thread to see if there was a time frame on when this might make it into release? |
I'll milestone it for 2.0, I don't see why we can't merge it for then. |
The conflicts get bigger and bigger. We should try to merge this sooner rather than later. |
Why don't you call it |
Cleaning this up to merge for 2.0. |
Subsumed by #4043. |
So |
To expand previous: Is adding See #4827 |
This PR adds support for building platform libraries. A stanza for a platform library looks something like
where
native-shared
means that we want to build a native shared library (.so
on Linux,.dylib
on OSX,.dll
on Windows). The parser also recognizesnative-static
but this is not currently supported anywhere. Thestandalone
option means that the we merge all library dependencies into the dynamic library (i.e., ghc options-shared -static
), rather than make the created dynamic library just record its dependencies (ghc options-shared -dynamic
); it is currently compulsory on Windows and unsupported anywhere else. Themod-def-file
can be used to specify a module definition file, and is also Windows specific.This probably needs a fairly careful review, in particular in the definition of
gbuild
, which is the oldbuildOrReplExe
and now deals with both executables and platform libraries.Note: there will be a minor clash between this and the independent goals stuff (in particular tracking fine grained dependencies, #2514).
/cc @dcoutts