-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(platform-probes): measure the long-path opt-in with a manifested pair #80
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (c) Mike Grier. | ||
|
|
||
| //! Embeds `longPathAware` into **one** binary, so the long-path opt-in can be | ||
| //! measured rather than read about. | ||
| //! | ||
| //! The opt-in has two halves and neither is a runtime switch: a machine-wide | ||
| //! registry value, and a per-executable manifest. The manifest half is what | ||
| //! this adds, and it is added to `probe-long-path-aware` **alone** -- | ||
| //! `probe-long-path-unaware` is the same code without it, because a comparison | ||
| //! needs both sides and the un-opted-in case is what most consumers of this | ||
| //! workspace actually have. | ||
| //! | ||
| //! `rustc-link-arg-bin` rather than `rustc-link-arg-bins`: the latter would | ||
| //! opt every probe in this crate into long paths, silently changing what all | ||
| //! the others measure -- stated without a count on purpose, so it stays true as | ||
| //! probes are added. | ||
|
|
||
| fn main() { | ||
| // Declared unconditionally, because the cfg's *absence* is as meaningful as | ||
| // its presence and an undeclared name would warn under `unexpected_cfgs`. | ||
| println!("cargo::rustc-check-cfg=cfg(long_path_manifest_embedded)"); | ||
|
|
||
| // Only the MSVC linker understands these, and this crate is Windows-only | ||
| // anyway; guarding keeps a cross-compile from failing on a flag its linker | ||
| // has never heard of. | ||
| if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { | ||
| let manifest = | ||
| std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("long-path-aware.manifest"); | ||
| println!("cargo::rerun-if-changed=long-path-aware.manifest"); | ||
| println!("cargo::rustc-link-arg-bin=probe-long-path-aware=/MANIFEST:EMBED"); | ||
| println!( | ||
| "cargo::rustc-link-arg-bin=probe-long-path-aware=/MANIFESTINPUT:{}", | ||
| manifest.display() | ||
| ); | ||
|
|
||
| // The aware binary reads this rather than claiming the opt-in outright, | ||
| // so its report cannot say `manifest longPathAware : yes` for an | ||
| // executable this script did not manifest. | ||
| // | ||
| // That mattered: with the claim hardcoded, a non-MSVC target skipped the | ||
| // block above and produced two binaries with *no* manifest between them, | ||
| // one of which still announced it had one. Both halves then measured the | ||
| // un-opted-in case and a reader comparing them would conclude the opt-in | ||
| // does not work -- a wrong answer, silently, in the one place this probe | ||
| // cannot fail loudly instead, because the whole finding is the difference | ||
| // between the two. Emitting the flag from the same branch that does the | ||
| // embedding is what keeps the label and the linker in step. | ||
| println!("cargo::rustc-cfg=long_path_manifest_embedded"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
| <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
| <assemblyIdentity type="win32" name="probe-long-path-aware" version="1.0.0.0"/> | ||
| <application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
| <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> | ||
| <ws2:longPathAware>true</ws2:longPathAware> | ||
| </windowsSettings> | ||
| </application> | ||
| </assembly> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (c) Mike Grier. | ||
|
|
||
| //! Measures the long-path opt-in **with** `longPathAware` in the manifest. | ||
| //! | ||
| //! **An experiment, not a component.** These probes measure platform behaviour | ||
| //! and are not for production use. See this crate's DESIGN-NOTES.md. | ||
| //! | ||
| //! Its twin, `probe-long-path-unaware`, is the same code without the manifest. | ||
| //! Run both: one row of results proves nothing, because the difference between | ||
| //! them is the whole measurement. | ||
|
|
||
| use windows_platform_probes::long_path_report; | ||
| use windows_platform_probes::report::emit_report; | ||
|
|
||
| fn main() { | ||
| // The probe's whole output policy, and it is one line: hand the renderer to | ||
| // the sink. Nothing here or below names a stream -- that is chosen once, in | ||
| // `report`, so retargeting a probe is not a rewrite. | ||
| // | ||
| // The manifest is this binary's whole difference from its twin, and it is a | ||
| // claim about the build rather than something measured at runtime: the two | ||
| // halves of the opt-in are a machine-wide registry value and a per-executable | ||
| // manifest, neither of which is a switch a process can read off itself. | ||
| // | ||
| // So the claim is *derived* from the flag `build.rs` sets in the same branch | ||
| // that embeds the manifest, never hardcoded. Hardcoding `true` here would let | ||
| // a target whose linker the script skips -- anything non-MSVC -- report | ||
| // `manifest longPathAware : yes` for an executable carrying no manifest, | ||
| // while both halves quietly measured the same un-opted-in case. | ||
| let manifest_aware = cfg!(long_path_manifest_embedded); | ||
| emit_report(|out| long_path_report::render(out, manifest_aware)); | ||
| } |
25 changes: 25 additions & 0 deletions
25
crates/windows-platform-probes/src/bin/long_path_unaware.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright (c) Mike Grier. | ||
|
|
||
| //! Measures the long-path opt-in **without** `longPathAware` in the manifest. | ||
| //! | ||
| //! **An experiment, not a component.** These probes measure platform behaviour | ||
| //! and are not for production use. See this crate's DESIGN-NOTES.md. | ||
| //! | ||
| //! This is the case most consumers of this workspace actually have, which is | ||
| //! why it is measured rather than assumed: a library cannot add a manifest to | ||
| //! someone else's executable, so whatever this reports is what a caller who has | ||
| //! not opted in will meet. | ||
|
|
||
| use windows_platform_probes::long_path_report; | ||
| use windows_platform_probes::report::emit_report; | ||
|
|
||
| fn main() { | ||
| // The probe's whole output policy, and it is one line: hand the renderer to | ||
| // the sink. Nothing here or below names a stream -- that is chosen once, in | ||
| // `report`, so retargeting a probe is not a rewrite. | ||
| // | ||
| // `false` is this binary's whole difference from its twin: `build.rs` | ||
| // embeds the manifest into `probe-long-path-aware` alone, so this one is | ||
| // the same code compiled without the opt-in. | ||
| emit_report(|out| long_path_report::render(out, false)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.