-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Fix issue #3795 - Fix LDC linked dynamically with Phobos and DRuntime when built with GDMD. #3810
Open
dbankov-vmware
wants to merge
1
commit into
ldc-developers:master
Choose a base branch
from
dbankov-vmware:fix-for-3795
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So what you are describing is something specific to Debian and all its derivatives (Ubuntu, etc...)
https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-9-debian/debian/patches/gdc-dynamic-link-phobos.diff
There exists the driver option
-static-libphobos
which covers what looks to be your intent for messing around with-Bdynamic
and-Bstatic
.So you can simplify this as just
-static-libphobos -Wl,--allow-multiple-definition
.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.
@ibuclaw I'm building GDC from the source in GCC 9.3 and if used directly my GDC version links both Phobos and DRuntime statically by default.
The problem occurs only when building LDC because when
-DLDC_LINK_MANUALLY=ON
(which is the default for GDMD) instead of calling GDMD for linking LDC build script calls CXX for linking. Now to make sure that the correct libraries (phobos and druntime) are linked by CXX, LDC build script extracts the link line from a call to GDMD with-v
and then copies all arguments which start with-L
,-l
and-B
in a list which is later passed to CXX. The problem here is that for GDMD the link line reported by-v
is what is passed to COLLECT2 (which are practically parameters passed to LD) and then when LDC build script passes these directly to CXX only parameters starting with-L
and-l
are honoured while these starting with-B
are simply dropped. The result is that although the link line reported by GDMD contains-Bstatic
before-lgphobos
and-lgdruntime
and-Bdynamic
after these when CXX is linking LDC it drops the parameters starting-B
and LDC ends up being linked dynamically with Phobos and DRuntime. What was needed was for parameters starting with-B
from the link line reported by GDMD to be prepended with-Wl,
in LDC build script so when these are passed to CXX it to correctly redirect them to LD.