[clang] 4c483a0 - [AIX] Consolidate Crt0Basename logic

Michael Francis via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 20 17:47:14 PDT 2023


Author: Michael Francis
Date: 2023-03-21T00:47:05Z
New Revision: 4c483a046d2ff29ec2fd5bad6305f97424a2b880

URL: https://github.com/llvm/llvm-project/commit/4c483a046d2ff29ec2fd5bad6305f97424a2b880
DIFF: https://github.com/llvm/llvm-project/commit/4c483a046d2ff29ec2fd5bad6305f97424a2b880.diff

LOG: [AIX] Consolidate Crt0Basename logic

when certain flags are specified, the Crt0 object files are not linked.
However, the logic for determining which files will always run. This
patch moves that logic so that the basename is only determined if it is
needed.

Differential Revision: https://reviews.llvm.org/D146443

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/AIX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index d4d13ce36e76f..5521a38d9bc0a 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-bpD:0x110000000");
   }
 
-  auto getCrt0Basename = [&Args, IsArch32Bit] {
-    if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-      // Enable gprofiling when "-pg" is specified.
-      if (A->getOption().matches(options::OPT_pg))
-        return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-      // Enable profiling when "-p" is specified.
-      return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-    }
-    return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
                    options::OPT_shared, options::OPT_r)) {
+    auto getCrt0Basename = [&Args, IsArch32Bit] {
+      if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+        // Enable gprofiling when "-pg" is specified.
+        if (A->getOption().matches(options::OPT_pg))
+          return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+        // Enable profiling when "-p" is specified.
+        return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+      }
+      return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+    };
+
     CmdArgs.push_back(
         Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename())));
 


        


More information about the cfe-commits mailing list