This is an archive of the discontinued LLVM Phabricator instance.

Revert "[Driver] Remove Joined -X"
ClosedPublic

Authored by rsundahl on Dec 9 2022, 7:16 AM.

Details

Summary

This change is breaking internal builds. We use the -Xfoo pattern but can
now no longer manage whether we allow an unused -Xfoo option to pass as a
warning or promote it to an error.

This reverts commit 98615fd376cea15af21e120e0e3ffa5ba68c2b6d.

Diff Detail

Event Timeline

rsundahl created this revision.Dec 9 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 7:16 AM
rsundahl requested review of this revision.Dec 9 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 7:16 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This is missing a test, like the original commit mentioned.
Why can you not just use the the split variant, -X clang ...?

davide added a comment.Dec 9 2022, 9:11 AM

This is missing a test, like the original commit mentioned.
Why can you not just use the the split variant, -X clang ...?

This breaks many projects internally. There's no real complexity to keep this around. Removing is more annoying than anything else.
I agree on the test, that has to be added.

The removal is also breaking ChromeOS builds which use -Xpattern in some cases.

The removal is also breaking ChromeOS builds which use -Xpattern in some cases.

Do you have a justifying example showing which -Xpattern is used? It needs to do useful work, instead of just using an option which happened to be ignored (and probably not ignored by GCC).

This change is breaking internal builds. We use the -Xfoo pattern but can now no longer manage whether we allow an unused -Xfoo option to pass as a warning or promote it to an error.

Which -Xfoo is used? Do your internal builds reserve -Xfoo as a placeholder to do other non-upstream work? Then you can consider -Gfoo if your builds don't need the mips semantics.
Is it possible to clean up the previously-ignored-with-a-warning -Xfoo?

We use -Xcompiler and -Xlinker which are passed in programs and they raise error now.

This change is breaking internal builds. We use the -Xfoo pattern but can now no longer manage whether we allow an unused -Xfoo option to pass as a warning or promote it to an error.

Which -Xfoo is used? Do your internal builds reserve -Xfoo as a placeholder to do other non-upstream work? Then you can consider -Gfoo if your builds don't need the mips semantics.

We use -Xparser

Is it possible to clean up the previously-ignored-with-a-warning -Xfoo?

Possibly. Maybe preferably. Builds are breaking now though. Dependent projects would have to be notified and changes scheduled. Was there a diff that we should have been part of? It looks like at least two of us are surprised with downstream consequences.

This change is breaking internal builds. We use the -Xfoo pattern but can now no longer manage whether we allow an unused -Xfoo option to pass as a warning or promote it to an error.

Which -Xfoo is used? Do your internal builds reserve -Xfoo as a placeholder to do other non-upstream work? Then you can consider -Gfoo if your builds don't need the mips semantics.
Is it possible to clean up the previously-ignored-with-a-warning -Xfoo?

@MaskRay -- we can discuss options but we can't just "kill" options willy-nilly just because you don't use them.
A better way of doing this would be marking them as deprecated, wait one release and then remove. Going cold turkey breaks clients you never heard of, and you didn't even warn.

Let's add a test and revert this patch, then we can continue the discussion on how to phase this out.

We use -Xcompiler and -Xlinker which are passed in programs and they raise error now.

Sorry, I do not understand. clang -Xlinker --verbose a.c works well. -Xcompiler is invalid in GCC. How do your programs use -Xlinker or -Xcompiler.
If -Xcompiler foo is used similar to -Xclang foo, it seems very wrong to silently ignore -Xcompiler as foo will be seen as a positional argument...

MaskRay added a comment.EditedDec 15 2022, 12:14 AM

This change is breaking internal builds. We use the -Xfoo pattern but can now no longer manage whether we allow an unused -Xfoo option to pass as a warning or promote it to an error.

Which -Xfoo is used? Do your internal builds reserve -Xfoo as a placeholder to do other non-upstream work? Then you can consider -Gfoo if your builds don't need the mips semantics.

We use -Xparser

There are two possibilities.

First, your downstream projects incorrectly pass a previously-ignored -Xparser. Then it seems the right call is to remove it.

Second, there are many projects doing -Xparser and it was intentionally ignored. Another program would analyze -Xparser.

For the second case, we can add an ignored Flag called -Xparser, with a comment which tool uses it.
We should not call it IgnoreGCCCompat as GCC doesn't recognize -Xparser.

We should try avoiding a broad -X*. If you want to carve out a larger namespace, say, -Xparser*, it may be fine as well. But calling it IgnoreGCCCompat with some vendor-specific undocumented thing seems not right.

Is it possible to clean up the previously-ignored-with-a-warning -Xfoo?

Possibly. Maybe preferably. Builds are breaking now though. Dependent projects would have to be notified and changes scheduled. Was there a diff that we should have been part of? It looks like at least two of us are surprised with downstream consequences.

See the previous paragraph. And we need a clang/test/Driver test to catch accidental removal from other contributors.

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

This change is breaking internal builds. We use the -Xfoo pattern but can now no longer manage whether we allow an unused -Xfoo option to pass as a warning or promote it to an error.

Which -Xfoo is used? Do your internal builds reserve -Xfoo as a placeholder to do other non-upstream work? Then you can consider -Gfoo if your builds don't need the mips semantics.

We use -Xparser

There are two possibilities.

First, your downstream projects incorrectly pass a previously-ignored -Xparser. Then it seems the right call is to remove it.

It is not. You first deprecate and then you remove. This commit needs to be reverted.

HTH,

D

rsundahl updated this revision to Diff 483297.Dec 15 2022, 12:18 PM

Added the test warn-not-error-Xfoo

I added a test so we can catch any regression. If we choose to deprecate then we can modify the test to watch for the "is deprecated" message that should be asserted for "some time" appropriate. Thank you all for your input.

davide accepted this revision.Dec 15 2022, 3:58 PM

LGTM

This revision is now accepted and ready to land.Dec 15 2022, 3:58 PM
This revision was automatically updated to reflect the committed changes.

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

Can you give an example how they use -Xcompiler?

% gcc -Xcompiler,-fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler,-fpic’
% gcc -Xcompiler -fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler’; did you mean ‘--compile’?

My commit message clearly says why the joined form is awkward and should be removed.
It seems that the many occurrences you found are likely for GNU libtool (-Xcompiler foo -Wc,foo), not for Clang Driver.

Added the test warn-not-error-Xfoo

-Xfoo leads to a warning (expected) which is weird. Can you change it to a form which actually reflects how -X is used? (aka -Xparser)

I am not sure adding arbitrary -X* which leads to a -Wunused-command-line-argument warning is useful. It certainly leads to confusion why this is supported at all, if the needs are just -Xparser.

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

Can you give an example how they use -Xcompiler?

% gcc -Xcompiler,-fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler,-fpic’
% gcc -Xcompiler -fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler’; did you mean ‘--compile’?

My commit message clearly says why the joined form is awkward and should be removed.
It seems that the many occurrences you found are likely for GNU libtool (-Xcompiler foo -Wc,foo), not for Clang Driver.

This is not about the philosophical correctness of the patch, it's about the transition period and allowing consumers to migrate.
If you want remove options, provide a deprecation window, and then remove. Noone is objecting about that.

MaskRay added a comment.EditedDec 16 2022, 9:28 AM

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

Can you give an example how they use -Xcompiler?

% gcc -Xcompiler,-fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler,-fpic’
% gcc -Xcompiler -fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler’; did you mean ‘--compile’?

My commit message clearly says why the joined form is awkward and should be removed.
It seems that the many occurrences you found are likely for GNU libtool (-Xcompiler foo -Wc,foo), not for Clang Driver.

This is not about the philosophical correctness of the patch, it's about the transition period and allowing consumers to migrate.
If you want remove options, provide a deprecation window, and then remove. Noone is objecting about that.

-Xparser has always been leading to such a warning: warning: argument unused during compilation: '-Xparser' [-Wunused-command-line-argument], perhaps since forever when the option was added in the first place?
The message is different from ... deprecation ... but isn't it sufficient as well?

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

Can you give an example how they use -Xcompiler?

% gcc -Xcompiler,-fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler,-fpic’
% gcc -Xcompiler -fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler’; did you mean ‘--compile’?

My commit message clearly says why the joined form is awkward and should be removed.
It seems that the many occurrences you found are likely for GNU libtool (-Xcompiler foo -Wc,foo), not for Clang Driver.

This is not about the philosophical correctness of the patch, it's about the transition period and allowing consumers to migrate.
If you want remove options, provide a deprecation window, and then remove. Noone is objecting about that.

-Xparser has always been leading to such a warning: warning: argument unused during compilation: '-Xparser' [-Wunused-command-line-argument], perhaps since forever when the option was added in the first place?
The message is different from ... deprecation ... but isn't it sufficient as well?

Yes. it is. "unused" doesn't mean "will go away".
Sometimes if you pass linker flags to the compiler you get the same "unused" warning. Noone expects them to go away.

Hope this helps.

MaskRay added a comment.EditedDec 16 2022, 9:39 AM

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many packages. Whether or not GCC supports it is not relevant. Please do not remove options just because you do not use them.

Can you give an example how they use -Xcompiler?

% gcc -Xcompiler,-fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler,-fpic’
% gcc -Xcompiler -fpic -c a.c
gcc: error: unrecognized command-line option ‘-Xcompiler’; did you mean ‘--compile’?

My commit message clearly says why the joined form is awkward and should be removed.
It seems that the many occurrences you found are likely for GNU libtool (-Xcompiler foo -Wc,foo), not for Clang Driver.

This is not about the philosophical correctness of the patch, it's about the transition period and allowing consumers to migrate.
If you want remove options, provide a deprecation window, and then remove. Noone is objecting about that.

-Xparser has always been leading to such a warning: warning: argument unused during compilation: '-Xparser' [-Wunused-command-line-argument], perhaps since forever when the option was added in the first place?
The message is different from ... deprecation ... but isn't it sufficient as well?

Yes. it is. "unused" doesn't mean "will go away".
Sometimes if you pass linker flags to the compiler you get the same "unused" warning. Noone expects them to go away.

Hope this helps.

Sorry, it doesn't help. A compiler option used a linker option leading to a "unused" warning is very different from this case.
I can understand that many CFLAGS options may end up in linking with a -Wunused-command-line-argument warning.
For practicality we must support them, as they are used in other phases.

In your case, at least as stated in the commit message, This change is breaking internal builds. (This message, if not from an affiliation with much contribution to Clang, might be conceived as weird by a casual contributor.)
This is only for -Xparser. Then why can't you just add a def : Flag<["-"], "Xparser">?

It seems that GCC < 4.6 reports g++: unrecognized option '-Xfoo' but exit with 0 while GCC >= 4.6 reports g++: error: unrecognized option '-Xaaa' and exits with 1.
I don't think GCC ever supports -Xcompiler or -Xparser, so IgnoredGCCCompat is not justified.