google / google/shaderc

work around bug in CMake 3.22.1 bug in CMP0128 policy, for compiling SPIRV-Tools tests

Open
#1,350 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.2k
Forks
445
Avg merge
11h 6m
Merged PRs (30d)
6

Description

This bug in the OLD implementation in CMake 3.22.1 is causing SPIR-V Tools test code to compile with tailing -std=c++11 when it really needs -std=c++17 to take effect.

A fix is
cmake_policy(SET CMP0128 NEW)

The bug is fixed in CMake 3.22.2

When the bug is present, I get a build.ninja lines like this:

build third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir/binary_destroy_test.cpp.o: CXX_COMPILER__test_spirv_unit_tests_Release /build/ndk/external/shaderc/spirv-tools/test/binary_destroy_test.cpp || cmake_object_order_depends_target_test_spirv_unit_tests
DEFINES = -DSPIRV_COLOR_TERMINAL -DSPIRV_LINUX -DSPIRV_TIMER_ENABLED
DEP_FILE = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir/binary_destroy_test.cpp.o.d
FLAGS = --target=x86_64-linux-gnu --sysroot=/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot -L/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -B/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64 -B/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64 -L/project/ndk/prebuilts/clang/host/linux-x86/clang-r498229/lib64 -B/project/ndk/prebuilts/clang/host/linux-x86/clang-r498229/lib64 -Os -fomit-frame-pointer -s -fuse-ld=lld -Wno-unused-command-line-argument -fno-rtti -fno-exceptions -stdlib=libc++ -Wimplicit-fallthrough -O3 -DNDEBUG -fPIE -Wextra-semi -w -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-self-assign -Werror -Wno-long-long -Wshadow -Wundef -Wconversion -Wno-sign-conversion -fno-exceptions -ftemplate-depth=1024 -Wno-undef -Wno-shadow **-std=c++11 -pthread**
INCLUDES = -I/build/ndk/external/shaderc/spirv-tools -I/project/ndk/external/shaderc/spirv-headers/include -I/build/ndk/external/shaderc/spirv-tools/include -I/build/ndk/external/shaderc/spirv-tools/test -I/build/ndk/out/linux/shader-tools/build/third_party/spirv-tools -I/build/ndk/external/effcee -I/build/ndk/external/effcee/effcee/.. -I/build/ndk/external/regex-re2 -isystem /build/ndk/external/googletest/googletest/include -isystem /build/ndk/external/googletest/googlemock/include -isystem /build/ndk/external/googletest/googlemock -isystem /build/ndk/external/googletest/googletest
OBJECT_DIR = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir
OBJECT_FILE_DIR = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir

When I set the policy to NEW, and in 3.22.2 and later, I get a configuration line like this for one particular object compilation. I have bolded the operative parts, which is at the end of the FLAGS line.

build third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir/binary_destroy_test.cpp.o: CXX_COMPILER__test_spirv_unit_tests_Release /build/ndk/external/shaderc/spirv-tools/test/binary_destroy_test.cpp || cmake_object_order_depends_target_test_spirv_unit_tests
DEFINES = -DSPIRV_COLOR_TERMINAL -DSPIRV_LINUX -DSPIRV_TIMER_ENABLED
DEP_FILE = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir/binary_destroy_test.cpp.o.d
FLAGS = --target=x86_64-linux-gnu --sysroot=/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot -L/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -B/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64 -B/project/ndk/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64 -L/project/ndk/prebuilts/clang/host/linux-x86/clang-r498229/lib64 -B/project/ndk/prebuilts/clang/host/linux-x86/clang-r498229/lib64 -Os -fomit-frame-pointer -s -fuse-ld=lld -Wno-unused-command-line-argument -fno-rtti -fno-exceptions -stdlib=libc++ -Wimplicit-fallthrough -O3 -DNDEBUG -fPIE -Wextra-semi -w -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-self-assign -Werror -Wno-long-long -Wshadow -Wundef -Wconversion -Wno-sign-conversion -fno-exceptions -ftemplate-depth=1024 -Wno-undef -Wno-shadow **-std=c++11 -pthread -std=c++17**
INCLUDES = -I/build/ndk/external/shaderc/spirv-tools -I/project/ndk/external/shaderc/spirv-headers/include -I/build/ndk/external/shaderc/spirv-tools/include -I/build/ndk/external/shaderc/spirv-tools/test -I/build/ndk/out/linux/shader-tools/build/third_party/spirv-tools -I/build/ndk/external/effcee -I/build/ndk/external/effcee/effcee/.. -I/build/ndk/external/regex-re2 -isystem /build/ndk/external/googletest/googletest/include -isystem /build/ndk/external/googletest/googlemock/include -isystem /build/ndk/external/googletest/googlemock -isystem /build/ndk/external/googletest/googletest
OBJECT_DIR = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir
OBJECT_FILE_DIR = third_party/spirv-tools/test/CMakeFiles/test_spirv_unit_tests.dir

The correct compilation has the -std=c++17 option which is required for the target.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.