Skip to content
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

[SR-1] Linux: remove Swift dependence on the swift.ld linker script #42627

Closed
jopamer opened this issue Nov 6, 2015 · 8 comments
Closed

[SR-1] Linux: remove Swift dependence on the swift.ld linker script #42627

jopamer opened this issue Nov 6, 2015 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux

Comments

@jopamer
Copy link
Contributor

jopamer commented Nov 6, 2015

Previous ID SR-1
Radar rdar://problem/22724955
Original Reporter @jopamer
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 2
Component/s
Labels Bug, Linux
Assignee None
Priority Medium

md5: 90c6fa571fac13d05c95850bed417233

Issue Description:

Building Swift on Linux currently depends on a linker script to mark protocol conformances. This linker script method is not compatible with the gold linker. We want to support using the gold linker, so come up with another method to achieve this that is compatible with the gold linker.

It seems likely there are at least the following options that seem potentially valid:

  1. We could do some work inside the swift compiler itself as a pre-link step, to collate the protocol conformance data into a single object file. I think we’re ultimately looking for a section of data that we know the size and length of, that contains the conformance data, that can be accessed as a known symbol name at runtime.

  2. Adjust the gold linker to support the symbol collation functionality in ld.bfd that is not in ld.gold. The gold linker is a GPLv3 project.

@octoploid
Copy link
Mannequin

octoploid mannequin commented Dec 4, 2015

Have you opened a binutils bug for this issue?
Cary Coutant normally fixes such issues quickly.
https://sourceware.org/bugzilla/

@octoploid
Copy link
Mannequin

octoploid mannequin commented Dec 4, 2015

@octoploid
Copy link
Mannequin

octoploid mannequin commented Dec 17, 2015

On Linux the following patch works fine, when gold is the default linker:

diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 712ea6581652..df4f2919de46 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1096,6 +1096,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,

// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
// of time the standard library won't be copied.
+  Arguments.push_back("-fuse-ld=bfd");
Arguments.push_back("-Xlinker");
Arguments.push_back("-rpath");
Arguments.push_back("-Xlinker");

@trfiala
Copy link
Mannequin

trfiala mannequin commented Apr 26, 2016

@markus,

Sorry for the late response.

I need to catch up on where this stands now.

> Cary Coutant normally fixes such issues quickly.

Are you suggesting that Cary can add support for linker scripts to the gold linker? We were really only using the linker script to simplify creating a table the aggregates all the protocol conformance data, so the feature we are using from the standard linker is relatively simple.

I've heard we might not be doing that any more, so this might all be moot. If we were mandating the gold linker, then your patch is fine. If not, we'd need to pass along the intent to use the gold linker flag through swiftc (either by any existing linker flag pass-through support, or by enabling a new option).

This is going to become more critical as we try to move to Ubuntu 16.04, where I'm hitting linker relocation issues using the standard linker.

@trfiala
Copy link
Mannequin

trfiala mannequin commented Apr 26, 2016

(I should add this was a bug I filed to track this item in our pre-launch system and Joe was kind enough to reflect it into the public system once we got this up and running, hence my interest here).

@trfiala
Copy link
Mannequin

trfiala mannequin commented Apr 26, 2016

> Are you suggesting that Cary can add support for linker scripts to the gold linker?

Ignore - I followed the thread of what you filed over there. We're on the same page.

Yes, I saw the original bug that was duped to as I was originally looking to see if we could use the same approach for the gold linker that we use for the standard linker. The bug it was duped to was filed a couple years ago.

@hpux735
Copy link
Contributor

hpux735 commented May 2, 2016

I just noticed this bug.

Doesn't this #1157 fix it?

@compnerd
Copy link
Collaborator

compnerd commented May 6, 2018

The alternate approach too has been replaced with another solution that avoids the wrapping entirely. There are no linker scripts in the build now I believe.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux
Projects
None yet
Development

No branches or pull requests

3 participants