[clang] 0fae851 - [AIX][pg] Add Correct Search Paths for Profiled Libraries

Chris Bowler via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 07:17:31 PST 2022


Author: Michael Francis
Date: 2022-11-29T10:16:27-05:00
New Revision: 0fae851824bc1b64a727aeb331b7a0787599bd1f

URL: https://github.com/llvm/llvm-project/commit/0fae851824bc1b64a727aeb331b7a0787599bd1f
DIFF: https://github.com/llvm/llvm-project/commit/0fae851824bc1b64a727aeb331b7a0787599bd1f.diff

LOG: [AIX][pg] Add Correct Search Paths for Profiled Libraries

On AIX, profiled system libraries are stored at `/lib/profiled` and
`/usr/lib/profiled`. When compiling with `-pg`, we want to link against
libraries in those directories. This PR modifies the AIX toolchain to
add those directories to the linker search paths.

Differential Review: https://reviews.llvm.org/D137375

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/AIX.cpp
    clang/test/Driver/aix-ld.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 1e72f1e761e8b..3bf97eec04a1a 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
       CmdArgs.push_back("-lm");
 
     CmdArgs.push_back("-lc");
+
+    if (Args.hasArg(options::OPT_pg)) {
+      CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+                                           "/lib/profiled"));
+      CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+                                           "/usr/lib/profiled"));
+    }
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 8aae6b086cbff..42631f4c59eee 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF:     "-lc"
+// CHECK-LD32-GPROF:     "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF:     "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF:     "-lc"
+// CHECK-LD64-GPROF:     "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF:     "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \


        


More information about the cfe-commits mailing list