Skip to content

Commit

Permalink
linker: Support -static-pie and -static -shared
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed May 20, 2020
1 parent eccaa01 commit 96a466c
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 131 deletions.
22 changes: 1 addition & 21 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,16 +1530,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
}

// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
// FIXME: Support `StaticPicExe` correctly.
match link_output_kind {
LinkOutputKind::DynamicPicExe | LinkOutputKind::StaticPicExe => {
cmd.position_independent_executable()
}
LinkOutputKind::DynamicNoPicExe | LinkOutputKind::StaticNoPicExe => {
cmd.no_position_independent_executable()
}
_ => {}
}
cmd.set_output_kind(link_output_kind, out_filename);

// OBJECT-FILES-NO, AUDIT-ORDER
add_relro_args(cmd, sess);
Expand Down Expand Up @@ -1568,17 +1559,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
tmpdir,
);

// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
// FIXME: Merge with the previous `link_output_kind` match,
// and support `StaticPicExe` and `StaticDylib` correctly.
match link_output_kind {
LinkOutputKind::StaticNoPicExe | LinkOutputKind::StaticPicExe => {
cmd.build_static_executable()
}
LinkOutputKind::DynamicDylib | LinkOutputKind::StaticDylib => cmd.build_dylib(out_filename),
_ => {}
}

// OBJECT-FILES-NO, AUDIT-ORDER
if sess.opts.cg.profile_generate.enabled() {
cmd.pgo_gen();
Expand Down
Loading

0 comments on commit 96a466c

Please sign in to comment.