I don’t think it’s quite ready for publishing yet (I still need to fix the /Zi bug for example), but I’ll do that in a followup <br><div class="gmail_quote"><div dir="ltr">On Wed, Feb 7, 2018 at 1:46 AM Hans Wennborg via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hans added inline comments.<br>
<br>
<br>
================<br>
Comment at: llvm/tools/msbuild/clang-cl.xml:1<br>
+<?xml version="1.0" encoding="utf-8"?><br>
+<Rule Name="clang-cl" PageTemplate="tool" DisplayName="C/C++" SwitchPrefix="/" Order="10" xmlns="<a href="http://schemas.microsoft.com/build/2009/properties" rel="noreferrer" target="_blank">http://schemas.microsoft.com/build/2009/properties</a>" xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml" rel="noreferrer" target="_blank">http://schemas.microsoft.com/winfx/2006/xaml</a>" xmlns:sys="clr-namespace:System;assembly=mscorlib"><br>
----------------<br>
zturner wrote:<br>
> rnk wrote:<br>
> > hans wrote:<br>
> > > rnk wrote:<br>
> > > > rnk wrote:<br>
> > > > > zturner wrote:<br>
> > > > > > hans wrote:<br>
> > > > > > > zturner wrote:<br>
> > > > > > > > hans wrote:<br>
> > > > > > > > > zturner wrote:<br>
> > > > > > > > > > hans wrote:<br>
> > > > > > > > > > > zturner wrote:<br>
> > > > > > > > > > > > hans wrote:<br>
> > > > > > > > > > > > > I thought you were going to leave the flag logic out of this patch?<br>
> > > > > > > > > > > > I thought Nico said to only separate out the option remapping into another patch. I took all of that out.<br>
> > > > > > > > > > > This file still attempts to duplicate the logic of what flags clang-cl supports, which are ignored, etc. I'd prefer if we didn't do that.<br>
> > > > > > > > > > ><br>
> > > > > > > > > > > To repeat my concerns:<br>
> > > > > > > > > > ><br>
> > > > > > > > > > > 1. This list of flags would need to be maintained, and I expect it will always end up being incomplete or inaccurate in some other way. The only way to keep it accurate would be if it's auto-generated from clang-cl's tablegen file. But that ties it to a specific clang-cl version, which is the next problem<br>
> > > > > > > > > > ><br>
> > > > > > > > > > > 2. It ties it to a particular clang-cl version, which goes against the point of decoupling the VS integration from the toolchain. As a concrete example, your file is missing /arch:AVX512 and /arch:AVX512F, so those should be added, but only when the user is using a Clang >= r323433. Of course the user could them manually, but why should some flags be listed and some not? And maybe we could handle this with version logic, but now we're getting into *really* hairy maintenance.<br>
> > > > > > > > > > I can move this to another patch if you want, but I have to say that presenting a clang-cl tailored UI of the options is something that I feel very strongly about. In fact, the main reason I volunteered to take on this effort is specifically because I wanted to make sure we do this.<br>
> > > > > > > > > ><br>
> > > > > > > > > > We can get into how it would have to be maintained etc, but all of that is irrelevant IMO because I'm approaching this from the perspective of the user. As someone who has used VS pretty heavily for close to 20 years, this is absolutely a large value-add for the user.<br>
> > > > > > > > > ><br>
> > > > > > > > > > To re-iterate though, I don't see where the perceived maintenance comes from. You're already suggesting that I do nothing, which means that the user will already have to manually add options anyway if the version of VS doesn't match up with the version of clang-cl exactly. So what I'm doing here is imperfect (as is the alternative of doing nothing), but is //strictly better//. I don't see how that could be perceived as anything other than a win.<br>
> > > > > > > > > ><br>
> > > > > > > > > > Version logic isn't even that hairy of maintenance. Every time we ship a new LLVM release (which seems to be about once a year), we copy the file and make the 1 or 2 necessary modifications to the copied file.<br>
> > > > > > > > > I think a clang-cl tailored UI would be really nice, but I don't think it's sustainable to maintain this file by hand. If we want to expose clang-cl's options this way, I think we need to auto-generate it from the .td file, and that it needs to be tied to the clang-cl version whose options are being exposed.<br>
> > > > > > > > ><br>
> > > > > > > > > We ship a major release twice a year, typically two more stable (x.0.1) releases per year, and in addition to that I ship snapshots about once or twice a month. If we're going to present clang-cl's options here, I think the file needs to stay in sync with clang-cl's options.<br>
> > > > > > > > Having it be auto-generated from the .td file is a good idea, but it's quite a bit of extra work and it may not be possible to do it in a useful way (for example, MSVC's UI displays the options in categories, which are defined just below this comment in Phab. Having the auto-generated options be correctly categorized seems difficult / impossible).<br>
> > > > > > > ><br>
> > > > > > > > It's worth trying, and if we can do it then I agree it would be worth doing, but in the meantime I think the approach here is still strictly better than doing nothing, even if this file were never touched again (which is unlikely).<br>
> > > > > > > We can add categories to the flags in the .td file.<br>
> > > > > > ><br>
> > > > > > > The "doing nothing" that we currently do is expose Visual Studio's choice of flags and then let clang-cl handle them. I don't think that's terribly bad.<br>
> > > > > > Sure, it's not terribly bad. But I'd like to do something better than just "not terribly bad". :)<br>
> > > > > ><br>
> > > > > > There are other issues with auto-generating the file from the td as well. When an option takes multiple values (such as `/arch:`), the specific values it takes are not always present in the TD file. You mentioned `/arch:AVX512` earlier, but that value is not in the td file anywhere.<br>
> > > > > ><br>
> > > > > > That doesn't mean it's impossible, we can probably address all of the various issues to get the td file to a point where this file could be auto-generated. But I don't think that work should hold this up, as I still maintain that the solution here is strictly better from the user's perspective than the old method of doing nothing.<br>
> > > > > I don't think we'd get much value from table generating them. This file contains a lot of information and organization that we'd have to encode in tablegen. Every option would need its property sheet category, name, and display name, none of which we currently encode.<br>
> > > > ><br>
> > > > > If we did want to automatically fill in undescribed options somehow, I'd suggest storing the property sheet information separately kind of like we currently do for the attribute documentation, and then "joining" the two files in tablegen to make this XML file. I just don't think it's worth it, though.<br>
> > > > I think part of the reason why I don't like the idea of loading this all into tablegen is that editing tablegen files sucks. We have all these ad-hoc conventions for adding line breaks, but there's no editor support for them or anything. I think if they were YAML files, it would be a lot easier to add new fields to options to help us auto-generate property sheets like this or even full HTML command line reference, something we sorely lack today.<br>
> > > ><br>
> > > > Maybe this is just dreaming, but I expect YAML would also make it easier to automatically parse enum values to options, like /arch:avx512 etc. We could do that today, but it requires hacking on and extending this janky Record abstraction that's not well understood. Or maybe it just requires effort and motivation.<br>
> > > But this file is effectively duplicating the information about what flags clang-cl supports. Am I the only one that's concerned about how to maintain that, and the two getting out of sync?<br>
> > ><br>
> > > Olga mentioned (<a href="https://reviews.llvm.org/D42762?id=132243#inline-375127" rel="noreferrer" target="_blank">https://reviews.llvm.org/D42762?id=132243#inline-375127</a>) something about extending rules rather than overwriting them. Would that be an option for us, i.e. just exposing the regular cl options and maybe do a few tweaks where really necessary?<br>
> > I am concerned about the duplication, but I think encoding the information in this XML into TableGen is going to be really ugly. Even if we stored this info outside the tablegen, we'd need some way to "join" the property sheet data with the .td data, which effectively duplicates the list of flags, or at least the supported flags with documentation and display names, similar to the way the attribute reference docs work.<br>
> ><br>
> > Re: Olga's comment, maybe that would work, but I suspect we won't have as much control over the organization.<br>
> extending a rules file only works when you want to add a new category or option, not when you want to remove some options but keep others. So it's not going to save us from the duplication. Personally though I'm not at all concerned about the duplication. If we take the duplicated file as it exists in this CL, and never touch it or maintain it ever again, we would still be providing a better user experience than doing nothing and relying on whatever version happens to ship with Visual Studio.<br>
><br>
> It's extremely unlikely that we would //never// touch it again, however. And in the worst case scenario, if we do ultimately find out that it's too much maintenance, we can change 4 or 5 lines of xml to disable our custom rules file, push an update to the marketplace, and people will automatically get updated to the new version.<br>
"If we take the duplicated file as it exists in this CL, and never touch it or maintain it ever again, we would still be providing a better user experience than doing nothing and relying on whatever version happens to ship with Visual Studio."<br>
<br>
I'm not sure I agree, but I think this has been reviewed to exhaustion. Go ahead and submit, please publish under the <a href="mailto:llvm-vs-code-extensions@google.com" target="_blank">llvm-vs-code-extensions@google.com</a> account, and I guess we'll see how it works out.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D42762" rel="noreferrer" target="_blank">https://reviews.llvm.org/D42762</a><br>
<br>
<br>
<br>
</blockquote></div>