Skip to content

Conversation

@kant2002
Copy link

@kant2002 kant2002 commented Dec 8, 2025

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
  • patch executable should be on PATH. I think you may find it in C:\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

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
@kant2002
Copy link
Author

kant2002 commented Dec 8, 2025

I think the second error is due to cmake missing support for VS 2026 rust-lang/cmake-rs#255

Copy link
Contributor

@kkysen kkysen left a 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.

Comment on lines +89 to +93
if cfg!(target_os = "windows") {
lib_dir.push("llvm-config.exe");
} else {
lib_dir.push("llvm-config");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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"
});

Comment on lines +87 to +88
lib_dir.push("..");
lib_dir.push("bin");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"LLVM_LIB_DIR is set but `{}' does not exist",
"LLVM_LIB_DIR is set but `{}` does not exist",

Comment on lines +94 to +101
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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"
Copy link
Contributor

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.

Comment on lines -8 to +10
let mut p = Command::new("gen/process_ast.py")
let mut p = Command::new("uv")
.arg("run")
.arg("gen/process_ast.py")
Copy link
Contributor

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.

Comment on lines +20 to +24
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();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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}`"));

Comment on lines +25 to +32
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();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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"))]
Copy link
Contributor

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.

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.

2 participants