This is an archive of the discontinued LLVM Phabricator instance.

[AIX][pg] Add Correct Search Paths for Profiled Libraries
ClosedPublic

Authored by francii on Nov 3 2022, 4:08 PM.

Details

Summary

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.

Diff Detail

Event Timeline

francii created this revision.Nov 3 2022, 4:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 4:08 PM
francii requested review of this revision.Nov 3 2022, 4:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 4:08 PM

This needs a clang/test/Driver test. And, does this work with --sysroot= ?

francii updated this revision to Diff 473528.Nov 6 2022, 5:22 PM

Including test case

francii added a comment.EditedNov 7 2022, 8:14 AM

This needs a clang/test/Driver test. And, does this work with --sysroot= ?

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.

francii updated this revision to Diff 474396.EditedNov 9 2022, 5:22 PM

Update the recently-created test cases

francii updated this revision to Diff 475005.Nov 13 2022, 10:48 AM

Add support for --sysroot

francii updated this revision to Diff 475006.Nov 13 2022, 10:54 AM

Removed unnecessary variables

francii updated this revision to Diff 475007.Nov 13 2022, 10:55 AM

Soft reset

francii updated this revision to Diff 475187.Nov 14 2022, 9:57 AM

Removed check for sysroot, it is not needed.

francii updated this revision to Diff 475194.Nov 14 2022, 10:10 AM

Fix mixup

francii updated this revision to Diff 475197.Nov 14 2022, 10:14 AM

Remove check for -p

francii updated this revision to Diff 475203.Nov 14 2022, 10:20 AM

Add sysroot to test cases

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 ↗(On Diff #475203)

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?

francii added a comment.EditedNov 22 2022, 8:34 AM

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.

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.

This revision is now accepted and ready to land.Nov 23 2022, 10:49 AM