Skip to content

utils: require gold on Linux targets #2609

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

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,11 @@ std::string toolchains::GenericUnix::getDefaultLinker() const {
// final executables, as such, unless specified, we default to gold
// linker.
return "gold";
case llvm::Triple::x86_64:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
// BFD linker has issues wrt relocations against protected symbols.
return "gold";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of what this change is proposing to do, switch to the gold linker by default on Linux, it might be worthwhile to wholly re-write this code.

What I mean is the default should be "gold" and then any thing that wants different should opt-out. Something more like:

std::string toolchains::GenericUnix::getDefaultLinker() const {
  switch(getTriple().getArch()) {
  default:
    // Otherwise, use the gold linker.
    return "gold";
  }
}

Also something that I noticed when changing the patch is that the toolchain is for GenericUnix does that mean this changes things for BSD? Is that OK?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its an ELF thing rather than a Linux thing, so I think that the current change as proposed makes sense. However, Id rather leave the structure as is (I explicitly split up the switch as the reasoning is different). That said, we could change the structure in a follow up change as well if others feel that is a good idea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for considering this in a follow-up pull request.

default:
// Otherwise, use the default BFD linker.
return "";
Expand Down
3 changes: 3 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ function set_deployment_target_based_options() {

case ${deployment_target} in
linux-x86_64)
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
linux-armv6)
Expand All @@ -346,9 +347,11 @@ function set_deployment_target_based_options() {
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
linux-powerpc64)
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="powerpc64"
;;
linux-powerpc64le)
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="powerpc64le"
;;
cygwin-x86_64)
Expand Down