This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Handle AIX Include management in the driver
ClosedPublic

Authored by ShuhongL on Jun 26 2020, 12:20 PM.

Details

Summary

Modify the AIX clang toolchain to include AIX dependencies in the search path

Diff Detail

Event Timeline

ShuhongL created this revision.Jun 26 2020, 12:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2020, 12:20 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ShuhongL retitled this revision from Modify AIX customized clang driver toolchain to include AIX system headers in search path to [AIX] Modify AIX customized clang driver toolchain to include AIX system headers in search path.Jun 26 2020, 12:20 PM
ShuhongL updated this revision to Diff 273819.Jun 26 2020, 12:51 PM
ShuhongL retitled this revision from [AIX] Modify AIX customized clang driver toolchain to include AIX system headers in search path to [Clang] Handle AIX Include management in the driver.
ShuhongL edited the summary of this revision. (Show Details)
stevewan added inline comments.Jun 26 2020, 1:33 PM
clang/lib/Driver/ToolChains/AIX.cpp
169

I don't think this is the revision you intended to post.

stevewan marked an inline comment as done.Jun 26 2020, 3:17 PM
stevewan added inline comments.
clang/lib/Driver/ToolChains/AIX.cpp
169

This is a stale comment, please ignore.

ShuhongL updated this revision to Diff 274210.Jun 29 2020, 12:51 PM

Added testcase for the clang toolchain changes

daltenty added inline comments.Jun 30 2020, 7:27 AM
clang/test/Driver/aix-toolchain-include.cpp
2

nit: aix->AIX
nit: period at end of comment.

6

I think we should test the 64-bit target as well.

16

Same comment as above

ShuhongL updated this revision to Diff 274519.Jun 30 2020, 9:24 AM
daltenty added inline comments.Jun 30 2020, 12:56 PM
clang/test/Driver/aix-toolchain-include.cpp
9

I don't think we need a separate check prefix for 32/64-bit cases, just the RUN statements. Since the expected output is the same they can share the same prefix.

ShuhongL updated this revision to Diff 275111.Jul 2 2020, 7:28 AM
ShuhongL marked 2 inline comments as done.
ShuhongL marked 2 inline comments as done.
daltenty accepted this revision.Jul 2 2020, 8:22 AM

LGTM other than minor nit

clang/test/Driver/aix-toolchain-include.cpp
14

nit: we usually put the 32-bit / 64-bit run lines together before the CHECK block for readabliity

This revision is now accepted and ready to land.Jul 2 2020, 8:22 AM
clang/lib/Driver/ToolChains/AIX.cpp
181

This does not observe --sysroot.

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

Please investigate the handling of OPT_nostdlibinc.

daltenty requested changes to this revision.Jul 2 2020, 11:21 AM
daltenty added inline comments.
clang/lib/Driver/ToolChains/AIX.cpp
174

If we are looking at this, should we also consider adding /usr/local/include?

This revision now requires changes to proceed.Jul 2 2020, 11:21 AM
clang/lib/Driver/ToolChains/AIX.cpp
174

It seems that, unlike what I found on Linux, the AIX versions of GCC and XL C/C++ do not include /usr/local/include. It seems this is a legitimate platform difference that we should respect.

ShuhongL updated this revision to Diff 275220.Jul 2 2020, 1:51 PM
ShuhongL updated this revision to Diff 275221.Jul 2 2020, 1:56 PM

Modified changes:

  1. Add sysroot
  2. return if options::OPT_nostdlibinc is specified, and will not add /usr/local/include to the path since it's different from other system (linux,darwin etc.)
ShuhongL marked 5 inline comments as done.Jul 2 2020, 2:02 PM
clang/lib/Driver/ToolChains/AIX.cpp
181

Minor nit: Use full sentences in comments with proper capitalization for English writing.

183

My understanding is that -nostdlibinc does not suppress the inclusion of the "builtin" headers.

clang/test/Driver/aix-toolchain-include.cpp
2

s/that AIX/that the AIX/;

4

Minor nit: Remove the space after the slash.

41

There should be testing for -nostdlibinc as well.

ShuhongL updated this revision to Diff 275396.Jul 3 2020, 8:02 AM
  • nostdlibinc should not suppress clang builtin headers
  • Add tests for nostdlibinc and nobuiltininc
  • fix lint
ShuhongL marked 5 inline comments as done.Jul 3 2020, 8:03 AM

Aside from one comment; LGTM. Thanks.

clang/test/Driver/aix-toolchain-include.cpp
5

I think there should be a clang (as opposed to clang++) test as well. Duplicate this invocation and use clang with -xc.

ShuhongL updated this revision to Diff 275432.Jul 3 2020, 10:20 AM

Add clang -xc tests

stevewan accepted this revision.EditedJul 3 2020, 11:44 AM

LGTM with minor nit.

I took a look at the failed tests in premerge checks, they didn't seem to be related, but please double check before you commit.

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

Can we rewrite this block of code so that it's in consistent with the previous one?

if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
  // Add <sysroot>/usr/include.
  SmallString<128> UP(Sysroot);
  path::append(UP, "/usr/include");
  addSystemInclude(DriverArgs, CC1Args, UP.str());
}
clang/lib/Driver/ToolChains/AIX.cpp
197

I think the current expression with the early exit is friendlier for future expansion. @daltenty, do you have an opinion on this?

daltenty accepted this revision.Jul 3 2020, 2:05 PM

LGTM

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

I tend to agree, everything below this point should be standard system includes that all should get ignored with nostdlibinc so I think the early exit makes sense.

This revision is now accepted and ready to land.Jul 3 2020, 2:05 PM
This revision was automatically updated to reflect the committed changes.