Skip to content
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

Core Gradle header dependencies is sensitive to the source ordering #864

Open
lacasseio opened this issue May 14, 2024 · 2 comments
Open

Comments

@lacasseio
Copy link
Member

Because of this condition in DefaultIncrementalCompileSourceProcessor, the order in which Gradle process the source file will affect what headers are discovered. It boils down to the fact that if Gradle processes a file containing a macro include and discovers more defines for the macro - e.g. BOOST_PP_FILENAME_1 - the result will depend on whether or not the new definitions are found before or after the macro include was resolved. The condition tries to handle include cycles but disregards the case when the cycle has additional "visible macros". This particular case will be problematic if the source ordering is not stable.

We have seen the ordering issues with the source files, which we are still tracking down. For now, the simplest patch seems to simply order the source files before processing them.

@Kelly12612
Copy link

Hi Daniel, we ran into an issue like this on Windows, when the case of the #include didn't match the case of the file itself, this resulted in longer builds/rebuilds and other sorts of issues. You helped us come up with a workaround in "GLM" (the gradle legacy gitub project which is meant to be an example of converting an older project to gradle/Nokee).

@lacasseio
Copy link
Member Author

This issue is a bit different than the one we encountered. This one breaks Gradle cacheability when compiling against complicated preprocessor libraries such as Boost. The issue is twofold: 1) FileTree ordering is not guaranteed and 2) Gradle can/may/will discover a different set of headers between builds because of the unguaranteed ordering.

The first part seems to be inconsistent between operating systems which is why this issue was complicated to diagnose. Officially, the documentation states: "The order of the files in a FileTree is not stable, even on a single computer." In practice, it seems the ordering is stable under some operating system (i.e. on macOS, I was never able to reproduce the issue but a client reproduced it consistently under Linux).

The second part is very flaky. Because of the conditions outlined in the description, if there are additional macro definitions to discover after realizing a macro includes, Gradle can discover a different set of headers. If the FileTree ordering is indeed not stable on your machine but the project isn't that big, Gradle may discover a different set of headers. Finally, if the project is sizable, Gradle will discover a different set of headers.

We validated a fix that ensures stability but will not fix the underlying issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants