r346064 - [Driver] Use -push-/-pop-state and -as-needed for libc++ on Fuchsia
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 2 18:43:25 PDT 2018
Author: phosek
Date: Fri Nov 2 18:43:25 2018
New Revision: 346064
URL: http://llvm.org/viewvc/llvm-project?rev=346064&view=rev
Log:
[Driver] Use -push-/-pop-state and -as-needed for libc++ on Fuchsia
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.
Differential Revision: https://reviews.llvm.org/D53854
Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=346064&r1=346063&r2=346064&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Fri Nov 2 18:43:25 2018
@@ -122,13 +122,14 @@ void fuchsia::Linker::ConstructJob(Compi
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("-lm");
+ CmdArgs.push_back("--pop-state");
}
- CmdArgs.push_back("-lm");
}
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
Modified: cfe/trunk/test/Driver/fuchsia.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.cpp?rev=346064&r1=346063&r2=346064&view=diff
==============================================================================
--- cfe/trunk/test/Driver/fuchsia.cpp (original)
+++ cfe/trunk/test/Driver/fuchsia.cpp Fri Nov 2 18:43:25 2018
@@ -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: "-lm"
+// CHECK: "--pop-state"
// 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: "-lm"
+// CHECK-STATIC: "--pop-state"
// CHECK-STATIC: "-lc"
More information about the cfe-commits
mailing list