[PATCH] D84412: [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos
Rainer Orth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 5 07:21:51 PDT 2020
ro updated this revision to Diff 283232.
ro added a comment.
Incorporate review comments: clarify comment and arg name.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84412/new/
https://reviews.llvm.org/D84412
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -630,6 +630,16 @@
return false;
}
+static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+ // While the Solaris 11.2 ld added --as-needed/--no-as-needed as aliases
+ // for the native forms -z ignore/-z record, they are missing in Illumos,
+ // so always use the native form.
+ if (TC.getTriple().isOSSolaris())
+ return as_needed ? "-zignore" : "-zrecord";
+ else
+ return as_needed ? "--as-needed" : "--no-as-needed";
+}
+
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
ArgStringList &CmdArgs) {
// Fuchsia never needs these. Any sanitizer runtimes with system
@@ -639,7 +649,7 @@
// Force linking against the system libraries sanitizers depends on
// (see PR15823 why this is necessary).
- CmdArgs.push_back("--no-as-needed");
+ CmdArgs.push_back(getAsNeededOption(TC, false));
// There's no libpthread or librt on RTEMS & Android.
if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
!TC.getTriple().isAndroid()) {
@@ -836,7 +846,7 @@
}
void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
- CmdArgs.push_back("--no-as-needed");
+ CmdArgs.push_back(getAsNeededOption(TC, false));
CmdArgs.push_back("-lpthread");
if (!TC.getTriple().isOSOpenBSD())
CmdArgs.push_back("-lrt");
@@ -1261,7 +1271,7 @@
bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
!TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();
if (AsNeeded)
- CmdArgs.push_back("--as-needed");
+ CmdArgs.push_back(getAsNeededOption(TC, true));
switch (UNW) {
case ToolChain::UNW_None:
@@ -1289,7 +1299,7 @@
}
if (AsNeeded)
- CmdArgs.push_back("--no-as-needed");
+ CmdArgs.push_back(getAsNeededOption(TC, false));
}
static void AddLibgcc(const ToolChain &TC, const Driver &D,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84412.283232.patch
Type: text/x-patch
Size: 2080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200805/93b40b44/attachment-0001.bin>
More information about the cfe-commits
mailing list