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

include doesn't support UNC paths on Windows #169

Closed
kornelski opened this issue Jun 16, 2017 · 4 comments
Closed

include doesn't support UNC paths on Windows #169

kornelski opened this issue Jun 16, 2017 · 4 comments

Comments

@kornelski
Copy link
Contributor

kornelski commented Jun 16, 2017

let cc = gcc::Config::new();
cc.include(std::fs::canonicalize("."));

Doesn't add absolute path of "." as the include dir (tested on Win10, MSVC). This is because Rust's canonicalize() makes a UNC path such as \\?\C:\Foo.

Stripping the \\?\ prefix seems to solve the problem, but I don't know enough about UNC paths to know whether that's a good solution.

I use fs::canonicalize() as the easiest way to get absolute paths in build scripts of link/-sys dependencies to reliably pass the paths in env vars for other packages to consume, and it works well on Unix.

@alexcrichton
Copy link
Member

Is this a bug with gcc-rs? Or is this a bug with cl.exe not accepting these paths? Do you have an error message?

@kornelski
Copy link
Contributor Author

cl.exe doesn't support UNC paths (-IC:\foo works as expected, -I\\?\C:\foo doesn't find includes)

So strictly speaking that's a bug in cl.exe, but I'm betting on gcc-rs to hide deficiencies of MSVC for me :)

@kornelski
Copy link
Contributor Author

I've released a crate that normalizes paths in a compatible way: https://gitlab.com/kornelski/dunce

It would be nice if that was built into the include() function here.

@alexcrichton
Copy link
Member

I'm going to close this since it sounds like it was a bug in cl.exe, and I'd prefer to not add too much normalization to this crate.

aaronvg added a commit to BoundaryML/baml that referenced this issue Mar 25, 2024
- Use more robust canonicalize() on windows

rust-lang/cc-rs#169

Basically, fs::canonicalize adds a prefix to the path which makes it a
UNC path, and CMD doesnt work with these paths. This dunce::canonicalize
returns a non-UNC path.
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

No branches or pull requests

2 participants