-
Notifications
You must be signed in to change notification settings - Fork 283
Windows building support #1501
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
base: master
Are you sure you want to change the base?
Windows building support #1501
Conversation
This is draft PR to check if there is appetite for that Current problems which I would work on - I should examine what libc variants has simply different signatures, I fail to recognize that, and ignore too much probably. - libclangAstExporter currently failed to build with error ``` unsupported or unknown VisualStudio version: 18.0 if another version is installed consider running the appropriate vcvars script before building this crate ', .....cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.50\src\lib.rs:955:2 ``` That probably indication that cmake create should be updated, but that's whole can of worm. Would be glad to recive feedback on the general direction
|
I think the second error is due to cmake missing support for VS 2026 rust-lang/cmake-rs#255 |
kkysen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is draft PR to check if there is appetite for that
Thanks for working on this! We're not able to help add Windows support and test and maintain it, but similarly to Nix, if you'd like to work on adding Windows support, we'll welcome it and review and merge your PRs. This one generally looks good so far.
Another thing is that #1444 adds much better support for cross-OS transpilation. We're not planning to test it on Windows, but the infrastructure should be there to do so if that seems like a good alternative, too. We'll likely get back to that cross-transpilation work in the medium-term future.
| if cfg!(target_os = "windows") { | ||
| lib_dir.push("llvm-config.exe"); | ||
| } else { | ||
| lib_dir.push("llvm-config"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if cfg!(target_os = "windows") { | |
| lib_dir.push("llvm-config.exe"); | |
| } else { | |
| lib_dir.push("llvm-config"); | |
| } | |
| lib_dir.push(if cfg!(target_os = "windows") { | |
| "llvm-config.exe" | |
| } else { | |
| "llvm-config" | |
| }); |
| lib_dir.push(".."); | ||
| lib_dir.push("bin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| lib_dir.push(".."); | |
| lib_dir.push("bin"); | |
| lib_dir.push("../bin"); |
| let canonicalized_dir = lib_dir.canonicalize(); | ||
| if canonicalized_dir.is_err() { | ||
| panic!( | ||
| "LLVM_LIB_DIR is set but `{}' does not exist", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "LLVM_LIB_DIR is set but `{}' does not exist", | |
| "LLVM_LIB_DIR is set but `{}` does not exist", |
| let canonicalized_dir = lib_dir.canonicalize(); | ||
| if canonicalized_dir.is_err() { | ||
| panic!( | ||
| "LLVM_LIB_DIR is set but `{}' does not exist", | ||
| lib_dir.display() | ||
| ); | ||
| } | ||
| canonicalized_dir.unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let canonicalized_dir = lib_dir.canonicalize(); | |
| if canonicalized_dir.is_err() { | |
| panic!( | |
| "LLVM_LIB_DIR is set but `{}' does not exist", | |
| lib_dir.display() | |
| ); | |
| } | |
| canonicalized_dir.unwrap() | |
| let canonicalized_dir = lib_dir.canonicalize(); | |
| lib_dir.canonicalize().unwrap_or_else(|_| { | |
| panic!( | |
| "LLVM_LIB_DIR is set but `{}` does not exist", | |
| lib_dir.display() | |
| ); | |
| }) |
| cargo-util = "0.2.1" | ||
| shlex = "1.3" | ||
| kstring = "=2.0.0" # v2.0.0 has a MSRV of 1.59, while v2.0.1 has a MSRV of 1.73, but we're pinned to 1.65. | ||
| libloading = "=0.7.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the reason it's pinned? I assume an MSRV issue, but it's good to have them documented like the others.
| let mut p = Command::new("gen/process_ast.py") | ||
| let mut p = Command::new("uv") | ||
| .arg("run") | ||
| .arg("gen/process_ast.py") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to keep these in sync, could you just read the #!? You can just read the first line, strip the #!/usr/bin/env -S prefix (panic if different), and then run what's after that.
| let lib = libloading::Library::new(path_str.clone()); | ||
| if lib.is_err() { | ||
| panic!("failed to open plugin `{}`", path_str); | ||
| } | ||
| let sym = dlsym(so, sym_name.as_ptr()); | ||
| if sym.is_null() { | ||
| let lib = lib.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let lib = libloading::Library::new(path_str.clone()); | |
| if lib.is_err() { | |
| panic!("failed to open plugin `{}`", path_str); | |
| } | |
| let sym = dlsym(so, sym_name.as_ptr()); | |
| if sym.is_null() { | |
| let lib = lib.unwrap(); | |
| let lib = libloading::Library::new(path_str.clone()) | |
| .unwrap_or_else(|_| panic!("failed to open plugin `{path_str}`")); |
| let f: Result<libloading::Symbol<fn(&mut Registry)>, libloading::Error> = lib.get(b"register_commands"); | ||
| if f.is_err() { | ||
| panic!( | ||
| "failed to locate symbol `register_commands` in `{}`", | ||
| path_str | ||
| ); | ||
| } | ||
| let f: fn(&mut Registry) = mem::transmute(sym); | ||
| let f = f.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let f: Result<libloading::Symbol<fn(&mut Registry)>, libloading::Error> = lib.get(b"register_commands"); | |
| if f.is_err() { | |
| panic!( | |
| "failed to locate symbol `register_commands` in `{}`", | |
| path_str | |
| ); | |
| } | |
| let f: fn(&mut Registry) = mem::transmute(sym); | |
| let f = f.unwrap(); | |
| let f = lib.get::<fn(&mut Registry)>(b"register_commands") | |
| .unwrap_or_else(|_| panic!("failed to locate symbol `register_commands` in `{path_str}`")); |
| i: c_int, | ||
| ) -> c_int; | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "macos"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but is this the right cfg here? Or do we want something more like #[cfg(not(windows))]? Same for the others.
This is draft PR to check if there is appetite for that Current problems which I would work on
patchexecutable should be on PATH. I think you may find it inC:\Program Files\Git\usr\bin\on most dev machines.That probably indication that cmake create should be updated, but that's whole can of worm.
Would be glad to recive feedback on the general direction