This is an archive of the discontinued LLVM Phabricator instance.

[driver] Add a -builtininc flag that lets Darwin driver include Clang builtin headers even with -nostdinc
ClosedPublic

Authored by arphaman on Jan 27 2020, 1:05 PM.

Details

Summary

Some projects use -nostdinc, but need to access some intrinsics files when building specific files. The new -builtininc flag lets them use this flag when compiling these files to ensure they can access Clang's builtin headers.

Diff Detail

Event Timeline

arphaman created this revision.Jan 27 2020, 1:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2020, 1:05 PM
dexonsmith requested changes to this revision.Jan 27 2020, 2:40 PM
dexonsmith added inline comments.
clang/include/clang/Driver/Options.td
503–504

I think -ibuiltininc might be better, since we already have lots of options that start with -i related to include paths. Please also clarify in the HelpText that this overrules -nostdinc even if -nostdinc comes later.

clang/lib/Driver/ToolChains/Darwin.cpp
1885–1890

It's probably better to let -ibuiltininc and -nobuiltininc cancel each other out, via a "last one wins" rule. If you agree, consider documenting the behaviour also in the HelpText.

This revision now requires changes to proceed.Jan 27 2020, 2:40 PM
arphaman updated this revision to Diff 241029.Jan 28 2020, 5:06 PM
arphaman marked 2 inline comments as done.

Add suggested changes. The -ibuiltininc flag now interacts with -nobuiltininc as well, i.e. it's cancelled out if -nobuiltininc comes after it, and vice-versa.

dexonsmith accepted this revision.Jan 28 2020, 5:41 PM

Okay, LGTM.

This revision is now accepted and ready to land.Jan 28 2020, 5:41 PM

Should they use -nostdlibinc instead?

Should they use -nostdlibinc instead?

Unfortunately they can't control the flag in this specific case, only add flags for specific files.

This revision was automatically updated to reflect the committed changes.

Should they use -nostdlibinc instead?

Unfortunately they can't control the flag in this specific case, only add flags for specific files.

To make sure I understand it correctly.

There is a project using -nostdinc. It still accesses intrinsics headers, so -ibuiltininc is added to make it work. The new option requires a new release of clang. Is it really more convenient adding a new option than teaching the project to use -nostdlibinc instead of -nostdinc?