KhronosGroup / KhronosGroup/SPIRV-Cross
compiler is optimizing unreferenced parameter in CompilerGLSL::type_to_array_glsl and causing linking issues
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
in file spirv_glsl.cpp you have a definition of this function:
```
string CompilerGLSL::type_to_array_glsl(const SPIRType &type, uint32_t)
{
```
as you can see, the second parameter is unnamed and unused. This is causing problems if I try to use this function from outside the library:
```
59>------ Build started: Project: VulkanRenderDevice, Configuration: Debug x64 ------
57>spirv_cross_c.cpp
58>main.cpp
57>spirv-cross-c.vcxproj -> F:\Projects\long-bow-engine\build\Debug\spirv-cross-cd.lib
58>spirv-cross.vcxproj -> F:\Projects\long-bow-engine\build\Debug\spirv-cross.exe
59> Creating library F:/Projects/long-bow-engine/build/Debug/VulkanRenderDeviced.lib and object F:/Projects/long-bow-engine/build/Debug/VulkanRenderDeviced.exp
59>BowVulkanShaderProgram.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string,class std::allocator > __cdecl spirv_cross::CompilerGLSL::type_to_array_glsl(struct spirv_cross::SPIRType const &)" (?type_to_array_glsl@CompilerGLSL@spirv_cross@@MEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBUSPIRType@2@@Z)
59>F:\Projects\long-bow-engine\build\Debug\VulkanRenderDeviced.dll : fatal error LNK1120: 1 unresolved externals
59>Done building project "VulkanRenderDevice.vcxproj" -- FAILED.
```
As you can see my compiler is trying to link this function which does not exist:
`spirv_cross::CompilerGLSL::type_to_array_glsl(struct spirv_cross::SPIRType const &)`
I fixed it for me by declaring and defning a second function, which takes only one parameter:
spirv_glsl.hpp:
```
virtual std::string type_to_array_glsl(const SPIRType &type);
virtual std::string type_to_array_glsl(const SPIRType &type, uint32_t variable_id);
```
spirv_glsl.cpp:
```
string CompilerGLSL::type_to_array_glsl(const SPIRType &type)
{
return type_to_array_glsl(type, 0);
}
string CompilerGLSL::type_to_array_glsl(const SPIRType &type, uint32_t)
{
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing the declaration in spirv_glsl.hpp with the definitions in spirv_glsl.cpp for CompilerGLSL::type_to_array_glsl. Build the library and an external caller using the one-argument signature; done means the symbol resolves without adding an unresolved external-linker error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100