Closed star69rem closed 6 months ago
librashader-reflect uses https://github.com/google/shaderc-rs which builds as dynamic by default. You could try enabling the standalone
cargo feature in librashader-reflect which should build shaderc from source.
If that doesn't work you'll have to do some digging. librashader is designed to be linked dynamically with librashader_ld.h
, since theres so many moving parts I can't really accommodate for every static linking scenario. I recommend corrosion in the README since that usually manages to get things working but thats only applicable if you use CMake as a build system.
It doesn't compile anymore after making reflect standalone.
Compiling librashader-runtime-vk v0.1.4 (C:\msys64\librashader\librashader-runtime-vk)
error[E0277]: the trait bound CachedCompilation<GlslangCompilation>: ShaderCompilation is not satisfied
--> librashader-runtime-gl\src\filter_chain\filter_impl.rs:107:39 |
107 | GLSL::compile_preset_passes::<CachedCompilation |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait ShaderCompilation is not implemented for CachedCompilation<GlslangCompilation> |
---|
= help: the trait `ShaderCompilation` is implemented for `CachedCompilation<T>`
note: required by a bound in compile_preset_passes
--> C:\msys64\librashader\librashader-reflect\src\reflect\presets.rs:51:12
|
38 | fn compile_preset_passes<C, E>(
| --------------------- required by a bound in this associated function
...
51 | C: ShaderCompilation,
| ^^^^^^^^^^^^^^^^^ required by this bound in CompilePresetTarget::compile_preset_passes
error[E0277]: the trait bound CachedCompilation<GlslangCompilation>: ShaderCompilation is not satisfied
--> librashader-runtime-d3d11\src\filter_chain.rs:83:39 |
83 | HLSL::compile_preset_passes::<CachedCompilation |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait ShaderCompilation is not implemented for CachedCompilation<GlslangCompilation> |
---|
= help: the trait ShaderCompilation
is implemented for CachedCompilation<T>
note: required by a bound in compile_preset_passes
--> C:\msys64\librashader\librashader-reflect\src\reflect\presets.rs:51:12
|
38 | fn compile_preset_passes<C, E>(
| --------------------- required by a bound in this associated function
...
51 | C: ShaderCompilation,
| ^^^^^^^^^^^^^^^^^ required by this bound in CompilePresetTarget::compile_preset_passes
error[E0277]: the trait bound CachedCompilation<GlslangCompilation>: ShaderCompilation is not satisfied
--> librashader-runtime-vk\src\filter_chain.rs:216:40 |
216 | SPIRV::compile_preset_passes::<CachedCompilation |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait ShaderCompilation is not implemented for CachedCompilation<GlslangCompilation> |
---|
= help: the trait `ShaderCompilation` is implemented for `CachedCompilation<T>`
note: required by a bound in compile_preset_passes
--> C:\msys64\librashader\librashader-reflect\src\reflect\presets.rs:51:12
|
38 | fn compile_preset_passes<C, E>(
| --------------------- required by a bound in this associated function
...
51 | C: ShaderCompilation,
| ^^^^^^^^^^^^^^^^^ required by this bound in CompilePresetTarget::compile_preset_passes
error[E0277]: the trait bound CachedCompilation<GlslangCompilation>: ShaderCompilation is not satisfied
--> librashader-runtime-d3d12\src\filter_chain.rs:154:39 |
154 | DXIL::compile_preset_passes::<CachedCompilation |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait ShaderCompilation is not implemented for CachedCompilation<GlslangCompilation> |
---|
= help: the trait `ShaderCompilation` is implemented for `CachedCompilation<T>`
note: required by a bound in compile_preset_passes
--> C:\msys64\librashader\librashader-reflect\src\reflect\presets.rs:51:12
|
38 | fn compile_preset_passes<C, E>(
| --------------------- required by a bound in this associated function
...
51 | C: ShaderCompilation,
| ^^^^^^^^^^^^^^^^^ required by this bound in CompilePresetTarget::compile_preset_passes
error[E0277]: the trait bound CachedCompilation<GlslangCompilation>: ShaderCompilation is not satisfied
--> librashader-runtime-d3d12\src\filter_chain.rs:171:39 |
171 | HLSL::compile_preset_passes::<CachedCompilation |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait ShaderCompilation is not implemented for CachedCompilation<GlslangCompilation> |
---|
= help: the trait `ShaderCompilation` is implemented for `CachedCompilation<T>`
note: required by a bound in compile_preset_passes
--> C:\msys64\librashader\librashader-reflect\src\reflect\presets.rs:51:12
|
38 | fn compile_preset_passes<C, E>(
| --------------------- required by a bound in this associated function
...
51 | C: ShaderCompilation,
| ^^^^^^^^^^^^^^^^^ required by this bound in CompilePresetTarget::compile_preset_passes
For more information about this error, try rustc --explain E0277
.
error: could not compile librashader-runtime-gl
(lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile librashader-runtime-d3d11
(lib) due to previous error
error: could not compile librashader-runtime-vk
(lib) due to previous error
error: could not compile librashader-runtime-d3d12
(lib) due to 2 previous errors
Are you using the nightly compiler?
Yes. It compiles fine if I don't try to build it static MT.
Is there a pressing reason why you need a static build and can’t use librashader_ld.h?
On Mon, Oct 9, 2023 at 12:44 PM star69rem @.***> wrote:
Yes. It compiles fine if I don't try to build it static MT.
— Reply to this email directly, view it on GitHub https://github.com/SnowflakePowered/librashader/issues/20#issuecomment-1753339409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUIN3FT7VUFVBACJ774NDX6QSWNAVCNFSM6AAAAAA5YKP742VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJTGMZTSNBQHE . You are receiving this because you commented.Message ID: @.***>
If there wasn't I wouldn't be going through this BDSM.
I'm going to need to know more about your use case as to why the supported headers aren't a valid option.
I don't want users to have to install the C++ Redistributables. Thanks!
While I honestly don’t think it’s worth the trouble of static linking just to avoid installing the C++ redistributables (especially since librashader_ld.h means that the librashader version is user-upgradable: it’s very unlikely the ABI will change at this point), I can look into this for you; just in the middle of a move right now so it’ll be some time until I can get set up again.
I would appreciate it but there's no rush. I just keep running into people who get tripped up by the redistributables and I would really prefer to not have to package a whole installer for it. Thanks again!
https://github.com/google/shaderc-rs/pull/143
looks like I'll need this, will need to wait until the next shaderc release to get this working.
Could you check if shaderc links properly as of 2bd6f8f80ff4293200f371216becc3bc69df2f07?
Publishing librashader 0.2.0-beta.2
for you to test. I removed DXIL support on Linux, hence the minor bump.
Get this error:
3>lld-link : error : /failifmismatch: mismatch detected for 'RuntimeLibrary': 3>>>> librashader.lib(wrapper.o) has value MT_StaticRelease 3>>>> librashader.lib(shaderc.obj) has value MD_DynamicRelease
Output from shaderc-sys build: cargo:warning=shaderc: searching native shaderc libraries in Vulkan SDK 'C:\VulkanSDK\1.3.236.0/lib' cargo:warning=shaderc: Windows MSVC static build is experimental cargo:rustc-link-search=native=\?\C:\VulkanSDK\1.3.236.0\Lib cargo:rustc-link-lib=static=shaderc_combined
I got it to compile by just moving the shaderc libs out of the vulkan SDK folder.
Still having one problem: it all works if it's using the optimized profile, but using the debug profile doesn't work because it seems like some stuff is still being compiled in release mode. So it seems like the debug setting isn't being passed to all dependencies?
2>>>> libcpmtd.lib(xstoull.obj) has value 2 2>>>> librashader_debug.lib(wrapper.o) has value 0
xstoull.obj for some reason is in release
I tried the recommendation to set the environment variables: SET CXXFLAGS=-MTd SET CFLAGS=-MTd
Now it fails on xstrxfrm.obj instead of xstoull.obj.
1>>>> libcpmtd.lib(xstrxfrm.obj) has value 2 1>>>> librashader_debug.lib(shaderc.cc.obj) has value 0
I'm honestly not sure where libcpmtd.lib is coming from. Maybe spirv-to-dxil-rs? Does it build without dxil
support?
I looked into it a bit, and apparently this is a known issue with rust's libc being hardcoded to compile with a release flag. I'm not even sure there's anything you can do. Seems like it's been an issue for years.
https://github.com/rust-lang/rust/issues/39016
I worked around it by just throwing in some preprocessor definitions to use the DLL for debug mode and the static linking for the release build. Not ideal, but it works. Stuff like this is why I think there's going to be so much friction actually getting your program into emulators. Emulator authors tend to be OCD nutjobs and stuff like this is going to drive them crazy. They all want to rule their own little world with statically linked everything.
Closing as resolved.
I'm not able to link librashader.lib with a Visual Studio project with MT_StaticRelease.
I get the following error when setting the crt-static environment variable (SET RUSTFLAGS=-Ctarget-feature=+crt-static):
librashader.lib(wrapper.o) has value MT_StaticRelease librashader.lib(shaderc.obj) has value MD_DynamicRelease
Is some librashader dependency dynamic or something?