nannou-org / nannou

A Creative Coding Framework for Rust.
https://nannou.cc/
6.01k stars 303 forks source link

Link Shaderc Dynamically #311

Open freesig opened 5 years ago

freesig commented 5 years ago

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:

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 commented 5 years ago

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

freesig commented 5 years ago

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 commented 5 years ago

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.