diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-11-08 18:14:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-08 18:14:53 -0700 |
| commit | 602a8b400f3468cf25fa834a5e9fb8a0a2403e2c (patch) | |
| tree | 73b2ddef94eb9781456fc31089bae5da10a3cf84 | |
| parent | 4805a97274bd8673bbe01d82ab3694441b1cf11d (diff) | |
| parent | f3428a7dc4bef051f6c1fb454761eda77dbeb106 (diff) | |
| download | rust-602a8b400f3468cf25fa834a5e9fb8a0a2403e2c.tar.gz rust-602a8b400f3468cf25fa834a5e9fb8a0a2403e2c.zip | |
Rollup merge of #55659 - alexcrichton:musl-no-group, r=michaelwoerister
rustc: Delete grouping logic from the musl target
This commit deletes the injection of `-(` and `-)` options to the linker
for the musl targets. This actually causes problems today on nightly if
you execute:
$ echo 'fn main() {}' >> foo.rs
$ rustc --target x86_64-unknown-linux-musl -C panic=abort
you get a linker error about "cannot nest groups". This comes about
because rustc injects its own `--start-group` and `--end-group`
variables which clash with the outer `-(` and `-)` variables. It's not
entirely clear to me why this doesn't affect the musl target by default
(in `-C panic=unwind` mode).
The compiler's own injection of `--start-group` and `--end-group` should
solve the issues mentioned in the comment for injecting `-(` and `-)` as
well.
| -rw-r--r-- | src/librustc_target/spec/linux_musl_base.rs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs index 7a3f3c2a518..c87f14977cb 100644 --- a/src/librustc_target/spec/linux_musl_base.rs +++ b/src/librustc_target/spec/linux_musl_base.rs @@ -24,31 +24,6 @@ pub fn opts() -> TargetOptions { // argument is *not* necessary for normal builds, but it can't hurt! base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string()); - // There's a whole bunch of circular dependencies when dealing with MUSL - // unfortunately. To put this in perspective libc is statically linked to - // liblibc and libunwind is statically linked to libstd: - // - // * libcore depends on `fmod` which is in libc (transitively in liblibc). - // liblibc, however, depends on libcore. - // * compiler-rt has personality symbols that depend on libunwind, but - // libunwind is in libstd which depends on compiler-rt. - // - // Recall that linkers discard libraries and object files as much as - // possible, and with all the static linking and archives flying around with - // MUSL the linker is super aggressively stripping out objects. For example - // the first case has fmod stripped from liblibc (it's in its own object - // file) so it's not there when libcore needs it. In the second example all - // the unused symbols from libunwind are stripped (each is in its own object - // file in libstd) before we end up linking compiler-rt which depends on - // those symbols. - // - // To deal with these circular dependencies we just force the compiler to - // link everything as a group, not stripping anything out until everything - // is processed. The linker will still perform a pass to strip out object - // files but it won't do so until all objects/archives have been processed. - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-(".to_string()); - base.post_link_args.insert(LinkerFlavor::Gcc, vec!["-Wl,-)".to_string()]); - // When generating a statically linked executable there's generally some // small setup needed which is listed in these files. These are provided by // a musl toolchain and are linked by default by the `musl-gcc` script. Note |
