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

Support dynamically linked glslang #58

Closed
faulesocke opened this issue Jul 5, 2019 · 15 comments
Closed

Support dynamically linked glslang #58

faulesocke opened this issue Jul 5, 2019 · 15 comments

Comments

@faulesocke
Copy link

The build script currently assumes that libSPIRV from glslang is always available in a static version (libSPIRV.a). However, this is not true on my system, I only have libSPIRV.so and my libshaderc_combined.a relies on symbols from that .so.

Would it be possible to add a check for libSPIRV.so to the build-script so that the crate compiles correctly on my system?

@antiagainst
Copy link
Collaborator

Hey @faulesocke, I don't have the exact configuration as yours; so please feel free to send a pull request for it.

@faulesocke
Copy link
Author

@antiagainst Okay, I'm working on it. My system (void linux) looks like this:

% ll /usr/lib/libSPIRV*
-rw-r--r-- 1 root root 336K Apr  2 05:52 /usr/lib/libSPIRV-Tools-comp.a
-rw-r--r-- 1 root root 151K Apr  2 05:52 /usr/lib/libSPIRV-Tools-link.a
-rw-r--r-- 1 root root 6.8M Apr  2 05:52 /usr/lib/libSPIRV-Tools-opt.a
-rw-r--r-- 1 root root 360K Apr  2 05:52 /usr/lib/libSPIRV-Tools-reduce.a
-rwxr-xr-x 1 root root 975K Apr  2 05:52 /usr/lib/libSPIRV-Tools-shared.so
-rw-r--r-- 1 root root 2.0M Apr  2 05:52 /usr/lib/libSPIRV-Tools.a
-rwxr-xr-x 1 root root 522K Jul  9 19:02 /usr/lib/libSPIRV.so
% ll /usr/lib/libshaderc*
-rw-r--r-- 1 root root  64K Jun  8 10:18 /usr/lib/libshaderc.a
-rw-r--r-- 1 root root 221K Jun  8 10:18 /usr/lib/libshaderc_combined.a
lrwxrwxrwx 1 root root   22 Jun  8 10:18 /usr/lib/libshaderc_shared.so -> libshaderc_shared.so.1
-rwxr-xr-x 1 root root 3.4M Jun  8 10:18 /usr/lib/libshaderc_shared.so.1
% ll /usr/lib/libglslang*
-rwxr-xr-x 1 root root  26K Jul  9 19:02 /usr/lib/libglslang-default-resource-limits.so
-rwxr-xr-x 1 root root 1.7M Jul  9 19:02 /usr/lib/libglslang.so

It's especially confusing that libSPIRV is only available as a .so while libSPIRV-Tools is available as a .a.

What way would you consider "proper" to detect the state of the system? I would prefer detection for every single library and if it exists, link it. However, I don't want to mess with the detection code too much so that I don't break everyone elses setups.

I will file a pull request shortly showing you the code with minimal changes that works on my system but I wouldn't consider that a proper solution.

@antiagainst
Copy link
Collaborator

That is strange. libSPIRV-Tools-opt should also have a shared library. It seems something is not correctly configured in upstream.

@faulesocke
Copy link
Author

Can't find one, neither on Void nor on Arch.

@Abendstolz
Copy link

Abendstolz commented Jul 21, 2019

May I jump in here?

I am running Archlinux and to me it looks like I have a similar but not the same problem. I get

Compiling shaderc-sys v0.5.1 error: could not find native static library SPIRV-Tools-opt, perhaps an -L flag is missing? error: aborting due to previous error warning: Checking for system installed libraries. Use --features > = build-from-source to disable this behavior warning: Found SPIRV. Linking libSPIRV & libglslang

error: Could not compile shaderc-sys.

I checked my /usr/lib for libSPIRV and found these:

.rwxr-xr-x 100k root 19 Jul 18:38 libSPIRV-Tools-link.so
.rwxr-xr-x 2.6M root 19 Jul 18:38 libSPIRV-Tools-opt.so
.rwxr-xr-x 181k root 19 Jul 18:38 libSPIRV-Tools-reduce.so
.rwxr-xr-x 1.1M root 19 Jul 18:38 libSPIRV-Tools-shared.so
.rwxr-xr-x 1.2M root 19 Jul 18:38 libSPIRV-Tools.so
.rw-r--r-- 1.0M root 19 Jul 19:46 libSPIRV.a
.rwxr-xr-x 538k root 19 Jul 19:46 libSPIRV.so
lrwxrwxrwx 11 root 19 Jul 19:46 libSPIRV.so.0 -> libSPIRV.so

looks like expected https://www.archlinux.org/packages/extra/x86_64/spirv-tools/files/

To me it's strange that a small cargo update broke everything while the only "suspicious" thing I could see in the Cargo.lock is a version increase from v0.5.0 to v0.5.1 - happening via https://github.com/vulkano-rs/vulkano

If you know of any workaround, I'd appreciate. Should I (we) wait until upstream is "fixed" and libSPIRV-Tools.a is included or what exactly is there to do?

@faulesocke
Copy link
Author

faulesocke commented Jul 22, 2019

I know two workarounds: At least on Void Linux I fixed my issues by building a static version of glslang. And my PR (see above) also fixed the issue for me.

@Abendstolz
Copy link

Thanks @faulesocke

Just for the record, here is my not-as-elegant fix:

[dependencies]
... 
# Fixing broken detection of glslang on my arch machine, see: https://github.com/google/shaderc-rs/pull/59
shaderc = "0.5.1"
shaderc-sys = "0.5.1"

[features]
shaderc_fix = ["shaderc/build-from-source"]

#[replace]
#"shaderc:0.5.1" = { git = "https://github.com/faulesocke/shaderc-rs", branch = "voidlinux"}
#"shaderc-sys:0.5.1" = { git = "https://github.com/faulesocke/shaderc-rs", branch = "voidlinux"}

as I couldn't get [replace] to work (*) I have to build with --features=shaderc_fix

(*) Meaning I still got the same error as in my previous comment

@faulesocke
Copy link
Author

Try this ;)

[patch.crates-io]
shaderc-sys = { path = "../shaderc-rs/shaderc-sys" }

@mitchmindtree
Copy link

Just wanted to mention that I'm also running into the same issue as @Abendstolz on Arch Linux. I haven't been able to get the aforementioned patch working just yet but I haven't had a lot of time to tinker. I'll revisit this tomorrow and report back.

@antiagainst
Copy link
Collaborator

antiagainst commented Jul 30, 2019

I've submitted 69adfd6, which should address this. Please try out and let me know (sorry I don't have a Linux box with the same configuration for this issue). If it's working I'll cut a release. Otherwise please reopen this issue. :)

@mitchmindtree
Copy link

Thanks @antiagainst!

Unfortunately, I'm still personally getting a build error when running cargo build, though cargo build --features "build-from-source" seems to work OK.

[mindtree@mindtree shaderc-sys]$ cargo clean                                                                                                  
[mindtree@mindtree shaderc-sys]$ cargo build --features "build-from-source"                                                                   
   Compiling cc v1.0.38                                                
   Compiling libc v0.2.60                                              
   Compiling cmake v0.1.40                                             
   Compiling shaderc-sys v0.6.0 (/home/mindtree/programming/rust/shaderc-rs/shaderc-sys)                                                      
warning: Requested to build from source                                                                                                       
    Finished dev [unoptimized + debuginfo] target(s) in 5m 38s         
[mindtree@mindtree shaderc-sys]$ cargo build                           
   Compiling shaderc-sys v0.6.0 (/home/mindtree/programming/rust/shaderc-rs/shaderc-sys)                                                      
warning: Checking for system installed libraries.  Use --features = build-from-source to disable this behavior                                
warning: Found and linking shared system installed SPIRV libraries.    
error: could not find native static library `SPIRV-Tools-opt`, perhaps an -L flag is missing?                                                 
                                                                       
error: aborting due to previous error                                  

Strange as libSPIRV-Tools-opt.so seems to be in my /usr/lib:

[mindtree@mindtree shaderc-sys]$ ls -ahl /usr/lib/libSPIRV*            
-rw-r--r-- 1 root root 1010K Jul 19 19:46 /usr/lib/libSPIRV.a          
-rwxr-xr-x 1 root root  526K Jul 19 19:46 /usr/lib/libSPIRV.so                                                                                
lrwxrwxrwx 1 root root    11 Jul 19 19:46 /usr/lib/libSPIRV.so.0 -> libSPIRV.so                                                               
-rwxr-xr-x 1 root root   98K Jul 19 18:38 /usr/lib/libSPIRV-Tools-link.so                                                                     
-rwxr-xr-x 1 root root  2.6M Jul 19 18:38 /usr/lib/libSPIRV-Tools-opt.so                                                                      
-rwxr-xr-x 1 root root  178K Jul 19 18:38 /usr/lib/libSPIRV-Tools-reduce.so                                                                   
-rwxr-xr-x 1 root root  1.1M Jul 19 18:38 /usr/lib/libSPIRV-Tools-shared.so                                                                   
-rwxr-xr-x 1 root root  1.2M Jul 19 18:38 /usr/lib/libSPIRV-Tools.so                                                                          

I might dig into this a little later to see if I can work out what's going on!

@antiagainst
Copy link
Collaborator

Ah, so you have a shared lib version of SPIRV-Tools-opt. The script right now only tries to find static version.

@antiagainst
Copy link
Collaborator

@mitchmindtree: Okay, submitted ff876b1. Let me know whether it works for you right now.

@mitchmindtree
Copy link

@antiagainst thanks so much, it works beautifully! ✨

Going from 5min source build to a 2sec compile time is a really great win :)

@antiagainst
Copy link
Collaborator

@mitchmindtree: Glad to hear that! I'll cut a release then. :)

mitchmindtree added a commit to mitchmindtree/vulkano that referenced this issue Aug 17, 2019
This is kind of a delayed emergency release to address an issue where
some Linux distributions (Arch, Void and perhaps others) are unable to
build any projects depending on vulkano-shaders due to
google/shaderc-rs#58. This is resolved in shaderc 0.6 and in turn will
be resolved in vulkano 0.14 thanks to vulkano-rs#1226.

See the CHANGELOG-VULKANO.md for more details on the release.
mitchmindtree added a commit to mitchmindtree/vulkano that referenced this issue Aug 17, 2019
This is kind of a delayed emergency release to address an issue where
some Linux distributions (Arch, Void and perhaps others) are unable to
build any projects depending on vulkano-shaders due to
google/shaderc-rs#58. This is resolved in shaderc 0.6 and in turn will
be resolved in vulkano 0.14 thanks to vulkano-rs#1226.

See the CHANGELOG-VULKANO.md for more details on the release.
mitchmindtree added a commit to vulkano-rs/vulkano that referenced this issue Aug 17, 2019
This is kind of a delayed emergency release to address an issue where
some Linux distributions (Arch, Void and perhaps others) are unable to
build any projects depending on vulkano-shaders due to
google/shaderc-rs#58. This is resolved in shaderc 0.6 and in turn will
be resolved in vulkano 0.14 thanks to #1226.

See the CHANGELOG-VULKANO.md for more details on the release.
mitchmindtree added a commit to mitchmindtree/conrod that referenced this issue Aug 18, 2019
This is kind of a late, emergency release to fix an issue where users of
some Linux distros (Arch, Void, possibly others) cannot currently build
conrod_vulkano due to a bug in the shaderc 0.5.1 build script.
google/shaderc-rs#58.
mitchmindtree added a commit to mitchmindtree/shade_runner that referenced this issue Aug 18, 2019
This patch addresses an issue with shaderc-rs 0.5.1 failing to build on
various Linux distros including Arch, Void and likely others.
google/shaderc-rs#58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants