vscode-linux-kernel icon indicating copy to clipboard operation
vscode-linux-kernel copied to clipboard

Produces errors when Rust is enabled

Open tamird opened this issue 1 year ago • 4 comments

compile_commands.json contains things like

 {
  "directory": "/Users/tamird/src/linux",
  "command": "OBJTREE=/Users/tamird/src/linux rustc --edition=2021 -Zbinary_dep_depinfo=y -Astable_features -Dunsafe_op_in_unsafe_fn -Dnon_ascii_idents -Wrust_2018_idioms -Wunreachable_pub -Wmissing_docs -Wrustdoc::missing_crate_level_docs -Wclippy::all -Wclippy::mut_mut -Wclippy::needless_bitwise_bool -Wclippy::needless_continue -Wclippy::no_mangle_with_rust_abi -Wclippy::dbg_macro -Cpanic=abort -Cembed-bitcode=n -Clto=n -Cforce-unwind-tables=n -Ccodegen-units=1 -Csymbol-mangling-version=v0 -Crelocation-model=static -Zfunction-sections=n -Wclippy::float_arithmetic --target=aarch64-unknown-none -Ctarget-feature=\"-neon\" -Cforce-unwind-tables=n -Zbranch-protection=bti,pac-ret -Copt-level=2 -Cdebug-assertions=y -Coverflow-checks=y -Cforce-frame-pointers=y -Cdebuginfo=1 @./include/generated/rustc_cfg --emit=dep-info=rust/.bindings.o.d --emit=obj=rust/bindings.o --emit=metadata=rust/libbindings.rmeta --crate-type rlib -L./rust --crate-name bindings rust/bindings/lib.rs --sysroot=/dev/null  ",
  "file": "rust/bindings/lib.rs",
  "output": "rust/bindings.o"
 },

which produces errors in VSCode when I have e.g. rust/bindings/bindings_helper.h open.

tamird avatar Oct 09 '24 13:10 tamird

Do you have any ideas how to filter out Rust entries correctly? Check for rustc in command?

Although these entries aren't really incorrect, they just aren't for C compiler...

amezin avatar Oct 09 '24 16:10 amezin

Do you have any ideas how to filter out Rust entries correctly? Check for rustc in command?

Good question! Maybe look for .c in the source file?

Although these entries aren't really incorrect, they just aren't for C compiler...

Right. make rust-analyzer produces rust-project.json which is the Rust analogue of compile_commands.json.

tamird avatar Oct 09 '24 17:10 tamird

I'm sorry, I'm not doing kernel development actively nowadays and have more important things to fix rn.

It would be great if you - or someone else - could make a PR that solves this issue.

By the way, I took a brief look at the upstream compile_commands.json generator - looks like it improved a bit. What's the reason you still use this repository? Is it still worth maintaining?

And, unless there are good reasons, filtering should be done the same way as the upstream script does it (if it does, though).

amezin avatar Oct 15 '24 20:10 amezin

I didn't know upstream had a generator! I will use that.

tamird avatar Oct 15 '24 20:10 tamird