amezin / vscode-linux-kernel

Visual Studio Code project/compile_commands.json generator for Linux kernel sources and out-of-tree modules
The Unlicense
577 stars 153 forks source link

Produces errors when Rust is enabled #19

Open tamird opened 5 days ago

tamird commented 5 days ago

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.

amezin commented 5 days ago

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...

tamird commented 5 days ago

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.