-
Notifications
You must be signed in to change notification settings - Fork 697
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
Update cabal-package.rst w.r.t standalone foreign libs #9320
base: master
Are you sure you want to change the base?
Conversation
doc/cabal-package.rst
Outdated
@@ -1324,6 +1324,7 @@ A typical stanza for a foreign library looks like | |||
lib-version-info: 6:3:2 | |||
|
|||
if os(Windows) | |||
-- standalone *must* be used on Windows. |
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.
What happens otherwise?
doc/cabal-package.rst
Outdated
(``libHSbase``), etc. Currently, ``standalone`` *must* be used on Windows | ||
and *must not* be used on any other platform. | ||
(``libHSbase``), etc. | ||
The ``standalone`` option *must* be used on Windows (FIXME: why? is so why is this not automatic?). |
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.
On Linux, ghc boot packages need to have been compiled with -fPIC
otherwise they won't be able to be statically linked in.
Ah, the good old
|
5375e31
to
568a42b
Compare
@BinderDavid @malteneus Would you mind looking at this from a documentation point-of-view? |
These are some notes from the investigation I did some months ago |
@@ -1356,8 +1357,7 @@ A typical stanza for a foreign library looks like | |||
have any dependencies on other (Haskell) shared libraries; without | |||
the ``standalone`` option the generated library would have dependencies | |||
on the Haskell runtime library (``libHSrts``), the base library | |||
(``libHSbase``), etc. Currently, ``standalone`` *must* be used on Windows | |||
and *must not* be used on any other platform. | |||
(``libHSbase``), etc. The ``standalone`` option *must* be used on Windows. |
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.
Still does not say why this must be used on windows. I mean sure, we do not have dynamic linking on window (for Haskell libraries) at all! So if you do not pass standalone
you end up with only the library you are building, but it lacks all the dependencies. (I think).
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.
It does not say why because I did not know why. What you say sounds reasonable, perhaps we should do some tests.
@@ -1326,6 +1326,7 @@ A typical stanza for a foreign library looks like | |||
lib-version-info: 6:3:2 | |||
|
|||
if os(Windows) | |||
-- standalone *must* be used on Windows. |
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.
-- standalone *must* be used on Windows. | |
-- standalone *must* be used on Windows. See (pkg-field:: options: foreign library option list) |
no idea how to make that a link with rST.
We should probably note that This does highlight an issue I experienced with linking static windows libraries when going from 8.10 to 9.6 (and thus also newer cabal) I think. |
@andreabedini do you see a path forward here? @angerman were all of your comments addressed? |
I have not a slightest idea about foreign libs, I'm sorry to say! |
I found this GHC ticket which seems relevant. |
When describing the
options:
field for foreign libraries, the user guide currenlty says:The phrase "standalone must be used on Windows and must not be used on any other platform" lacks enough details to let the user (or FWIW future contributors :P) understand what the issue is and what happens otherwise.
E.g.
When I tried to produce a standalone library on linux, the only issue I ran into was the old RPATH hack we have since removed (in Remove RPATH workaround #9164). If boot packages are built with
-fPIC
, producing a standalone foreign library seems to work without issues.I do not have any knowledge of what can happen not using standalone on Windows (there's even a runtime assertion so one cannot check without modifying cabal). If it is something intrinsic to linking on window, I am wondering: would it make sense to make this automatic? is it worth having the user explictly write
options: standalone
?The origin of the phrase seems to be Edsko's commit introducing foreign-libraries: 382143a. The commit message does not provide any further explanation other than "it is not supported":
EDIT: what about macOS? We cannot just ignore it.
EDIT 2: AFAIU this just relies on passing the right flags to GHC, so it's GHC doing the linking. In that case, whether it is supported or not is GHC responsibility more than cabal's.