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

Modify executable checking to be more universal #76607

Merged
merged 1 commit into from
Oct 17, 2020

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Sep 11, 2020

This uses a dummy file to check if the filesystem being used supports the executable bit in general.

Supersedes #74753.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2020
@Mark-Simulacrum
Copy link
Member Author

cc @mati865

I don't have a Windows/WSL system to test this on.

@mati865
Copy link
Contributor

mati865 commented Sep 11, 2020

It felt like working on Core 2 Duo system again but ./x.py test src/tools/tidy/ passed in WSL2 with Rust located on NTFS partition (/mnt/D/Projekty/Rust in my case).

@Mark-Simulacrum
Copy link
Member Author

Interesting! It looks like the /checkout/src directory is actually read-only in our CI environment, so this check would then be a bit problematic.

@pietroalbini, do you know if we mount that directory as read-only for any particular reason? Could we make that not true?

I guess the alternative is to try and disable the touching just in CI...

@pietroalbini
Copy link
Member

I don't know exactly why (I wasn't the one doing that, and the comments don't explain it), but I guess it's to force every tool and proc macro not to override the source code, but use Cargo's OUT_DIR instead. Or at least, that's what I'd do.

@Mark-Simulacrum
Copy link
Member Author

Hm. In this case we're intentionally trying to detect src because other directories might, in theory be on different partitions... I guess we can fall back to trying the same pattern in the build directory. It'll almost always be on the same filesystem.

@jyn514 jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc O-windows Operating system: Windows labels Sep 15, 2020
This uses a dummy file to check if the filesystem being used supports the
executable bit in general.
@Mark-Simulacrum
Copy link
Member Author

Okay, I think this should be good on our CI now -- mingw-check no longer skips the bins check, at least.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2020
if contents.contains("Microsoft") || contents.contains("boot2docker") {
return;
fn is_executable(path: &Path) -> std::io::Result<bool> {
Ok(path.metadata()?.mode() & 0o111 != 0)
Copy link
Member

@pnkfelix pnkfelix Oct 17, 2020

Choose a reason for hiding this comment

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

So my only misgiving here is that when I first read this, I spent a while wondering about why its looking at the group and others bits at all, and about what scenarios could arise here. (example questions: Does owner alone not suffice? Is there any scenario where we could get an exec-bit set for group and/or others, and not owner, and yet we would still expect things to continue to work? Because the logic as written here seems to imply that interpretation of matters...)

I don't really know the best way to fix this, or if it really is something to fix at all. I figure the code as written is probably just playing it safe (no one ever got fired for taking the OR of all three triads, right?). But I would be curious if there is actually a scenario that its anticipating, and if so, maybe a comment here is warranted.

Copy link
Member

@pnkfelix pnkfelix Oct 17, 2020

Choose a reason for hiding this comment

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

Actually, I guess given the first context where this is called, namely a check if the filesystem is magically treating fresh created files as executable, the OR of all the triads does make sense to me.

Update: And for the second context, where we are trying to detect a binary that has been checked into git... well, I guess that was the logic that was already there, so we might assume that's doing the right thing.

(I might rename the method to is_any_triad_executable, though, to make that clear.)

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 17, 2020

📌 Commit 05c9c0e has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 17, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#75802 (resolve: Do not put nonexistent crate `meta` into prelude)
 - rust-lang#76607 (Modify executable checking to be more universal)
 - rust-lang#77851 (BTreeMap: refactor Entry out of map.rs into its own file)
 - rust-lang#78043 (Fix grammar in note for orphan-rule error [E0210])
 - rust-lang#78048 (Suggest correct place to add `self` parameter when inside closure)
 - rust-lang#78050 (Small CSS cleanup)
 - rust-lang#78059 (Set `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker)

Failed merges:

r? `@ghost`
@bors bors merged commit 83ee319 into rust-lang:master Oct 17, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants