[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

Manoj Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 16:14:48 PDT 2019


manojgupta added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:447
       const char *crtbegin;
-      if (Args.hasArg(options::OPT_static))
-        crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
-      else if (Args.hasArg(options::OPT_shared))
-        crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-      else if (IsPIE || IsStaticPIE)
-        crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
-      else
-        crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
-
-      if (HasCRTBeginEndFiles)
+      if (ToolChain.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT &&
+          !isAndroid) {
----------------
phosek wrote:
> manojgupta wrote:
> > This is currently unconditional on using compiler-rt. Given that compiler-rt provides the crt*.o files only under the CMake flag COMPILER_RT_BUILD_CRT, shouldn't there be an equivalent clang CMake flag to conditionally enable this.
> `COMPILER_RT_BUILD_CRT` is `ON` by default now in D28791, but even if we change that, I think this logic should be independent since you should be able to build Clang separately from compiler-rt.
Since it is possible to build compiler-rt without CRT files, I believe that clang should also be able to use compiler-rt without compiler-rt provided CRT files.
Using them unconditionally will also break the case of using newer clang with older compiler-rt.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59264





More information about the cfe-commits mailing list