summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Driver/Tools.cpp18
-rw-r--r--test/Driver/mips-as.c2
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f62cb85196..c5758e4b0b 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -7047,8 +7047,22 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-mabi");
CmdArgs.push_back(ABIName.data());
- // LLVM doesn't support -mabicalls yet and acts as if it is always given.
- CmdArgs.push_back("-mno-shared");
+ // -mno-shared should be emitted unless -fpic, -fpie, -fPIC, -fPIE,
+ // or -mshared (not implemented) is in effect.
+ bool IsPicOrPie = false;
+ if (Arg *A = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
+ options::OPT_fpic, options::OPT_fno_pic,
+ options::OPT_fPIE, options::OPT_fno_PIE,
+ options::OPT_fpie, options::OPT_fno_pie)) {
+ if (A->getOption().matches(options::OPT_fPIC) ||
+ A->getOption().matches(options::OPT_fpic) ||
+ A->getOption().matches(options::OPT_fPIE) ||
+ A->getOption().matches(options::OPT_fpie))
+ IsPicOrPie = true;
+ }
+ if (!IsPicOrPie)
+ CmdArgs.push_back("-mno-shared");
+
// LLVM doesn't support -mplt yet and acts as if it is always given.
// However, -mplt has no effect with the N64 ABI.
CmdArgs.push_back(ABIName == "64" ? "-KPIC" : "-call_nonpic");
diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c
index fd046c7ffa..ecbe7d668f 100644
--- a/test/Driver/mips-as.c
+++ b/test/Driver/mips-as.c
@@ -12,7 +12,7 @@
// RUN: %clang -target mips-linux-gnu -### \
// RUN: -no-integrated-as -fPIC -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS32R2-EB-PIC %s
-// MIPS32R2-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
+// MIPS32R2-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-call_nonpic" "-EB"
// MIPS32R2-EB-PIC: "-KPIC"
//
// RUN: %clang -target mipsel-linux-gnu -### \