-
Notifications
You must be signed in to change notification settings - Fork 303
Use headers as raw headers when generating vsgo projects. #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D81630869. (Because this pull request was imported automatically, there will not be any future comments.) |
|
This is relatively large code changes. I will need one or two days to understand it a little bit more and ensure there is no regression on our internal (massive) projects. |
|
No worries, thank you! Here's the first test I would do to see the difference in practice (using vsgo without this PR):
Actual behavior (without this PR): Two copies of the file will be open in the editor. One with a symlink path and one with source tree path. The version with symlink path will be full of squigglies and intellisense won't work. The other version everything will work. Second test you can do is as follows:
Previous behavior: Lots of paths to |
|
CC @zhaopuw |
|
I generated some solutions for both before and after this change, and I think I found some issue.
(GitHub UI isn't very efficient to spot the difference, might want to other tools for viewing the diff.) Our internal solutions easily pass thousands of projects, with the fact that some of our folder is enormous like "$(RepoRoot)\xplat". If all target root or large directory is included, it stalls Visual Studio completely as Visual Studio needs to enumerate and index all the files in include path. We got bite by the same problem here last year and got around by rigorously examine what included in include paths. |
|
If I’m reading the diff correctly, I’m guessing that somewhere in your codebase, there is the statement if this is correct then i think the new algorithm is actually correct. On the other hand, it obviously is a non starter for visual studio project to fail to load, so we have to find some solution. Possible ideas (just brainstorming)
that being said, i think everyone will benefit from raw headers mode here, because without it — at least for our use cases — Intellisense is totally broken on headers most of the time. So I’d like to find a way to make it the default, but I’m also open to doing whatever change causes the least disruption for you |
|
Here is the include part for the first example, We just buckified https://github.com/Neargye/semver internally with, I then generated solution for target If I understand correctly, this should be the exported public include path for semver library (and thus included when other projects depends on it such as basic_example), While the currently generated include path has an extra I'm all for solving the problems for both internally and externally. We might need to address the rough edges or unintended behavior of this code. In the worst case, we could branch out and do things differently (might caused by macro layer differences etc). |
|
Ok i think i understand. You are using public_include_directories, so in your case Intellisense will already find includes includes in the source tree. we are not using public_include_directories because it causes local builds to break the sandbox and be different than remote builds. 🤔 |
|
Can you confirm that when you right click an include statement in the editor to open the header that way, does the opened file have a symlink path to buck-out, or source tree path? |
|
For this example, I see opened file from the source tree, no buck-out in
the path.
If not public_include_header, what is use in your repo? header namespace?
Only one way?
Meta's codebase is massive, that example is just one I use for quick
validation. Our repo is very much likely have setup in all the different
ways.
…On Thu, Sep 4, 2025 at 16:54 zjturner ***@***.***> wrote:
*zjturner* left a comment (facebook/buck2#1094)
<#1094 (comment)>
Can you confirm that when you right click an include statement in the
editor to open the header that way, does the opened file have a symlink
path to buck-out, or source tree path?
—
Reply to this email directly, view it on GitHub
<#1094 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALC334P7M5RBUANUAMHSP33RDGMFAVCNFSM6AAAAACFSBHNB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTENJWGQ3TIOBTGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
We use headers and exported_headers, but it’s not necessary to use public_include_directories or include_directories when using headers / exported_headers |
|
What if we were to say that it only uses this method if there is an empty |
|
I see. I believe if Can you also do the exercise of generating solutions before and after this PR and diff them? I understand this debugging process is not easy. I can help making this works for both |
|
Just to make sure we're talking about the same thing, what I mean is that suppose I make a change like follows: If Does this sound like a reasonable approach? |
|
FWIW, the reason we don't use |
|
Sounds good. When I say, Meta's targets are setup using both |
|
That’s interesting, I actually find that surprising since I thought that’s the “wrong” way. Can you find an internal target using exported_headers and see if Intellisense works for it? |
|
Build infra people might know this better, and we can also bring the question to them. But based on the doc https://buck2.build/docs/prelude/rules/cxx/cxx_library/ and extensive usage of Checking the case of exported_headers from our internal repo. |
|
I've checked prod example of The library definition, The |
|
If I look closer to that library's intermediate output Maybe there is mode file difference? Or the original examples you're looking at are generated headers during build? |
|
@zjturner I think it's a little hard to debug here since we are using different buck modes. Can you share the buck mode setting on these configs? If your mode doesn't have them can you add these lines to the mode file and see if the original issue persist? |
When you use Then, when generating the argsfile, it will contain something like If you use In the first case (our case), right clicking header file from an open editor in Visual Studio and opening the header file, Intellisense will locate it at In the second case (your case), it will locate it directly in the source tree. I think looking at Then there is no now the compiler gets a
I have never heard of these. I'll look into it. What is this |
This is the part I am trying to figure out here. I can confirm for our case, argsfiles indeed passes But the during VSGO generation, we're not relying on the compiler args (maybe we will eventually), and we're using this heuristic to "guess" the correct include path from the target (before and after this PR). While this heuristic guess works for us (for both public_include_directories and exported_headers cases), but not for your case (exported_headers). That's the part we don't understand yet, and the |
|
Alternatively, it might work better to have a repo setup to reproduce the original issue (or future issue) that both can access. |
Do you also have public_include_directories set on that target? If so both paths will be on the command line in the argsfile. I think I know which heuristic you’re referring to. Maybe one difference is that we always (100% of the time) use a header_namespace (usually “.”) |
That's the
|
Yes it's set for this target. |
|
I haven't had time to come back to this yet, but do you think the issue could be because we're using |
|
I doubt that's the real reason, but you can go ahead modifying the header namespace processing part and see if it changes anything. Though I would be looking very closely at passed in |
vsgo by default uses the actual include path that it passes to the compiler for intellisense purposes. This is obviously correct from a compilation point of view, but it creates serious issues with intellisense usability.
This PR addresses both of these issues by forcing raw headers mode whenever possible. This is only for Intellisense purposes, nothing about the behavior of executing a build is changed. It does this by copying the logic of
headers_as_raw_headersfrom the cxx prelude. Unfortunately I was not able to reuse that function directly out of the prelude since a BxlContext and an AnalysisContext are not compatible types.