Adjust linker_is_gnu branches for cases that don't work on windows.
This commit is contained in:
parent
45225d24bf
commit
a862b1f6cc
1 changed files with 16 additions and 7 deletions
|
@ -276,18 +276,27 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
|
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
|
||||||
match output_kind {
|
match output_kind {
|
||||||
LinkOutputKind::DynamicNoPicExe => {
|
LinkOutputKind::DynamicNoPicExe => {
|
||||||
if !self.is_ld && self.sess.target.linker_is_gnu {
|
if !self.is_ld
|
||||||
|
&& self.sess.target.linker_is_gnu
|
||||||
|
&& !self.sess.target.is_like_windows
|
||||||
|
{
|
||||||
self.cmd.arg("-no-pie");
|
self.cmd.arg("-no-pie");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LinkOutputKind::DynamicPicExe => {
|
LinkOutputKind::DynamicPicExe => {
|
||||||
// `-pie` works for both gcc wrapper and ld.
|
// noop on windows w/ gcc & ld, error w/ lld
|
||||||
self.cmd.arg("-pie");
|
if !self.sess.target.is_like_windows {
|
||||||
|
// `-pie` works for both gcc wrapper and ld
|
||||||
|
self.cmd.arg("-pie");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LinkOutputKind::StaticNoPicExe => {
|
LinkOutputKind::StaticNoPicExe => {
|
||||||
// `-static` works for both gcc wrapper and ld.
|
// `-static` works for both gcc wrapper and ld.
|
||||||
self.cmd.arg("-static");
|
self.cmd.arg("-static");
|
||||||
if !self.is_ld && self.sess.target.linker_is_gnu {
|
if !self.is_ld
|
||||||
|
&& self.sess.target.linker_is_gnu
|
||||||
|
&& !self.sess.target.is_like_windows
|
||||||
|
{
|
||||||
self.cmd.arg("-no-pie");
|
self.cmd.arg("-no-pie");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +356,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// has -needed-l{} / -needed_library {}
|
// has -needed-l{} / -needed_library {}
|
||||||
// but we have no way to detect that here.
|
// but we have no way to detect that here.
|
||||||
self.sess.warn("`as-needed` modifier not implemented yet for ld64");
|
self.sess.warn("`as-needed` modifier not implemented yet for ld64");
|
||||||
} else if self.sess.target.linker_is_gnu {
|
} else if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
|
||||||
self.linker_arg("--no-as-needed");
|
self.linker_arg("--no-as-needed");
|
||||||
} else {
|
} else {
|
||||||
self.sess.warn("`as-needed` modifier not supported for current linker");
|
self.sess.warn("`as-needed` modifier not supported for current linker");
|
||||||
|
@ -358,7 +367,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
if !as_needed {
|
if !as_needed {
|
||||||
if self.sess.target.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
// See above FIXME comment
|
// See above FIXME comment
|
||||||
} else if self.sess.target.linker_is_gnu {
|
} else if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
|
||||||
self.linker_arg("--as-needed");
|
self.linker_arg("--as-needed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -690,7 +699,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_as_needed(&mut self) {
|
fn add_as_needed(&mut self) {
|
||||||
if self.sess.target.linker_is_gnu {
|
if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
|
||||||
self.linker_arg("--as-needed");
|
self.linker_arg("--as-needed");
|
||||||
} else if self.sess.target.is_like_solaris {
|
} else if self.sess.target.is_like_solaris {
|
||||||
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option
|
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue