google / amber

Amber is a multi-API shader test framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build failures on linux/clang-16

kuhar opened this issue · comments

A fresh checkout of Amber fails to build on linux w/ clang-16:

$ ninja                                                                                                                                                               
[154/413] Building CXX object third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/MachineIndependent/glslang_tab.cpp.o                                      
MachineIndependent/glslang_tab.cpp:4933:9: warning: variable 'yynerrs' set but not used [-Wunused-but-set-variable]
    int yynerrs = 0;
        ^
1 warning generated.
[304/413] Building CXX object src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o
FAILED: src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o 

and

FAILED: src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o 
/usr/bin/clang++-bolt -DAMBER_CTS_VULKAN_HEADER=0 -DAMBER_ENABLE_CLSPV=0 -DAMBER_ENABLE_DXC=0 -DAMBER_ENABLE_LODEPNG=1 -DAMBER_ENABLE_RTTI=0 -DAMBER_ENABLE_SHADERC=1 -DAMBER_ENABLE_SPIRV_TOOLS=1 -DAMBER_ENGINE_DAWN=0 -DAMBER_ENGINE_VULKAN=1 -I/usr/local/google/home/kubak/amber/amber/include -I/usr/local/google/home/kubak/amber/amber -I/usr/local/google/home/kubak/amber/amber/third_party/spirv-tools/include -I/usr/local/google/home/kubak/amber/amber/build -I/usr/local/google/home/kubak/vulkan/1.2.182.0/x86_64/include -g -fPIC -fno-exceptions -fvisibility=hidden -Wall -Werror -Wextra -Wno-padded -Wno-switch-enum -Wno-unknown-pragmas -pedantic-errors -fno-rtti -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-pedantic -Wno-unknown-warning-option -Weverything -Wno-zero-as-null-pointer-constant -std=gnu++11 -MD -MT src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o -MF src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o.d -o src/vulkan/CMakeFiles/libamberenginevulkan.dir/device.cc.o -c /usr/local/google/home/kubak/amber/amber/src/vulkan/device.cc
In file included from /usr/local/google/home/kubak/amber/amber/src/vulkan/device.cc:421:
/usr/local/google/home/kubak/amber/amber/build/vk-wrappers-1-0.inc:2:38: error: cast from 'PFN_vkVoidFunction' (aka 'void (*)()') to 'PFN_vkAllocateCommandBuffers' (aka 'VkResult (*)(VkDevice_T *, const VkCommandBufferAllocateInfo *, VkCommandBuffer_T **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  PFN_vkAllocateCommandBuffers ptr = reinterpret_cast<PFN_vkAllocateCommandBuffers>(getInstanceProcAddr(instance_, "vkAllocateCommandBuffers"));
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/kubak/amber/amber/build/vk-wrappers-1-0.inc:36:38: error: cast from 'PFN_vkVoidFunction' (aka 'void (*)()') to 'PFN_vkAllocateDescriptorSets' (aka 'VkResult (*)(VkDevice_T *, const VkDescriptorSetAllocateInfo *, VkDescriptorSet_T **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  PFN_vkAllocateDescriptorSets ptr = reinterpret_cast<PFN_vkAllocateDescriptorSets>(getInstanceProcAddr(instance_, "vkAllocateDescriptorSets"));
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/kubak/amber/amber/build/vk-wrappers-1-0.inc:70:30: error: cast from 'PFN_vkVoidFunction' (aka 'void (*)()') to 'PFN_vkAllocateMemory' (aka 'VkResult (*)(VkDevice_T *, const VkMemoryAllocateInfo *, const VkAllocationCallbacks *, VkDeviceMemory_T **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  PFN_vkAllocateMemory ptr = reinterpret_cast<PFN_vkAllocateMemory>(getInstanceProcAddr(instance_, "vkAllocateMemory"));
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ...

This seems to be caused by the default compilation options in amber:

function(amber_default_compile_options TARGET)        
  if (${COMPILER_IS_LIKE_GNU}) 
    target_compile_options(${TARGET} PRIVATE            
      -fno-exceptions   
      -fvisibility=hidden                   
      -Wall
      -Werror                    
      -Wextra                                                     
      -Wno-padded
      -Wno-switch-enum
      -Wno-unknown-pragmas                            
      -pedantic-errors      
    ) 

Defaulting to -Werror and -Wextra/-pedantic/etc seems like a very fragile strategy to me outside of CI, since compiler diagnostics change very across compilers. What do you think about dropping it from the default set of compile options?

My preference is to leave the flags enabled, but they should only be applying to the amber code itself. We should figure out why those default compile options got applied to the third_party code.