-
Notifications
You must be signed in to change notification settings - Fork 701
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
Use linker capability detection to improve linker use #9443
Conversation
1e3366c
to
d424287
Compare
1180003
to
e66f226
Compare
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.
LGTM! Feature detection over assumption by proxy!
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.
You still need to add a changelog entry.
609049b
to
b7810b9
Compare
@geekosaur Changelog entry added. |
eec42d8
to
1e3528a
Compare
let linkerSupportsGhciLibs :: Bool | ||
linkerSupportsGhciLibs = | ||
case lookupProgramByName "ld" programDb'' of | ||
Nothing -> True -- NOTE: This may still fail if the linker does not support -r. | ||
Just ld -> | ||
case Map.lookup "Supports relocatable output" $ programProperties ld of | ||
Just "YES" -> True | ||
Just "NO" -> False | ||
_other -> True -- NOTE: This may still fail if the linker does not support -r. |
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.
Sorry to be a PITA 😂
What this function does is checking whether we had previously detected that linker does not support -r
. Am I correct? We use this information to ignore enable-library-for-ghci
further down. I think this should be more explicit.
How about we
- Rename the function to not mention ghci but to mention the linker property (relocatable outputs? is it always
-r
?) - Change the function to return Maybe Bool (as in Yes/No/I don't know).
- Delegate the
fromMaybe True
towithGHCiLib_
Does this sound fair?
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.
Done.
1e3528a
to
9d8b74b
Compare
Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable` flag (with a single `-`). Code will now detect both versions.
`ldProgram` gets configured in two places, a seemingly default and a GHC specific version. The later needs to be updated so that it first calls the default configuration and then the new GHC version.
The function `comperSupportsGhciLibs` has been renamed to `linkerSupportsGhciLibs` because its about the linker not the compiler. The function `comperSupportsGhciLibs` was using the compiler version as a proxy for whether the linker supports relocatable objects. Now support for relocatable objects is detected by running the linker.
9d8b74b
to
53fc3d3
Compare
🎉 🎉 🎉 |
@Mikolaj @Kleidukos could this possibly be backported to 3.10.3.0? |
@Kleidukos calls the shots re 3.10.3.0, but from what I know, it's 5 past midnight, so the PR would need to be backported by somebody else, which involves solving formatting conflicts. Is there a volunteer? It may be best to apply the changes afresh instead of backporting, but let me try an automatic backport just to confirm the conflicts. |
@mergify backport 3.10 |
✅ Backports have been created
|
Cabal currently adds the
-r
(relocatable) flag to some invocations ofldProgram
, butlld
(commonly used on WIndows) does not understand the-r
flag. This PR just detects ifldProgram
accepts-r
during theconfigure
step.Hopefully this far simpler implementation will replace #9270