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

[move] Fix vfs relativization #16987

Merged
merged 9 commits into from
Apr 3, 2024
Merged

[move] Fix vfs relativization #16987

merged 9 commits into from
Apr 3, 2024

Conversation

tnowacki
Copy link
Contributor

@tnowacki tnowacki commented Apr 1, 2024

Description

Test Plan

  • Built on windows

If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

Fixed issues with sui move not working in cmd.exe on Windows.

Copy link

vercel bot commented Apr 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm
multisig-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm
sui-kiosk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:34pm

@@ -347,7 +339,7 @@ impl Compiler {

source_text
.iter_mut()
.for_each(|(_, (path, _))| *path = relativize_path(&vfs_root, *path));
.for_each(|(_, (path, _))| *path = vfs_to_original_path[path]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This map access should not be unconditional as new paths can be generated between when the map is initialized and when it's used here, so not every path will have an entry in the map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I found out as much from tests. Attempting to fix but it might blow up on windows

Comment on lines +149 to +152
let paths: Vec<Symbol> = if vfs_root.is_none() {
let paths: Vec<_> = paths.into_iter().map(|p| p.into()).collect();
let paths: Vec<_> = paths.iter().map(|p| p.as_str()).collect();
find_filenames_and_keep_specified(&paths, &mut find_move_files)?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, I want to get the compiler out of the business of finding files. It is a relic from before the package system. But its functionality is relied on a bit too much to rip out from this PR, though I totally can if y'all want me to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a very large fan of ripping it out as soon as possible.

Comment on lines +788 to +789
// TODO this should really be done by the package system, with the interface files stuffed into the
// build/ directory for the package. This would give a more consistent location for errors.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Speaking of pre-package system relics... it would be really great to make this a package system feature someday

Comment on lines +76 to +80
pub fn set_compiler_vfs_root(mut self, vfs_root: VfsPath) -> Self {
assert!(self.compiler_vfs_root.is_none());
self.compiler_vfs_root = Some(vfs_root);
self
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find this very unsatisfying, but am unsure what to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

This could be std::mem::replace where you hand back the old one and make the caller deal with it

Copy link
Contributor

@awelc awelc left a comment

Choose a reason for hiding this comment

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

Other than a nit, LGTM

.collect::<Result<Vec<_>, anyhow::Error>>()?;

for path in targets.iter().chain(&deps) {
if !path.path.is_file().unwrap_or(false) {
debug_assert!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the assertion since we are bailing anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want the assertion so we get a panic instead of an Err in debug builds

let vfs = p.to_vfs_path(&vfs_root)?;
vfs_to_original_path.insert(Symbol::from(vfs.path.as_str()), original);
Ok(vfs)
})
.collect::<Result<Vec<_>, anyhow::Error>>()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Something to mention is there were some build issues in migration where two packages pointed to the same dependency via different relative paths, and those got reported as conflicting even though they were the same. I don't think we should fix that in this PR, but I suspect it may impact some of this code.

Comment on lines +131 to +134
let mut files = file_paths
.into_iter()
.map(path_to_string)
.collect::<anyhow::Result<Vec<String>>>()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be filtered by is_file_desired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the intention of this function versus find_files is to keep any file specified.

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

Approved, modulo the nit above and a few small questions.

@tnowacki tnowacki merged commit 66d6e2c into MystenLabs:main Apr 3, 2024
45 checks passed
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.

Failed to build Move modules
3 participants