rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
116 stars 17 forks source link

Rust-analyzer crashes with ctru-rs #175

Closed velllu closed 3 months ago

velllu commented 3 months ago

The lsp server crashes when i try to open a ctru-rs project, I'm using the nightly toolchain, here's the logs:

2024-04-03T16:17:49.385522Z ERROR rust_analyzer::main_loop: FetchBuildDataError:
The following warnings were emitted during compilation:

error: failed to run custom build command for `ctru-sys v0.5.0 (https://github.com/rust3ds/ctru-rs#d3082059)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/vellu/Projects/3dsreader/target/debug/build/ctru-sys-41f883e682c3e3ea/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-env-changed=DEVKITPRO
  cargo:rustc-link-search=native=/nix/store/bb94hxamr1zxqhxvaqz0kzf9qikc8d51-devkitarm-1.0.0/opt/devkitpro/libctru/lib
  cargo:rustc-link-lib=static=ctrud
  cargo:warning=unable to find `pacman` or `dkp-pacman`: cannot find binary path; cannot find binary path
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler version doesn't include clang or GCC: "/nix/store/bb94hxamr1zxqhxvaqz0kzf9qikc8d51-devkitarm-1.0.0/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc" "--version"
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=arm-none-eabi-gcc: error: unrecognized command-line option '-m64'

  --- stderr

  error occurred: Command "/nix/store/bb94hxamr1zxqhxvaqz0kzf9qikc8d51-devkitarm-1.0.0/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/nix/store/bb94hxamr1zxqhxvaqz0kzf9qikc8d51-devkitarm-1.0.0/opt/devkitpro/libctru/include" "-Wall" "-Wextra" "-march=armv6k" "-mtune=mpcore" "-mfloat-abi=hard" "-mfpu=vfp" "-mtp=soft" "-Wno-deprecated-declarations" "-o" "/home/vellu/Projects/3dsreader/target/debug/build/ctru-sys-c27fcaffccf77a76/out/e147c4bd913656e0-libctru_statics_wrapper.o" "-c" "/home/vellu/Projects/3dsreader/target/debug/build/ctru-sys-c27fcaffccf77a76/out/libctru_statics_wrapper.c" with args "arm-none-eabi-gcc" did not execute successfully (status code exit status: 1).

2024-04-03T16:17:51.631841Z ERROR flycheck: Flycheck failed to run the following command: CommandHandle { program: "/nix/store/3b02h25w17w94j6vhpy8w6ys66n987s7-rust-complete-1.79.0-nightly-2024-04-03/bin/cargo", arguments: ["check", "--workspace", "--message-format=json-diagnostic-rendered-ansi", "--manifest-path", "/home/vellu/Projects/3dsreader/Cargo.toml", "--all-targets"], current_dir: Some("/home/vellu/Projects/3dsreader") }
Meziu commented 3 months ago

The cause is that the build script can’t find dkp-pacman (or normal pacman). If you have installed devkitPro’s toolchain correctly, you might have encountered the same issue as #154, though only a warning should’ve been emitted.

It seems you also run NixOS, do you have the same setup as that other user?

velllu commented 3 months ago

The cause is that the build script can’t find dkp-pacman (or normal pacman). If you have installed devkitPro’s toolchain correctly, you might have encountered the same issue as #154, though only a warning should’ve been emitted.

It seems you also run NixOS, do you have the same setup as that other user?

Why can it build my project just fine but it breaks the lsp? shouldn't build.rs run in both cases? But yeah, i don't have pacman installed

Meziu commented 3 months ago

Try running the lsp with the configuration at https://github.com/rust3ds/ctru-rs/wiki/Guides#setting-up-rust-analyzer (you don’t need the env vars if they are already properly set). It might be an issue with the target/clippy.

Edit: ehm, it seems I had read your error message incorrectly. The error looks to be that it doesn’t recognise the -m64 option. Are you sure that the arm-none-eabi-gcc in scope is the devkitARM one? It might give some issues if you are already working with other ARM toolchains.

velllu commented 3 months ago

Try running the lsp with the configuration at https://github.com/rust3ds/ctru-rs/wiki/Guides#setting-up-rust-analyzer (you don’t need the env vars if they are already properly set). It might be an issue with the target/clippy.

Edit: ehm, it seems I had read your error message incorrectly. The error looks to be that it doesn’t recognise the -m64 option. Are you sure that the arm-none-eabi-gcc in scope is the devkitARM one? It might give some issues if you are already working with other ARM toolchains.

I am sure that i'm using the devkitARM one, and i dont have any other arm toolchains installed

velllu commented 3 months ago

nevermind, i followed the link you sent, removed the alteady set extra vars, and it worked