This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix expansion of response files in -Wp after integrated-cc1 change
AbandonedPublic

Authored by aganea on Jan 20 2020, 11:17 AM.

Details

Reviewers
hans
thakis
wenlei
Summary

After rGb4a99a061f517e60985667e39519f60186cbb469, passing a response file such as -Wp,@a.rsp wasn't working anymore because .rsp expansion happens inside clang's main() function.

I'm noticing along the way that explicit arguments in -Wp are parsed in the driver, whereas arguments inside a response file are parsed in the -cc1 tool. Is that the desired behavior? This was the previous behavior but I'm not sure it's the right behavior.

Diff Detail

Event Timeline

aganea created this revision.Jan 20 2020, 11:17 AM
aganea edited the summary of this revision. (Show Details)Jan 20 2020, 11:17 AM
wenlei accepted this revision.Jan 20 2020, 11:32 AM

Is that the desired behavior? This was the previous behavior but I'm not sure it's the right behavior.

Good point. It might be safer to keep that previous behavior though.

Thanks for the quick fix, LGTM!

This revision is now accepted and ready to land.Jan 20 2020, 11:32 AM
hans added inline comments.Jan 21 2020, 9:26 AM
clang/tools/driver/driver.cpp
338

This looks pretty hacky.

Can you explain more what the current problem is and how you're proposing to fix it? I'm not familiar with the -Wp flag and how it relates to response files.

aganea marked an inline comment as done.Jan 21 2020, 9:41 AM
aganea added inline comments.
clang/tools/driver/driver.cpp
338

The problem is that for -Wp,@file.rsp, file.rsp is not expanded anymore, because previously it was done in the cc1 process, at L379 below.

This patch calls back into ExecuteClangTool instead of ExecuteCC1Tool. This was my initial proposal for rGb4a99a061f517e60985667e39519f60186cbb469, purposely to fix this issue (which I forgot about)

An alternate way is to duplicate L379 into ExecuteCC1Tool, but I felt that wasn't pretty and opens the door to more code duplication down the line. See D73120 for an alternate implementation.

hans added inline comments.Jan 21 2020, 10:24 AM
clang/tools/driver/driver.cpp
338

I think that if cc1 is supposed to expand response files, then let's make that explicit.

I don't think the "reenter" flag in D73120 is necessary: if cc1 is supposed to expand response files, let's make it do that always.

aganea abandoned this revision.Jan 21 2020, 1:19 PM

Abandoning this in favor of D73120. Please take a look at the other patch.