Nannou: Link Shaderc Dynamically

Created on 12 May 2019  路  3Comments  路  Source: nannou-org/nannou

I'm opening this issue to investigate the possibility of linking shaderc dynamically.
It's by far the biggest time consumer in nannous build times.
But all it's doing is compiling a c library which we should be able to install as a system library and just link against.
Things to consider:

  • How do we build it the first time? Perhaps we make a small crate that compiles and installs it as a system library.
  • How to check if it's already installed. I think maybe the same crate could check if it's already installed and only compile if it isn't. Something similar to moltenvk_deps.
  • What if shaderc get's an update. We might need a way to check if this happens and recompile. I'm not sure how this is currently handled. I think it's pulling the source as a submodule from git.
  • How to tell vulkano not to just compile shaderc. (And any other crates that use it) We might need a PR to vulkano as well but maybe there is someway to tell shaderc-rs to check for system libraries first.

I'll try and get to this soon but I'm pretty busy with other stuff. This would be a good issue for anyone with cmake experience and I'm happy to help with the build.rs stuff. Probably not a good first issue.

I think the best place to start is to see if there is a way to achieve this with the current setup by passing a feature flag to shaderc-rs or something similar.

help wanted

Most helpful comment

This is possible now with the latest vulkano master and will be in the next vulkano release.
You need to set the SHADERC_LIB_DIR env var to a path where the shaderc lib is.
On mac it is:
SHADERC_LIB_DIR=~/vulkan_sdk/macOS/lib/
Maybe we should look at automating this so that if it's not set it can be set.

All 3 comments

I just noticed that libshadec_shared.dylib is distributed with the vulkan_sdk. So this means we automatically have it on mac.

This is possible now with the latest vulkano master and will be in the next vulkano release.
You need to set the SHADERC_LIB_DIR env var to a path where the shaderc lib is.
On mac it is:
SHADERC_LIB_DIR=~/vulkan_sdk/macOS/lib/
Maybe we should look at automating this so that if it's not set it can be set.

I've noticed that this is leading to 500mb+ .rlib files being created multiple times even if you are just using --release.
I'd like to investigate this before closing this issue. I don't know too much about what an rlib is or if that is actually needed. I would have thought we could just link dynamically to the shaderc library without needing to make any large files like this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoshuaBatty picture JoshuaBatty  路  4Comments

mitchmindtree picture mitchmindtree  路  4Comments

capogreco picture capogreco  路  4Comments

sulram picture sulram  路  6Comments

kvark picture kvark  路  3Comments