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

Use llbuild's new content-exclusion-patterns node attribute to prevent it from descending into .build and .git directories #5594

Conversation

abertelrud
Copy link
Contributor

@abertelrud abertelrud commented Jun 15, 2022

This requires the llbuild commit a1adaff2a405c3a74925e60356431050cb9a3a9d, but it does not cause problems if the llbuild being used doesn't yet support this property. Instead it will be ignored.

Also added a dedicated test with a flat package.

We should consider whether any customized scratch directory should also be included in the list. This is a little tricky since the exclusion patterns are applied to all subdirectory name, not just those at the top level. Oddly, in testing I did not repro the problem if I was using a custom scratch directory, so this may not be a issue in practice.

Note that this fixes the problem with doing spurious rebuilds (of which the spurious JSON output is just a symptom) for the case of a flat package structure, where the root directory of the package is considered to be a source directory. We have also seen this output when switching toolchains, which seems to be a completely different problem with similar symptoms.

rdar://93982172

@abertelrud abertelrud self-assigned this Jun 15, 2022
@abertelrud abertelrud added the WIP Work in progress label Jun 15, 2022
@abertelrud
Copy link
Contributor Author

abertelrud commented Jun 16, 2022

I'm actually not sure how a custom scratch directory could be excluded in a way that wouldn't have side effects — at the llbuild level, the exclusion is for directory entries and contains just names (last path components), so if the scratch directory is package-dir/foo then we'd need to exclude foo, which would also eliminate package-dir/bar/foo (for example). In practice this might not actually be a big problem, but there's some more exploration to be done here.

@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud
Copy link
Contributor Author

Confirmed that this fixes the problem, when the latest llbuild is used, and with the test case from #5482. Surprisingly using --scratch-path with something like <proj-dir>/.foo does not seem to cause the problem even though it in theory should still do so. I haven't yet looked into that but I think we should take this fix as it is safe and effective.

…ent it from descending into `.build` and `.git` directories

This requires the llbuild commit a1adaff2a405c3a74925e60356431050cb9a3a9d, but it does not cause problems if the llbuild being used doesn't yet support this property.  Instead it will be ignored.

This adds a dedicated unit test with a flat package.  We should consider whether any customized scratch directory should also be included in the list.  This is a little tricky since the exclusion patterns are applied to all subdirectory name, not just those at the top level.  In testing, it doesn't actually seem to be required, which seems a little surprising.  The fix in this commit is safe and good on its own, and we can consider adding customized scratch paths later once we've looked deeper into that issue.

rdar://93982172
@abertelrud abertelrud force-pushed the eng/93982172-flat-packages-can-cause-spurious-swift-compilation branch from c987281 to f51fc51 Compare June 16, 2022 17:38
@abertelrud
Copy link
Contributor Author

Found a way to reproduce the problem using a test fixture, so I'm adding an end-to-end test as well.

@abertelrud abertelrud changed the title WIP: Use llbuild's new content-exclusion-patterns node attribute to prevent it from descending into .build and .git directories Use llbuild's new content-exclusion-patterns node attribute to prevent it from descending into .build and .git directories Jun 16, 2022
@abertelrud abertelrud added ready Author believes the PR is ready to be merged & any feedback has been addressed and removed WIP Work in progress labels Jun 16, 2022
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud removed the ready Author believes the PR is ready to be merged & any feedback has been addressed label Jun 16, 2022
@abertelrud
Copy link
Contributor Author

@tomerd I managed to find a way to repro and add a unit test here. Wanted to let you know since it's a chance since last you looked.

@abertelrud abertelrud merged commit fb032ac into swiftlang:main Jun 17, 2022
@abertelrud abertelrud deleted the eng/93982172-flat-packages-can-cause-spurious-swift-compilation branch June 17, 2022 04:56
abertelrud added a commit to abertelrud/swift-package-manager that referenced this pull request Jun 17, 2022
…ent it from descending into `.build` and `.git` directories (swiftlang#5594)

This requires the llbuild commit a1adaff2a405c3a74925e60356431050cb9a3a9d, but it does not cause problems if the llbuild being used doesn't yet support this property.  Instead it will be ignored.

This adds a dedicated unit test with a flat package.  We should consider whether any customized scratch directory should also be included in the list.  This is a little tricky since the exclusion patterns are applied to all subdirectory name, not just those at the top level.  In testing, it doesn't actually seem to be required, which seems a little surprising.  The fix in this commit is safe and good on its own, and we can consider adding customized scratch paths later once we've looked deeper into that issue.

rdar://93982172
(cherry picked from commit fb032ac)
abertelrud added a commit that referenced this pull request Jun 17, 2022
…ent it from descending into `.build` and `.git` directories (#5594) (#5599)

This requires the llbuild commit a1adaff2a405c3a74925e60356431050cb9a3a9d, but it does not cause problems if the llbuild being used doesn't yet support this property.  Instead it will be ignored.

This adds a dedicated unit test with a flat package.  We should consider whether any customized scratch directory should also be included in the list.  This is a little tricky since the exclusion patterns are applied to all subdirectory name, not just those at the top level.  In testing, it doesn't actually seem to be required, which seems a little surprising.  The fix in this commit is safe and good on its own, and we can consider adding customized scratch paths later once we've looked deeper into that issue.

rdar://93982172
(cherry picked from commit fb032ac)
@philipturner
Copy link

This seems to have fixed #5482 (#5482 (comment)). Can we add #5505 as a regression test, then close both #5482 and #5505?

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

Successfully merging this pull request may close these issues.

4 participants