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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for your comment!
It does not work with --sysroot. From my initial findings, the compiler recognizes sysroot but the linker does not respect it for any of the libraries it links against.
On xlc, passing --sysroot= does not change the path used for these libraries. The driver will emit the same link flags: -L/lib/profiled,-L/usr/lib/profiled. As of now, this patch follows the same standard for consistency.
Looks good but I just want to confirm that the profiled -L paths are appended in the correct order with respect to the non-profiled paths.
clang/test/Driver/aix-ld.c | ||
---|---|---|
192 | I don't currently see the test checking for the usual /lib and /usr/lib directories. Should we check that the new profiled -L paths are correctly positioned relative to the non-profiled directories, or does it matter? |
In the AIX ld manpage, we find:
Libraries Libraries are files whose names end in .a, or possibly .so. To designate a library, you can specify an absolute or relative path name or use the -l (lowercase letter L) flag in the form -lName. The last form designates a libName.a file, or when the rtl option is used, a libName.so file to be searched for in several directories. These search directories include any directories that are specified by -L flags and the standard library directories /usr/lib and /lib.
So the addition of -L/usr/lib/profiled and -L/lib/profiled comes before the implicit linking of /usr/lib and /lib, so the linker will resolve the profiled libraries first.
Closing as this revision has landed
https://reviews.llvm.org/rG0fae851824bc1b64a727aeb331b7a0787599bd1f
I don't currently see the test checking for the usual /lib and /usr/lib directories. Should we check that the new profiled -L paths are correctly positioned relative to the non-profiled directories, or does it matter?