[PATCH] D53854: [Driver] Use -push-/-pop-state and -as-needed for libc++ on Fuchsia
Petr Hosek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 29 18:15:19 PDT 2018
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added a reviewer: EricWF.
Herald added a subscriber: cfe-commits.
This avoids introducing unnecessary DT_NEEDED entries when using
C++ driver for linking C code or C++ code that doesn't use C++
standard library.
Repository:
rC Clang
https://reviews.llvm.org/D53854
Files:
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp
Index: clang/test/Driver/fuchsia.cpp
===================================================================
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -15,7 +15,11 @@
// CHECK-NOT: crti.o
// CHECK-NOT: crtbegin.o
// CHECK: "-L[[SYSROOT]]{{/|\\\\}}lib"
-// CHECK: "-lc++" "-lm"
+// CHECK: "-push-state"
+// CHECK: "-as-needed"
+// CHECK: "-lc++"
+// CHECK: "-pop-state"
+// CHECK: "-lm"
// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
// CHECK: "-lc"
// CHECK-NOT: crtend.o
@@ -29,8 +33,10 @@
// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ \
// RUN: -fuse-ld=lld 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
-// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-push-state"
+// CHECK-STATIC: "-as-needed"
+// CHECK-STATIC: "-static"
// CHECK-STATIC: "-lc++"
-// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-pop-state"
// CHECK-STATIC: "-lm"
// CHECK-STATIC: "-lc"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -122,11 +122,12 @@
if (ToolChain.ShouldLinkCXXStdlib(Args)) {
bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
+ CmdArgs.push_back("-push-state");
+ CmdArgs.push_back("-as-needed");
if (OnlyLibstdcxxStatic)
- CmdArgs.push_back("-Bstatic");
+ CmdArgs.push_back("-static");
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
- if (OnlyLibstdcxxStatic)
- CmdArgs.push_back("-Bdynamic");
+ CmdArgs.push_back("-pop-state");
}
CmdArgs.push_back("-lm");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53854.171617.patch
Type: text/x-patch
Size: 1802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181030/ae8dd056/attachment-0001.bin>
More information about the cfe-commits
mailing list