This is an archive of the discontinued LLVM Phabricator instance.

[AIX][clang][driver] Check the command string to the linker for exportlist opts
ClosedPublic

Authored by DiggerLin on Feb 7 2022, 8:23 AM.

Details

Summary

Some of code in the patch are contributed by David Tenty.

  1. We currently only check driver Wl options and don't check for the plain -b, -Xlinker or other options which get passed through to the linker when we decide whether to run llvm-nm --export-symbols, so we may run it in situations where we wouldn't if the user had used the equivalent -Wl, prefixed options. If we run the export list utility when the user has specified an export list, we could export more symbols than they intended.
  1. Add a new functionality to allow redirecting the stdin, stdout, stderr of individual Jobs, if redirects are set for the Job use them, otherwise fall back to the global Compilation redirects if any.

Diff Detail

Event Timeline

DiggerLin requested review of this revision.Feb 7 2022, 8:23 AM
DiggerLin created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 8:23 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ormris removed a subscriber: ormris.Feb 7 2022, 10:26 AM
DiggerLin updated this revision to Diff 406560.Feb 7 2022, 12:17 PM

run git format

DiggerLin edited the summary of this revision. (Show Details)Feb 7 2022, 12:21 PM
DiggerLin edited the summary of this revision. (Show Details)Feb 8 2022, 8:19 AM
MaskRay added a subscriber: MaskRay.Feb 8 2022, 8:14 PM
MaskRay added inline comments.
clang/lib/Driver/Job.cpp
304
371
clang/lib/Driver/ToolChains/AIX.cpp
80
220
clang/test/Driver/aix-ld.c
617

If you don't test clang in CHECK lines, you can omit -no-canonical-prefixes

Consider switching to .cpp if you always use -x c++.

621
623

-u prefixed long option form is not recommended. -u is a short option taking a value, therefore an option name typo cannot be detected.

DiggerLin marked 6 inline comments as done.Feb 24 2022, 10:04 AM
DiggerLin added inline comments.
clang/lib/Driver/ToolChains/AIX.cpp
80

thanks

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

all the test in the aix-ld.c using "-no-canonical-prefixes", in order to keep the same style. I am prefer to keep as it now. and create a NFC patch to clean the ""-no-canonical-prefixes" later. And keep the file name as aix-ld.c , it maybe better to have another NFC to change the file name.

623

same comment as above, I am prefer for another NFC patch for it. thanks.

MaskRay added inline comments.Feb 24 2022, 10:11 AM
clang/test/Driver/aix-ld.c
617
DiggerLin marked 3 inline comments as done.
DiggerLin updated this revision to Diff 412516.Mar 2 2022, 12:53 PM
DiggerLin marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 12:53 PM
DiggerLin added inline comments.Mar 2 2022, 12:53 PM
clang/test/Driver/aix-ld.c
617

thanks

stevewan added a comment.EditedApr 19 2022, 10:59 AM

I don't think the redirect files portion of this patch is well-described, could you please add it to the description?

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

Since != is preferred, let's switch to that.

88
DiggerLin retitled this revision from [AIX][clang][driver] Check the command string to the linker for exportlist opts to [AIX][clang][driver] Check the command string to the linker for exportlist opts and .Apr 20 2022, 10:54 AM
DiggerLin edited the summary of this revision. (Show Details)
DiggerLin edited the summary of this revision. (Show Details)
DiggerLin edited the summary of this revision. (Show Details)Apr 20 2022, 10:57 AM
DiggerLin marked 2 inline comments as done.

address comment

DiggerLin added inline comments.Apr 20 2022, 12:01 PM
clang/lib/Driver/ToolChains/AIX.cpp
80

I do not think there is a benefit "i != Size" over "i < Size" ,https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop
I use the Size = CmdArgs.size() to avoid the evaluating the CmdArgs.size() every time through a loop.

88

thanks

stevewan edited the summary of this revision. (Show Details)Apr 27 2022, 12:05 PM
stevewan edited the summary of this revision. (Show Details)May 3 2022, 9:54 AM
stevewan accepted this revision.May 3 2022, 10:06 AM

LGTM other than some nits.

clang/lib/Driver/Job.cpp
361
clang/test/Driver/aix-ld.c
672–673

And please keep this consistent across the tests.

766–767

Ditto.

816–817

Ditto.

880–881

Ditto.

952–953

Ditto.

This revision is now accepted and ready to land.May 3 2022, 10:06 AM
MaskRay added inline comments.May 3 2022, 11:05 AM
clang/lib/Driver/ToolChains/AIX.cpp
197

Use sys::path::append

201
206

omit braces

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

You may pack more options on one line.
The current style may make the file unnecessarily long.

956

If these options are actually adjacent, check them on the same line to make the test more strict: you can catch issues if new options are somehow inserted in between.

DiggerLin marked an inline comment as done.May 4 2022, 8:14 AM
DiggerLin added inline comments.
clang/test/Driver/aix-ld.c
672–673

using:
CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
CHECK-LD32-SHARED-EXPORTS-NOT: "32"

will be fail on the -X 64 too.

using // CHECK-LD32-SHARED-EXPORTS-NOT: "-X" "32"
will be success on the -X 64.
So I am prefer use the
CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
CHECK-LD32-SHARED-EXPORTS-NOT: "32"

DiggerLin marked 8 inline comments as done.May 4 2022, 10:56 AM
DiggerLin added inline comments.
clang/test/Driver/aix-ld.c
956

yes, the options are actually adjacent now, if we put these option in the same line, there maybe a failure when the driver change the options(for example adding a option) later. and it will have different style on the existing test options

stevewan added inline comments.May 4 2022, 12:30 PM
clang/test/Driver/aix-ld.c
672–673

If this is meant to check also for -X 64. I suggest using proper regex instead of relying solely on the -X check.

DiggerLin updated this revision to Diff 427297.EditedMay 5 2022, 6:26 AM
DiggerLin marked an inline comment as done.

address MaskRay's comment.

if there is no more comment. Can you help to approve it ?, thanks in advance. @MaskRay .

DiggerLin marked 3 inline comments as done.May 5 2022, 6:27 AM
DiggerLin retitled this revision from [AIX][clang][driver] Check the command string to the linker for exportlist opts and to [AIX][clang][driver] Check the command string to the linker for exportlist opts.Jul 7 2022, 9:49 AM

if there is no more comment. Can you help to approve it ?, thanks in advance. @MaskRay @daltenty

Suggest adding the following text to clang/docs/ReleaseNotes.rst under the AIX section with this change:

* When using `-shared`, the clang driver now invokes llvm-nm to create an export list if the user doesn't specify one via linker flag or pass an alternative export control option.
clang/test/Driver/aix-ld.c
691–695

The comment line is strange here, probably a typo:

DiggerLin updated this revision to Diff 455758.Aug 25 2022, 4:43 PM
daltenty accepted this revision.Aug 26 2022, 7:16 AM

LGTM, thanks