Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up-Z linker-flavor #40018
Conversation
rust-highfive
assigned
pnkfelix
Feb 21, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
|
Yes, the Solaris linker is multi-arch. As long as it is provided well-formed objects it should be able to link them. With that said, I intend to evaluate what it would take to get lld working on Solaris later this year and teach it some Solaris-specific tricks. |
This comment has been minimized.
This comment has been minimized.
|
Oh, and btw, this is awesome as it will make it easier for us to teach rust how to use the Solaris linker directly. |
This comment has been minimized.
This comment has been minimized.
|
This kinda collides and duplicates my effort to refactor target specs altogether but since it is pretty similar to what I'm going for wrt linkers I guess it's fine. |
This comment has been minimized.
This comment has been minimized.
|
The target spec field needn't be required field as it can just default to gnu, just like pretty much everything else does already anyway |
This comment has been minimized.
This comment has been minimized.
|
/cc @dhduvall |
alexcrichton
reviewed
Mar 1, 2017
| "em" => LinkerFlavor::Em, | ||
| "gnu" => LinkerFlavor::Gnu, | ||
| "ld" => LinkerFlavor::Ld, | ||
| "msvc" => LinkerFlavor::Msvc, |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Mar 1, 2017
Member
These same four strings have been repeated quite a few times throughout this PR, perhaps they could be centralized to one location though?
alexcrichton
reviewed
Mar 1, 2017
| } | ||
| } | ||
|
|
||
| impl<'a> Linker for LdLinker<'a> { |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Mar 1, 2017
Member
Most of this seems duplicated from a definition above, would it be possible to share code instead of duplicating?
alexcrichton
reviewed
Mar 1, 2017
| // Always enable NX protection when it is available | ||
| "-Wl,-z,noexecstack".to_string(), | ||
| ]); | ||
|
|
||
| TargetOptions { | ||
| dynamic_linking: true, | ||
| executables: true, | ||
| target_family: Some("unix".to_string()), | ||
| linker_is_gnu: true, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This all sounds like a great idea to me, thanks @japaric! I think it's some good internal refactoring regardless as well. As a minor bikeshed, can we perhaps rename |
alexcrichton
assigned
alexcrichton
and unassigned
pnkfelix
Mar 1, 2017
japaric
force-pushed the
japaric:ld
branch
from
77bf2c9
to
21e2e3f
Mar 6, 2017
This comment has been minimized.
This comment has been minimized.
Done.
I got some deduplication by making
Yes.
Done |
This comment has been minimized.
This comment has been minimized.
|
Ah yeah for deduplication of gcc/ld I was thinking we could just strip Also could the "did you mean ..." be deduplicated as well? Just trying to contain the number of places we have to update when we inevitably add a new flavor of linker :) Also yeah that's true about |
This comment has been minimized.
This comment has been minimized.
|
It also looks like Travis may be failing? |
This comment has been minimized.
This comment has been minimized.
|
ping @japaric |
This comment has been minimized.
This comment has been minimized.
|
squeaky wheel @japaric |
This comment has been minimized.
This comment has been minimized.
|
Closing due to inactivity, but feel free to resubmit with a rebase! |
alexcrichton
closed this
Mar 27, 2017
japaric
reopened this
Apr 5, 2017
japaric
force-pushed the
japaric:ld
branch
from
21e2e3f
to
6ac1bfc
Apr 5, 2017
This comment has been minimized.
This comment has been minimized.
|
Rebased.
Done. Merged GccLinker and LdLinker into a single GccLinker that decides whether to add the -Wl based on the value of a boolean is_ld field.
Done.
That rmake test should be fixed now. |
japaric
changed the title
[RFC] -Z linker-flavor
-Z linker-flavor
Apr 6, 2017
This comment has been minimized.
This comment has been minimized.
|
Now that we have the unstable book, should I document I forgot to ask in my previous comment: r? @alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
japaric
force-pushed the
japaric:ld
branch
from
6ac1bfc
to
c9c42ee
Apr 6, 2017
bors
added a commit
that referenced
this pull request
Apr 10, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 10, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors retry
|
bors
added a commit
that referenced
this pull request
Apr 10, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 10, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit e192fb3
into
rust-lang:master
Apr 10, 2017
japaric
deleted the
japaric:ld
branch
Apr 10, 2017
This was referenced Apr 10, 2017
phil-opp
added a commit
to phil-opp/blog_os
that referenced
this pull request
Apr 12, 2017
CryZe
added a commit
to CryZe/rust
that referenced
this pull request
Apr 14, 2017
CryZe
referenced this pull request
Apr 14, 2017
Merged
Compile WASM as WASM instead of asm.js #41303
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this pull request
Apr 14, 2017
hawkw
added a commit
to hawkw/kernel
that referenced
this pull request
May 21, 2017
This was referenced May 21, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
orumin
added a commit
to orumin/Rust-BareMetal-GBA-Sample
that referenced
this pull request
Jun 17, 2017
tamird
reviewed
Nov 24, 2017
| self.cmd.arg("-Wl,--whole-archive") | ||
| .arg("-l").arg(lib) | ||
| .arg("-Wl,--no-whole-archive"); | ||
| self.linker_arg("--whole-archive").cmd.arg("-l").arg(lib); |
This comment has been minimized.
This comment has been minimized.
tamird
Nov 24, 2017
Contributor
FYI: this style (e.g. "-l" "System") isn't supported by ld64 on darwin - that linker requires the style "-lSystem". I'm testing a PR that changes this.
japaric commentedFeb 21, 2017
(Please read the commit message first)
This PR is an alternative to #36120 (internal lld linker). The
main goal of this PR is to make it possible to use LLD as a linker to allow
out of tree experimentation. Now that LLD is going to be shipped with LLVM 4.0,
it should become easier to get a hold of LLD (hopefully, it will be packaged by
Linux distros soon).
Since LLD is a multiarch linker, it has the potential to make cross compilation
easier (less tools need to be installed). Supposedly, LLD is also faster than
the gold linker so LLD may improve build times where link times are significant
(e.g. 100% incremental compilation reuse).
The place where LLD shines is at linking Rust programs that don't depend on
system libraries. For example, here's how you would link a bare metal ARM
Cortex-M program:
This doesn't require installing the
arm-none-eabi-gcctoolchain.Even cooler (but I'm biased) is that you can link Rust programs that use
steed(steedis astdre-implementation free of C dependencies for Linuxsystems) instead of
stdfor a bunch of different architectures without havingto install a single cross toolchain.
All these targets (architectures) worked with LLD:
The case where lld is unergonomic is linking binaries that depend on system
libraries. Like "Hello, world" for
x86_64-unknown-linux-gnu. Because you haveto pass as linker arguments: the path to the startup objects, the path to the
dynamic linker and the library search paths. And all those are system specific
so they can't be encoded in the target itself.
Another case where
-Z linker-flavormay come in handy is directly callingSolaris' linker which is also a multiarch linker (or so I have heard). cc
@binarycrusader
cc @alexcrichton
Heads up: [breaking-change] due to changes in the target specification format.