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

bevy fails to compile/run on musl based linux distros #898

Closed
lxea opened this issue Nov 20, 2020 · 2 comments
Closed

bevy fails to compile/run on musl based linux distros #898

lxea opened this issue Nov 20, 2020 · 2 comments
Labels
A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system

Comments

@lxea
Copy link

lxea commented Nov 20, 2020

Bevy version
0.3/master also fails the same way

Operating system & version
Alpine linux edge

What you did
Attempt to compile and run a bevy example on alpine linux.

What you expected to happen

the sample would run

What actually happened

The engine fails to compile when compiling cart/glsl-to-spirv

Additional information

The engine fails to compile as x86_64-unknown-linux-gnu is being used but alpine expects x86_64-unknown-linux-musl
If I edit the glsl-to-spirv build.rs files to use -muslthe compilation succeeds however, it then fails to launch and exits with a segfault to the usage of the precompiled static libraries expecting glibc (as far as i can understand anyway).

Also worth mentioning, if I dont use the fast compile .cargo/config i get a huge error that ends with the log below.

  = note: /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /home/alex/glsl-to-spirv/build/linux-musl/libglslang.glsltospirv.a(Constant.cpp.o): undefined reference to symbol 'acos'
          /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /lib/libc.musl-x86_64.so.1: error adding symbols: DSO missing from command line
          collect2: error: ld returned 1 exit status

Since reporting this I've also tried building with shaderc adding conditionals for musl/linux which when running an example segfaults

@Moxinilian Moxinilian added C-Bug An unexpected or incorrect behavior A-Build-System Related to build systems or continuous integration O-Linux Specific to the Linux desktop operating system labels Nov 20, 2020
@lxea
Copy link
Author

lxea commented Dec 9, 2020

Having spent a bit of time debugging this, I changed some conditionals to make this use shaderc and it doesnt fail to compile the render crate now, it still segfaults though, however I think the issue is in the rodio alsa crate

@inodentry
Copy link
Contributor

inodentry commented Jan 29, 2021

Yes, FYI (to anyone attempting to compile Bevy apps for any target other than the most common explicitly supported ones (x86_64 windows/linux-gnu/macos, AArch64 ios/android/macos, wasm)):

Bevy uses a temporary ugly hack for shader compilation (bevy-glsl-to-spirv) that makes builds on the officially-supported platforms easier by using some precompiled C/C++ binaries (to avoid the need for extra build tools). However this means that on unsupported platforms, bevy will fail to compile.

To use bevy on other platforms, you need to switch out bevy-glsl-to-spirv for shaderc. This is currently done in the official bevy for iOS and Arm macOS. You can just simply patch your bevy to remove the conditional selection of shaderc for only those platforms, to use it unconditionally. This should unblock Bevy to compile for your target, at the cost of extra build-time dependencies (ninja, cmake, python).

You need to remove the conditional compilation checks in the Cargo.toml and in crates/bevy_render/src/shader/shader.rs (also remove the conflicting bevy-glsl-to-spirv code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants