forked from OSchip/llvm-project
[Driver] Use libatomic for 32-bit SPARC atomics support
Even after D86621 <https://reviews.llvm.org/D86621>, `clang -m32` on Solaris/sparcv9 doesn't inline atomics with 8-byte operands, unlike `gcc`. This leads to many link failures in the testsuite (undefined references to `__atomic_load_8` and `__sync_val_compare_and_swap_8`. Until a proper codegen fix can be implemented, this patch works around the first of those by linking with `-latomic`. Tested on `sparcv9-sun-solaris2.11`. Differential Revision: https://reviews.llvm.org/D118021
This commit is contained in:
parent
be5734ddaa
commit
a6afa9e6b0
|
@ -756,7 +756,7 @@ static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
|
const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
|
||||||
assert(!TC.getTriple().isOSAIX() &&
|
assert(!TC.getTriple().isOSAIX() &&
|
||||||
"AIX linker does not support any form of --as-needed option yet.");
|
"AIX linker does not support any form of --as-needed option yet.");
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,8 @@ bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
|
||||||
bool ForceStaticHostRuntime = false,
|
bool ForceStaticHostRuntime = false,
|
||||||
bool IsOffloadingHost = false, bool GompNeedsRT = false);
|
bool IsOffloadingHost = false, bool GompNeedsRT = false);
|
||||||
|
|
||||||
|
const char *getAsNeededOption(const ToolChain &TC, bool as_needed);
|
||||||
|
|
||||||
llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
|
llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
|
||||||
llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
|
llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,13 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
CmdArgs.push_back("-lssp_nonshared");
|
CmdArgs.push_back("-lssp_nonshared");
|
||||||
CmdArgs.push_back("-lssp");
|
CmdArgs.push_back("-lssp");
|
||||||
}
|
}
|
||||||
|
// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
|
||||||
|
// forcibly link with libatomic as a workaround.
|
||||||
|
if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
|
||||||
|
CmdArgs.push_back(getAsNeededOption(getToolChain(), true));
|
||||||
|
CmdArgs.push_back("-latomic");
|
||||||
|
CmdArgs.push_back(getAsNeededOption(getToolChain(), false));
|
||||||
|
}
|
||||||
CmdArgs.push_back("-lgcc_s");
|
CmdArgs.push_back("-lgcc_s");
|
||||||
CmdArgs.push_back("-lc");
|
CmdArgs.push_back("-lc");
|
||||||
if (!Args.hasArg(options::OPT_shared)) {
|
if (!Args.hasArg(options::OPT_shared)) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
|
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
|
||||||
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
|
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
|
||||||
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
|
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
|
||||||
|
// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
|
||||||
// CHECK-LD-SPARC32-SAME: "-lgcc_s"
|
// CHECK-LD-SPARC32-SAME: "-lgcc_s"
|
||||||
// CHECK-LD-SPARC32-SAME: "-lc"
|
// CHECK-LD-SPARC32-SAME: "-lc"
|
||||||
// CHECK-LD-SPARC32-SAME: "-lgcc"
|
// CHECK-LD-SPARC32-SAME: "-lgcc"
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
|
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
|
||||||
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
|
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
|
||||||
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
|
// CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
|
||||||
|
// CHECK-LD-SPARC64-NOT: "-latomic"
|
||||||
// CHECK-LD-SPARC64-SAME: "-lgcc_s"
|
// CHECK-LD-SPARC64-SAME: "-lgcc_s"
|
||||||
// CHECK-LD-SPARC64-SAME: "-lc"
|
// CHECK-LD-SPARC64-SAME: "-lc"
|
||||||
// CHECK-LD-SPARC64-SAME: "-lgcc"
|
// CHECK-LD-SPARC64-SAME: "-lgcc"
|
||||||
|
@ -63,6 +65,7 @@
|
||||||
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
|
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
|
||||||
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
|
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
|
||||||
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
|
// CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
|
||||||
|
// CHECK-LD-X32-NOT: "-latomic"
|
||||||
// CHECK-LD-X32-SAME: "-lgcc_s"
|
// CHECK-LD-X32-SAME: "-lgcc_s"
|
||||||
// CHECK-LD-X32-SAME: "-lc"
|
// CHECK-LD-X32-SAME: "-lc"
|
||||||
// CHECK-LD-X32-SAME: "-lgcc"
|
// CHECK-LD-X32-SAME: "-lgcc"
|
||||||
|
@ -86,6 +89,7 @@
|
||||||
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
|
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
|
||||||
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
|
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
|
||||||
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
|
// CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
|
||||||
|
// CHECK-LD-X64-NOT: "-latomic"
|
||||||
// CHECK-LD-X64-SAME: "-lgcc_s"
|
// CHECK-LD-X64-SAME: "-lgcc_s"
|
||||||
// CHECK-LD-X64-SAME: "-lc"
|
// CHECK-LD-X64-SAME: "-lc"
|
||||||
// CHECK-LD-X64-SAME: "-lgcc"
|
// CHECK-LD-X64-SAME: "-lgcc"
|
||||||
|
|
Loading…
Reference in New Issue