weixin_39939918
weixin_39939918
2020-12-01 14:51

Windows: error: expected unqualified-id

ANGLE is attempting to pull in the latest version of the Vulkan validation layers, but is hitting an error with the Windows build:


FAILED: obj/third_party/vulkan-validation-layers/src/VkLayer_khronos_validation/subresource_adapter.obj 
C:\b\s\w\ir\cache\goma\client\gomacc.exe ..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /nologo /showIncludes -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\um -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\shared -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\winrt -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\ucrt -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\VC\Tools\MSVC\14.23.28105\include -imsvc..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\VC\Tools\MSVC\14.23.28105\atlmfc\include -DUSE_AURA=1 "-DCR_CLANG_REVISION=\"n332890-c2443155-1\"" -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -D_USING_V110_SDK71_ -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNTDDI_VERSION=NTDDI_WIN10_RS2 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -D_HAS_ITERATOR_DEBUGGING=0 -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DVK_USE_PLATFORM_WIN32_KHR -DVULKAN_NON_CMAKE_BUILD "-DAPI_NAME=\"Vulkan\"" -I../.. -Igen -I../../third_party/vulkan-validation-layers/src/layers -I../../third_party/vulkan-validation-layers/src/layers/generated -I../../third_party/vulkan-headers/src/include -I../../third_party/glslang/src -I../../third_party/spirv-tools/src/include -I../../third_party/spirv-headers/src/include -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase /Zc:sizedDealloc- /X -fmsc-version=1916 /guard:cf,nochecks -m64 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes /Od /Ob0 /GF /Z7 -gcodeview-ghash -fno-standalone-debug /MTd -Xclang -add-plugin -Xclang find-bad-constructs -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare /W3 /wd4800 /wd4267 /wd4996 -Wno-unused-variable /WX /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-bitwise-conditional-parentheses -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-sizeof-array-div -Wno-unused-function -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare /TP /GR- /wd4577 /c ../../third_party/vulkan-validation-layers/src/layers/subresource_adapter.cpp /Foobj/third_party/vulkan-validation-layers/src/VkLayer_khronos_validation/subresource_adapter.obj /Fd"obj/third_party/vulkan-validation-layers/src/VkLayer_khronos_validation_cc.pdb"
In file included from ../../third_party/vulkan-validation-layers/src/layers/subresource_adapter.cpp:22:
../../third_party/vulkan-validation-layers/src/layers/subresource_adapter.h(406,58): error: expected unqualified-id
                            constant_value_bound_ = std::min(cached_it_->lower_bound->first.end, range_gen_->end);
                                                         ^
..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
#define min(a,b)            (((a) < (b)) ? (a) : (b))
                            ^
In file included from ../../third_party/vulkan-validation-layers/src/layers/subresource_adapter.cpp:22:
../../third_party/vulkan-validation-layers/src/layers/subresource_adapter.h(411,51): error: expected unqualified-id
                            current_index_ = std::min(cached_it_->lower_bound->first.begin, range_gen_->end);
                                                  ^
..\..\..\..\win_toolchain\vs_files\8f58c55897a3282ed617055775a77ec3db771b88\win_sdk\Include\10.0.18362.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
#define min(a,b)            (((a) < (b)) ? (a) : (b))
                            ^
2 errors generated.

One suggestion we came across was to use #define NOMINMAX: https://stackoverflow.com/a/22744273/912144

This is being tracked within ANGLE with: http://anglebug.com/4338

该提问来源于开源项目:KhronosGroup/Vulkan-ValidationLayers

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39662432 weixin_39662432 4月前

    Hey , we also use NOMINMAX in the layers for these issues. Sorry for my lack of understanding, but can you be more specific about what you'd like for us to check out?

    点赞 评论 复制链接分享
  • weixin_39960793 weixin_39960793 4月前

    Tim, we should define NOMINMAX in angle's build on windows. Looks like there isn't anything for VVL to do.

    点赞 评论 复制链接分享
  • weixin_39939918 weixin_39939918 4月前

    Looking at this some more, it looks like the fix is to add the following to src/layers/subresource_adapter.h:

    
    // Allow use of STL min and max functions in Windows
    #define NOMINMAX
    

    Defining NOMINMAX in ANGLE's or the validation layers' build doesn't work, and is in fact explicitly being undone already:

    In src/layers/BUILD.gn, there is:

    
    vulkan_undefine_configs = []
    if (is_win) {
      vulkan_undefine_configs += [
        "//build/config/win:nominmax",
        "//build/config/win:unicode",
      ]
    }
    

    This is later used to remove the NOMINMAX definition from windows builds later in the build process:

    
    source_set("vulkan_layer_utils") {
    ...
      configs -= vulkan_undefine_configs
    }
    

    and

    
    foreach(layer_info, layers) {
    ...
      configs -= vulkan_undefine_configs
    

    Commenting those lines out shows that other source files within src/layers/ are already explicitly defining NOMINMAX themselves to work around this. For example, src/layers/core_validation.cpp:

    
    // Allow use of STL min and max functions in Windows
    #define NOMINMAX
    

    There are several files doing this already:

    
    $ grep -R NOMINMAX
    buffer_validation.cpp:#define NOMINMAX
    core_validation.cpp:#define NOMINMAX
    descriptor_sets.cpp:#define NOMINMAX
    drawdispatch.cpp:#define NOMINMAX
    generated/chassis.h:#define NOMINMAX
    gpu_validation.cpp:#define NOMINMAX
    hash_util.h:#define NOMINMAX
    parameter_validation_utils.cpp:#define NOMINMAX
    shader_validation.cpp:#define NOMINMAX
    sparse_containers.h:#define NOMINMAX
    state_tracker.cpp:#define NOMINMAX
    vk_mem_alloc.h:#ifndef NOMINMAX
    vk_mem_alloc.h:    #define NOMINMAX // For windows.h
    

    Based on the above, adding this to src/layers/subresource_adapter.h appears to be the correct solution.

    点赞 评论 复制链接分享
  • weixin_39960793 weixin_39960793 4月前

    Maybe VVL should just -DNOMINMAX in its builds and rip all of these out. I don't imagine there is any file that actually wants min&max from the windows SDK.

    点赞 评论 复制链接分享
  • weixin_39662432 weixin_39662432 4月前

    , , I'll get this in the repo directly. Thanks for chasing it down.

    点赞 评论 复制链接分享