[PATCH] D110128: [Driver] Correctly handle static C++ standard library

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 21 11:36:05 PDT 2021


MaskRay added a comment.

LGTM.

I looked at this in 2019 but did not change because GNU ld 2.25 (2014) introduced --push-state. (gold added it in 2016 but I think we can have higher version requirement for gold.)
In 2021, binutils 2.24 (2013) compatibility should be irrelevant now...



================
Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:143
         if (OnlyLibstdcxxStatic)
           CmdArgs.push_back("-Bstatic");
         ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
----------------
`--as-needed` only applies to shared objects so you can move it into the `else` code path.


================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:581
+      CmdArgs.push_back("--push-state");
+      CmdArgs.push_back("--as-needed");
       if (OnlyLibstdcxxStatic)
----------------
The --as-needed change should be dropped from this patch.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110128/new/

https://reviews.llvm.org/D110128



More information about the cfe-commits mailing list