[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2022-08-03 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.
Herald added a subscriber: MaskRay.
Herald added a project: All.

Is this going to continue?
And also if we use libunwind to handle EH, then it uses dladdr function which 
need link libdl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63329

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2020-12-10 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added a comment.
Herald added a subscriber: dang.

@erikjv Are you still working on this? Or is a better alternative being 
pursued? IIUC, this functionality is still missing in trunk.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:570
 
+  // FIXME: libc++ dynamically links against libpthread, so for static
+  // linking, we need to supply that dependency.

Why does this say FIXME?



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:574
+// FIXME: Again, like above, does this really make sense for all GNU
+// toolchains?
+WantPthread = true;

It seems to me that, in general, the answer will be yes. std::thread is built 
on pthreads, generally, and if we need to change this for particular systems, 
then that can always be done as a special case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

In D63329#1543407 , @lebedev.ri wrote:

> Tests?


I can add a test, but I'd first like to know if this would be accepted. Test 
would be along the lines of "test/Driver/fuchsia.cpp" line 36, where it tests 
"-static-libstdc++".


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv created this revision.
erikjv added reviewers: dlj, cfe-commits.
Herald added a reviewer: EricWF.
Herald added a subscriber: jfb.
Herald added a project: clang.

Dynamic linking against libc++ on Linux was already supported, as is
dynamic and static linking against libstdc++. What was missing is being
able to statically link against libc++. This can be used by applications
that choose to use libc++ instead of libstdc++, but do not (or can not)
require the dynamic libraries of libc++(abi) to be installed.


Repository:
  rC Clang

https://reviews.llvm.org/D63329

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -528,11 +528,14 @@
   if (D.CCCIsCXX() &&
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (ToolChain.ShouldLinkCXXStdlib(Args)) {
-  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+  bool OnlyLibstdcxxStatic = (Args.hasArg(options::OPT_static_libstdcxx) ||
+  Args.hasArg(options::OPT_static_libcxx)) &&
  !Args.hasArg(options::OPT_static);
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bstatic");
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (Args.hasArg(options::OPT_static_libcxx)) // libc++ links against 
libc++abi, so we have to pull that in too.
+CmdArgs.push_back("-lc++abi");
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bdynamic");
 }
@@ -564,6 +567,13 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+  // FIXME: libc++ dynamically links against libpthread, so for static
+  // linking, we need to supply that dependency.
+  if (Args.hasArg(options::OPT_static_libcxx))
+// FIXME: Again, like above, does this really make sense for all GNU
+// toolchains?
+WantPthread = true;
+
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
   if (WantPthread && !isAndroid)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2602,6 +2602,7 @@
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -528,11 +528,14 @@
   if (D.CCCIsCXX() &&
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (ToolChain.ShouldLinkCXXStdlib(Args)) {
-  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+  bool OnlyLibstdcxxStatic = (Args.hasArg(options::OPT_static_libstdcxx) ||
+  Args.hasArg(options::OPT_static_libcxx)) &&
  !Args.hasArg(options::OPT_static);
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bstatic");
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (Args.hasArg(options::OPT_static_libcxx)) // libc++ links against libc++abi, so we have to pull that in too.
+CmdArgs.push_back("-lc++abi");
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bdynamic");
 }
@@ -564,6 +567,13 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+  // FIXME: libc++ dynamically links against libpthread, so for static
+  // linking, we need to supply that dependency.
+  if (Args.hasArg(options::OPT_static_libcxx))
+// FIXME: Again, like above, does this really make sense for all GNU
+// toolchains?
+WantPthread = true;
+
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
   if (WantPthread && !isAndroid)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2602,6 +2602,7 @@
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ