Skip to content

Conversation

cachemeifyoucan
Copy link

Fix the proper laying of the llvm library by splitting CAS reference away from FileSystem references.

This has some behavior changes:

  • The common base class for FileSystem configured with a CAS-backing is now llvm::cas::CASBackedFileSystem and migrate CAS related FileSystem APIs to the new class.
  • ThreadSafeFileSystem is folded into CASBackedFileSystem to avoid diamond class hierachies.
  • llvm::vfs::File needs to be RTTIExtended, so that a user can tell if the file is CAS backed when there are overlaying file system.
  • When configured with multi-layer CAS backed file system, the file content is available in every CAS along the way the file is resolved and the returned CASID is from the top layer. This is a more deterministic behavior than current one, that only the lowest level CAS has the reference, and user actually don't know which CAS it is associated with unless know in advance which layer vended the file.

@cachemeifyoucan
Copy link
Author

@swift-ci please test llvm


/// Get CASBackedFile for read.
virtual llvm::Expected<std::unique_ptr<CASBackedFile>>
openCASBackedFileForRead(const Twine &Path) = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for having this be a separate API instead of just using openFileForRead and cast<>ing the result to a CASBackedFile? Having both be virtual allows the posibility that a subclass returns different files from each one.

Copy link
Author

@cachemeifyoucan cachemeifyoucan Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because CASBackedFileSystem implements openFileForRead for all underlying classes and underlying classes just need to implement openCASBackedFileForRead which returns a different file type. This allows user of CASBackedFileSystem to use a different API to avoid casting between File types.

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-cas-relayering branch 2 times, most recently from 4f6647b to 82d3f2b Compare August 21, 2025 20:31
@cachemeifyoucan
Copy link
Author

@swift-ci please test llvm

Fix the proper laying of the llvm library by splitting CAS reference
away from FileSystem references.

This has some behavior changes:
* The common base class for FileSystem configured with a CAS-backing is
  now `llvm::cas::CASBackedFileSystem` and migrate CAS related
  FileSystem APIs to the new class.
* ThreadSafeFileSystem is folded into CASBackedFileSystem to avoid
  diamond class hierachies.
* llvm::vfs::File needs to be RTTIExtended, so that a user can tell if
  the file is CAS backed when there are overlaying file system.
* When configured with multi-layer CAS backed file system, the file
  content is available in every CAS along the way the file is resolved
  and the returned CASID is from the top layer. This is a more
  deterministic behavior than current one, that only the lowest level
  CAS has the reference, and user actually don't know which CAS it is
  associated with unless know in advance which layer vended the file.
@cachemeifyoucan
Copy link
Author

@swift-ci please test llvm

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