A new option -I is added for dxc mode.
It is just alias of existing cc1 -I option.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'm confused by the ways this option is allowed to be specified
clang/include/clang/Driver/Options.td | ||
---|---|---|
6880 | I'm not sure why this has the suffix "Conflict" In addition, you can't currently specify the "I" option with "--" in DXC. | |
clang/test/Driver/dxc_I.hlsl | ||
2 | test.h is kind of a funny name for a directory. 🤔 Maybe just call it "test"? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6905 | This option has the same behavior between DXC and clang, is there a reason we need to define a new option value instead of reusing the existing one? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6905 | As a note, the I_Group only has the -I flag, so we probably can just make I_Group valid for DXC. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6880 | The conflict happened with clang-cl which use same prefix ("/", "-") as dxc. def _SLASH_I : CLJoinedOrSeparate<"I">, HelpText<"Add directory to include search path">, MetaVarName<"<dir>">, Alias<I>; | |
6905 | clang -I is CC1Option,CC1AsOption,FlangOption,FC1Option. We need one for dxc mode with prefix "/", "-". But it conflict with _SLASH_I for clang-cl. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6880 | Our option’s behavior is the same as _SLASH_I, so why can’t we reuse it instead of re-implementing it. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6880 | You mean add DXCOption flag for _SLASH_I? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6880 | It is preferable to add DXCOption to existing options rather than declaring new options for everything. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6367 | Do we need this group or can it just be cl_Group? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6367 | Yes. Without the group, it fails. |
This change works and avoids the duplicated group. The duplicated group results in the help spew duplicating the group heading, which is undesirable.
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 6dd4ec82d376..2dcdbae4385d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6310,10 +6310,7 @@ def defsym : Separate<["-"], "defsym">, // clang-cl Options //===----------------------------------------------------------------------===// -def cl_Group : OptionGroup<"<clang-cl options>">, Flags<[CLOption]>, - HelpText<"CL.EXE COMPATIBILITY OPTIONS">; - -def cl_dxc_Group : OptionGroup<"<clang-cl options>">, Flags<[CLDXCOption]>, +def cl_Group : OptionGroup<"<clang-cl options>">, Flags<[CLDXCOption]>, HelpText<"CL.EXE COMPATIBILITY OPTIONS">; def cl_compile_Group : OptionGroup<"<clang-cl compile-only options>">, @@ -6344,7 +6341,7 @@ class CLJoinedOrSeparate<string name> : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, Group<cl_Group>, Flags<[CLOption, NoXarchOption]>; class CLDXCJoinedOrSeparate<string name> : Option<["/", "-"], name, - KIND_JOINED_OR_SEPARATE>, Group<cl_dxc_Group>, Flags<[CLDXCOption, NoXarchOption]>; + KIND_JOINED_OR_SEPARATE>, Group<cl_Group>, Flags<[CLDXCOption, NoXarchOption]>; class CLCompileJoinedOrSeparate<string name> : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, Group<cl_compile_Group>, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index bc26f0d279a2..ee72f0fcb54c 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6238,6 +6238,10 @@ Driver::getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const { } else { ExcludedFlagsBitmask |= options::DXCOption; } + + if (!IsClCompatMode && !IsDXCMode()) + ExcludedFlagsBitmask |= options::CLDXCOption; + return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); }
clang/include/clang/Driver/Options.td | ||
---|---|---|
6362 | i am failing to understand the semantics of this new option group, and it's causing regressions in clangd. see https://github.com/clangd/clangd/issues/1292. is this new group suppose to serve flags that are available both in --driver-mode=cl and --driver-mode=dxc? i.e. they are for the flags in the intersection? why didn't we go for just adding DXCOption mode into here, if every option in CL mode is actually applicable to DXC option as well, rather than introducing a new option? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6362 | DXC does not support all the CL options, and vice versa. There are some shared options, which is what this group tries to capture. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
6362 | okay thanks for the explanation. i'll fix it on the clangd side since the new option group seems to be necessary indeed (or we actually need to disentangle the include/exclude logic inside the driver). it's still a little bit unfortunate that we actually need a new option flag just because we actually need to perform both inclusions and exclusions of options (i.e. we can't simply let this be CLOption | DXCOption, because being in --driver-mode=dxc would actually disable all options marked with CLOption). WDYT @jansvoboda11 @MaskRay (as owners for driver and compiler options) ? Is this something that has been on your radar? |
BTW, I am not sure when the new DXC driver mode was introduced but ATM it isn't properly handled by clang-tooling APIs, especially clangd. As the logic there wasn't updated accordingly, and it also resulted in regressions for clang-cl mode. I've sent out https://reviews.llvm.org/D133962 to remedy the regressions at least (which needs to be cherry-picked into next minor release I am afraid).
This is actually probably causing bigger troubles at the moment as a file that starts with /I will actually be treated as an include search path, rather than the input of the compilation, in places where CLDXC flags aren't excluded.
It would be nice to monitor new driver mode introductions to make sure they're not making the logic more complicated, as parsing needs to happen in other places as well (clangd, lld, lldb and a bunch of other tools parse compile flags themselves) and this logic gets duplicated into those places because driver doesn't have a public interface that exposes this (mostly because getIncludeExcludeOptionFlagMasks is complicated, and it's more complicated after this new driver mode).
Not supporting new driver modes in those tools, unless explicitly implemented, is probably OK, but it's really unfortunate that they'll break silently (due to changes similar to this). Because even if we were to test for all of the existing flags in those tools, we can't really test for possible flags that might be added in the future, which might all of a sudden change a filename to a command line option as seen here.
I think we had no expectation that DXC-mode would be supported by the tooling APIs at this point.
For context, DXC is the HLSL compiler that is based on clang-3.7. The DXC mode provides interface compatibility with it. DXC doesn't work with any of the clang tooling infrastructure, and clang's HLSL support isn't complete enough that people are going to be relying on tooling. I expect that we'll make larger investments in the Tooling library as we get further along in the HLSL implementation.
Right, and as I mentioned in my previous comments this is completely fine, at least in the start. because as more and more developers start working with your toolchain, they'll also start using clang-tools and their bugs will be on us, rather than the maintainers of these toolchain/driver modes. which I believe puts the pressure on the wrong end, because we cannot even know what the intended way of handling these flags are, let alone knowing about the details of file discovery etc. that turns out to be a problem if not done properly.
My main complaint here's around breaking functionality for existing driver-modes/toolchains, and I am asking either getting OWNERS approvals going forward or being more through with the changes or changing the design overall to make these less complicated.
I understand your frustration with the regression, but let’s try to constructive. We all care about quality and we’re all working hard to do the best we can.
Regressions happen. There are things we can do to avoid them (code review being one), but the most fool-proof way to avoid regressions is test coverage. Here we had a gap in test coverage of existing functionality. A new change went in, all the tests passed, but an important usage regression occurred. It is unfortunate, but it happened.
Getting owner approval before commit has never been required by our developer policy. In fact, the wording of the policy puts the onus on the owner for post-commit review. In this case we had a fairly innocuous seeming change by a relatively new contributor and I reviewed and approved it because it seemed fairly innocuous. This said, hopefully the recent changes in Clang code ownership will help here too.
This change was tested, and introduces a new test in accordance with our community standards and policy.
I don’t think it is fair to say this change contributed to a complicated design other than that llvm’s libOption is pretty complicated and has lots of difficult to see edge cases, and the tools that share option parsing logic often have disparate and duplicated logic for handing those options which can cause a variety of issues.
In terms of your other complaints around bug handling; I also understand frustration there. Unfortunately, clangd has a separate bug reporting and tracking process from the rest of the LLVM and Clang code it depends on. I’m sure it is frustrating to get bug reports that relate to code you didn’t write or design, but I think that is a reality of the process and complexity of the software that we have today. It is incredibly common in LLVM for bugs to get routed to the wrong area and need to be rerouted. Sometimes this is because users reporting issues don’t understand the architecture of the code base well enough to route to the right place, other times it is because the cultural boundaries of responsibility in LLVM aren’t well codified.
In order to support the incremental implementation process that LLVM has always used we need a way to be able to add driver and language modes incrementally. If there’s a gap in the Tooling testing or architecture we can change to make that better, let’s please discuss that, rather than trying to apply additional hurdles to a review process because a regression was introduced.
i am failing to understand the semantics of this new option group, and it's causing regressions in clangd. see https://github.com/clangd/clangd/issues/1292.
is this new group suppose to serve flags that are available both in --driver-mode=cl and --driver-mode=dxc? i.e. they are for the flags in the intersection?
are there any flags that are applicable to CL driver mode but not to the DXC mode (and vice versa)?
why didn't we go for just adding DXCOption mode into here, if every option in CL mode is actually applicable to DXC option as well, rather than introducing a new option?