Skip to content
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

Document NixOS woes #136

Closed
logannc opened this issue Aug 12, 2020 · 2 comments · Fixed by #290
Closed

Document NixOS woes #136

logannc opened this issue Aug 12, 2020 · 2 comments · Fixed by #290
Labels
C-Dependencies A change to the crates that Bevy depends on

Comments

@logannc
Copy link
Contributor

logannc commented Aug 12, 2020

This issue is inherently going to be a little meandering because I am not entirely familiar with the issues I'm having. Which is largely my fault for using such a niche OS, but also some fault lies in the completely bonkers world that is the intersection of graphics drivers, dynamic linking, and dependency management in general at the distro level.

I am hoping to merely make the maintainers aware and, mostly, hoping for a nod to this in the documentation more than any substantive codebase changes.

There are two primary blockers to running bevy out of the box on NixOS:

  1. without a build.rs, bevy fails to link to Vulkan. I don't know how much of this is NixOS's fault for being weird (or how much of it is specific to my common Nvidia GPU).
  2. glslang_validator needs to be patched to find it's dependency on libstdc++.so.6. I know most of this is NixOS's fault for being weird, but it also seem like an odd implementation.

Steps to successfully run Bevy examples:

  1. Enter a nix-shell with nix-shell -p pkgconfig x11 xorg.libXcursor xorg.libXrandr xorg.libXi vulkan-tools lutris vulkan-headers vulkan-loader vulkan-validation-layers alsaLib. I have not yet tested to see which, if any, of the vulkan packages can be removed. There may be more dependencies that I don't have listed here because I have them installed globally. For the most part, what is needed is usually fairly easy to find. The build will complain, you nix search <missing item>, and add it to the list.
  2. Create a build.rs file.
fn main() {
    if cfg!(target_os = "linux") {
        // these pragmas are optional on my system but left as examples if you run into trouble.
        // println!("cargo:rustc-link-lib=X11");
        // println!("cargo:rustc-link-lib=Xcursor");
        // println!("cargo:rustc-link-lib=Xrandr");
        // println!("cargo:rustc-link-lib=Xi");
        println!("cargo:rustc-link-lib=vulkan");
    }
}
  1. Try to run an example! Any example! We just need a particular dependency to be built.
  2. find target -type f -name glslang_validator in order to find glslang_validator in target/debug/build/bevy-glsl-to-spirv-<hash>/out/glslang_validator. export OUT_DIR="$(dirname $(find target -type f -name glslang_validator))" (you don't have to export it but we need the path for later).
  3. if you run ldd $OUT_DIR/glslang_validator, at least on my system, libstdc++.so.6 is not found. install (globally or in your nix-shell) any of the results found by nix-locate -w libstdc++.so.6. I'm using nixos.gcc-unwrapped below. In theory you can use any of the ones in find -L /nix/store -type f -name libstdc++.so.6.
  4. patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath /nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib $OUT_DIR/glslang_validator
  5. You should now be able to run examples.
@cart
Copy link
Member

cart commented Aug 12, 2020

Thanks for investigating the fix here. I'm sure other NixOS folks will appreciate it.

I think @kvark is the right person to talk to here given that wgpu is what uses vulkan. Im guessing wgpu also suffers from this problem.

I'm hoping we can fully remove the glslangvalidator dependency in favor of Naga in the near future. Glslangvalidator is causing many problems for us.

@kvark
Copy link

kvark commented Aug 12, 2020

We discussed this semi-recently in gfx-rs/wgpu-rs#332
The conclusion was that it should be handled by the "-sys" crate at the lowest level, so Ash in our case - ash-rs/ash#312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Dependencies A change to the crates that Bevy depends on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants