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

Support OUT_DIR located in \\?\ path on Windows #51

Merged
merged 1 commit into from
May 14, 2024
Merged

Support OUT_DIR located in \\?\ path on Windows #51

merged 1 commit into from
May 14, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented May 14, 2024

This PR is similar to #50, but determining to use / vs \ based on the host OS, not the target OS.

From Maximum Path Length Limitation: File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections. If the OUT_DIR directory for the current build on a Windows host is prefixed with "\\?\", then include!(concat!(…, "/…")) does not work:

couldn't read \\?\D:\a\tokio\tokio\target\debug\build\rustversion-2d44b26e828f2c8d\out/version.expr: The filename, directory name, or volume label syntax is incorrect. (os error 123)

Rustc or cargo do not have any built-in way to handle including code from OUT_DIR robustly (rust-lang/rust#75075).

Specifically for a procedural macro crate, using target_os like in #50 sort of works, but only because Cargo does not support cross-compiling procedural macro crates (it just ignores --target if --package refers to a macro). But other build systems definitely support cross-compiling proc macros, and would be broken by #50 if target_os is Windows but the host is not.

Closes #50.

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.

None yet

1 participant