[PATCH] D80488: Teach `-fsanitize=fuzzer` to respect `-static` and `-static-libstdc++` when adding C++ standard libraries.

Chandler Carruth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 24 01:02:09 PDT 2020


chandlerc created this revision.
Herald added subscribers: cfe-commits, mcrosier.
Herald added a project: clang.

No idea if this is 'correct' or the right way to fix this, so just
sending this mostly as an FYI. Someone who works more closely on the
sanitizers might need to take it over and figure out how this should be
working and add relevant test cases, etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80488

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
@@ -747,8 +747,15 @@
       !Args.hasArg(options::OPT_shared)) {
 
     addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
-    if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+    if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) {
+      bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+                                 !Args.hasArg(options::OPT_static);
+      if (OnlyLibstdcxxStatic)
+        CmdArgs.push_back("-Bstatic");
       TC.AddCXXStdlibLibArgs(Args, CmdArgs);
+      if (OnlyLibstdcxxStatic)
+        CmdArgs.push_back("-Bdynamic");
+    }
   }
 
   for (auto RT : SharedRuntimes)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80488.265912.patch
Type: text/x-patch
Size: 863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200524/53458595/attachment-0001.bin>


More information about the cfe-commits mailing list