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

Link Shaderc Dynamically #311

Open
freesig opened this issue May 12, 2019 · 3 comments
Open

Link Shaderc Dynamically #311

freesig opened this issue May 12, 2019 · 3 comments

Comments

@freesig
Copy link
Collaborator

freesig commented May 12, 2019

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.

@freesig freesig changed the title Link Shaderc dynamically Link Shaderc Dynamically May 12, 2019
@freesig
Copy link
Collaborator Author

freesig commented May 12, 2019

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

@freesig
Copy link
Collaborator Author

freesig commented May 21, 2019

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.

@freesig
Copy link
Collaborator Author

freesig commented May 28, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant