-
Notifications
You must be signed in to change notification settings - Fork 128
Implement support for ifdefs in header file parsing #1980
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
Conversation
The CreateRuntimeRootDescriptorFile task parses some header files from the CoreCLR and produces an XML descriptor. This change adds support for understanding simple ifdefs. Also added tests.
|
The dotnet/runtime counterpart to this change is here: dotnet/runtime#51562 |
marek-safar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me but not sure if we need it. I think we have task that can merge XMLs files together in runtime already
| { | ||
| int ifdefLength = 0; | ||
| bool negativeIfDef = false; | ||
| if (def.StartsWith ("#ifdef ")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to just run the C/C++ preprocessor on the file instead of building a poor man's version of the preprocessor into this task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've investigated what it would take to use C/C++ preprocessor:
- We can't really run it during coreclr build - it would mean that building CoreLib requires output from CoreCLR build - which is a new dependency and the infra team really doesn't like this (it would also mean that
dotnet buildon CoreLib would basically never work fully). - Running CMake from CoreLib build is a possibility, but it's complex and probably slow (we already have 3 places we start native build pipeline in the runtime repo, this would introduce a new one - while we're trying hard to go down to just 1 place ideally).
- That leaves running the preprocessor directly (without CMake) from the CoreLib build. This is probably not that hard since we have scripts to find the compiler path - Windows to get cl.exe on PATH, Linux, macOS to get clang path into CC/CXX. That said it's still not exactly easy as we would be adding a new thing into the pipeline for CoreLib - the risk here is that we have to construct the compiler command line by hand - making that work on all the platforms could be time consuming.
- This also comes with a downside - we would not run it in the same environment as within CoreCLR build, for example we would have to propagate the defines manually.
In the meantime, there's a request to add additional logic to this process to be able to specify that some of the roots should be added behind a feature switch (built-in COM support), which puts additional pressure on making this happen.
So the proposal is:
- Keep the current "hacky" solution (merge this PR and then the one in runtime)
- Define new macros for the feature switch support so that we express that in a C++ syntax - but still use the "hacky" parser for it
- File an issue to improve this in the future - documenting the knowledge from the investigation done so far.
What do you think @jkotas ?
/cc @LakshanF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thank you for looking into this.
File an issue to improve this in the future
The ultimate plan would be to switch to the same plan that Mono is on: Capture the dependencies introduced by the VM side explicitly by regular DynamicDependency attributes (and probably also convert more of the VM logic to C# so that it is maintainable). This whole task can then disapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed dotnet/runtime#51991 to track this
The |
The CreateRuntimeRootDescriptorFile task parses some header files from the CoreCLR and produces an XML descriptor. This change adds support for understanding simple ifdefs. Commit migrated from dotnet/linker@307f6b0
The CreateRuntimeRootDescriptorFile task parses some header files from the CoreCLR and produces an XML descriptor. This change adds support for understanding simple ifdefs.
Also added tests.
This is the mono/linker part of fix for #1973