This is an archive of the discontinued LLVM Phabricator instance.

[AIX][Clang] Respect -r when invoking the linker
ClosedPublic

Authored by francii on Mar 12 2023, 11:55 PM.

Details

Summary

On AIX, libraries are still being linked when -r is passed to the driver. This patch corrects this error.

Diff Detail

Event Timeline

francii created this revision.Mar 12 2023, 11:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 11:55 PM
francii requested review of this revision.Mar 12 2023, 11:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 11:55 PM
francii retitled this revision from [AIX][Clang] Respect -r when invoking the linker On AIX, libraries are still being linked when `-r` is passed to the driver. This patch corrects this error. to [AIX][Clang] Respect -r when invoking the linker.Mar 12 2023, 11:55 PM
francii edited the summary of this revision. (Show Details)
francii edited the summary of this revision. (Show Details)
francii updated this revision to Diff 504516.Mar 12 2023, 11:59 PM

Move comment

francii updated this revision to Diff 504518.Mar 13 2023, 12:05 AM

Move -r check in CommonArgs.cpp

testcase?

clang/lib/Driver/ToolChains/AIX.cpp
236

nit: can we avoid the code duplication here? We can use a goto or add options::OPT_r checking below.
./lib/Driver/ToolChains/Gnu.cpp can be used as a reference.

testcase?

This patch is still WIP while I verify the libraries that we intend not to add. But I will add a test case once I've done so :)

francii edited the summary of this revision. (Show Details)
francii updated this revision to Diff 504884.Mar 13 2023, 4:20 PM

Update check in AIX.cpp, add test case

francii marked an inline comment as done.Mar 13 2023, 6:05 PM
francii updated this revision to Diff 505221.Mar 14 2023, 12:38 PM

Update test case

w2yehia accepted this revision.Mar 14 2023, 1:22 PM

LGTM. Would be nice to get @daltenty 's approval too.

clang/test/Driver/aix-ld.c
1094

is there a way to check that -l<anything> is not present?
I'm thinking it's more future-proof ((1) detects if new libraries get added and (2) avoids having to update the testcase).. not sure what the disadvantages of adding the wildcard is.

This revision is now accepted and ready to land.Mar 14 2023, 1:22 PM
francii updated this revision to Diff 505243.Mar 14 2023, 1:31 PM

Wildcard check for -l.

francii marked an inline comment as done.Mar 14 2023, 1:31 PM
francii updated this revision to Diff 505689.Mar 15 2023, 8:16 PM

Add missing bracket

francii updated this revision to Diff 505691.Mar 15 2023, 8:20 PM

Add missing bracket

daltenty added inline comments.Mar 17 2023, 8:00 AM
clang/lib/Driver/ToolChains/AIX.cpp
240

This mostly looks good, but I'm not sure other toolchains omit use specified L options. I think we shouldn't either.

clang/lib/Driver/ToolChains/CommonArgs.cpp
1696 ↗(On Diff #505691)

I think this is redundant, we guard out this whole function call in the block above.

francii updated this revision to Diff 506439.Mar 19 2023, 3:21 PM

Allow user-specified -L and -l options

LGTM, with a small nit about the test that should be addressed before committing

clang/test/Driver/aix-ld.c
1085

nit: add the user -L option to the test to reflect the changes above

francii updated this revision to Diff 506577.Mar 20 2023, 7:32 AM

Update test case

francii marked an inline comment as done.Mar 20 2023, 10:55 AM
This revision was automatically updated to reflect the committed changes.