This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Claim options which manipulate include paths
AbandonedPublic

Authored by MaskRay on Jun 1 2023, 1:31 PM.

Details

Summary

Claim options which disable include paths in case the pre-processor is not run.

This avoids warnings when, for example, all inputs are objects. Libtool sometimes builds libraries and binaries this way.

Here's an obviously exaggerated example:

clang++ -c test.cpp -o test.o
clang++ -shared test.o -nobuiltininc -nostdinc -nostdlibinc -nostdinc++ -nogpuinc -nohipwrapperinc -ibuiltininc -o testing
clang-16: warning: argument unused during compilation: '-nobuiltininc' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-nostdinc' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-nostdlibinc' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-nogpuinc' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-nohipwrapperinc' [-Wunused-command-line-argument]
clang-16: warning: argument unused during compilation: '-ibuiltininc' [-Wunused-command-line-argument]

These cflags/cxxflags are very often inadvertently passed as part of the link-line, making the warnings annoying (and problematic with -Werror). Most other path-related options are consumed, making the above outliers. If it makes sense for options like -isystem to be consumed, imo it makes sense for options which control those options to be consumed as well.

I'm not familiar with this code, so I largely guessed as to where they should be added.

Diff Detail

Event Timeline

theuni created this revision.Jun 1 2023, 1:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 1:31 PM
theuni requested review of this revision.Jun 1 2023, 1:31 PM
MaskRay commandeered this revision.Jul 1 2023, 8:32 AM
MaskRay abandoned this revision.
MaskRay edited reviewers, added: theuni; removed: MaskRay.

Obsoleted by D151944