Fix linker flags for -static-executable

Also adds a test to ensure it does not break in the future
This commit is contained in:
Dario Rexin
2020-04-07 16:15:46 -07:00
parent e659006c71
commit e4e6c16319
4 changed files with 19 additions and 5 deletions

View File

@@ -211,8 +211,10 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
Arguments.push_back(context.Args.MakeArgString(A->getValue()));
}
if (getTriple().getOS() == llvm::Triple::Linux &&
job.getKind() == LinkKind::Executable) {
if (getTriple().getObjectFormat() == llvm::Triple::ELF &&
job.getKind() == LinkKind::Executable &&
!context.Args.hasFlag(options::OPT_static_executable,
options::OPT_no_static_executable, false)) {
Arguments.push_back("-pie");
}