[PATCH] D97736: [Driver] Add a experimental option to link to LLVM libc.

Siva Chandra via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 4 17:12:50 PST 2021


sivachandra added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:680
+    for (StringRef Arg : CmdArgs) {
+      if (Arg == "-lm" || Arg == "-lc") {
+        // TODO: Add -lllvmlibc before -lpthread when LLVM libc has pthread
----------------
phosek wrote:
> This wouldn't handle the case where you use `-nolibc path/to/libc.a` in which case you'd have to manually pass in the `libllvmllibc.a`, but I'm not sure if that's a case we care about.
Yeah, its hard to cater to all combinations.  In this case though, assuming `libllvmlibc.a` is available in path, one can add `-lllvmlibc` in the right place. 


================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:684
+        WithLLVMLibc.push_back("-lllvmlibc");
+        WithLLVMLibc.push_back(Arg.data());
+      } else {
----------------
phosek wrote:
> You can move this after the condition and omit the `else` branch.
[Shame cube] Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97736



More information about the cfe-commits mailing list