Skip to content

[VFS] Add a "redirecting-with" field to overlays #3990

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

Merged

Conversation

bnbarham
Copy link

Cherry-picks commits needed to to support the new "redirecting-with" field to overlays. Previously reverted in #3918 as a few Swift tests were failing on some platforms. This is fixed in 66b60bf, which makes sure to use the generic_category for VFS errors.

The new field can be used to specify which filesystem and path the RedirectingFileSystem should try first.

Resolves rdar://87906715.

Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

Differential Revision: https://reviews.llvm.org/D117937
This fixes lldb's build. We can remove this in the future if we want but
for now this will be nicer to existing consumers.
Errors are generally checked in clients by comparing to the portable
error condition in `std::errc`, which will have the `generic_category`
(eg. `std::errc::no_such_file_or_directory`). While in practice these
are usually equivalent for the standard errno's, they are not in *all*
implementations. One such example is CentOS 7.

Differential Revision: https://reviews.llvm.org/D120299
@bnbarham bnbarham requested a review from akyrtzi February 23, 2022 22:54
@bnbarham
Copy link
Author

@swift-ci please test

Mark clang as being able to use the new `redirecting-with` property in
VFS overlays.

Resolves rdar://87906715.
@bnbarham
Copy link
Author

@swift-ci please test

@bnbarham
Copy link
Author

@swift-ci please test Linux platform

@bnbarham bnbarham merged commit b0b5a83 into swiftlang:stable/20211026 Feb 25, 2022
@bnbarham bnbarham deleted the cherry-redirecting-with-again branch February 25, 2022 00:03
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.

2 participants