Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error #2581

Closed
nmdnm opened this issue May 23, 2020 · 4 comments
Closed

Compilation error #2581

nmdnm opened this issue May 23, 2020 · 4 comments

Comments

@nmdnm
Copy link

nmdnm commented May 23, 2020

Arch Linux

$ git rev-parse HEAD
dc51dc197c1bde688f9502955718edc223168d8f

$ clang++ --version
clang version 10.0.0 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ env CC=clang CXX=clang++ ./build.sh debug
Warning: JAVA_HOME is not set, skipping Java projects
Building debug in out/cmake-debug...
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang
-- DFG LUT size set to 128x128
-- Found Python3: /usr/bin/python3.8 (found version "3.8.2") found components: Interpreter 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vikaig/filament/out/cmake-debug
[27/1284] Building CXX object libs/math/CMakeFiles/benchmark_math.dir/benchmarks/benchmark_fast.cpp.o
In file included from ../../libs/math/benchmarks/benchmark_fast.cpp:22:
../../libs/math/include/math/fast.h:132:33: warning: implicit conversion from 'const int' to 'float' changes value from 1064866805 to 1064866816 [-Wimplicit-int-float-conversion]
    u.x = (int)(b * (u.x - K) + K);
                              ~ ^
1 warning generated.
[28/1284] Building CXX object libs/math/CMakeFiles/test_math.dir/tests/test_fast.cpp.o
In file included from ../../libs/math/tests/test_fast.cpp:19:
../../libs/math/include/math/fast.h:132:33: warning: implicit conversion from 'const int' to 'float' changes value from 1064866805 to 1064866816 [-Wimplicit-int-float-conversion]
    u.x = (int)(b * (u.x - K) + K);
                              ~ ^
1 warning generated.
[308/1284] Building CXX object third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate.cpp.o
FAILED: third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate.cpp.o 
/usr/bin/clang++  -DFILAMENT_DRIVER_SUPPORTS_VULKAN -DSPIRV_CHECK_CONTEXT -DSPIRV_COLOR_TERMINAL -DSPIRV_LINUX -DSPIRV_TIMER_ENABLED -DSPIRV_TOOLS_IMPLEMENTATION -DSPIRV_TOOLS_SHAREDLIB -DSPIRV_Tools_shared_EXPORTS -I../../third_party/spirv-tools -I../../third_party/spirv-tools/include -Ithird_party/spirv-tools -I../../third_party/spirv-tools/external/spirv-headers/include -std=c++14 -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function -stdlib=libc++ -fcolor-diagnostics -DTNT_DEV -g -fstack-protector  -fPIC -fvisibility=hidden   -Wextra-semi -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-self-assign -Werror -std=c++11 -fno-exceptions -fno-rtti -Wno-long-long -Wshadow -Wundef -Wconversion -Wno-sign-conversion -ftemplate-depth=1024 -std=gnu++11 -MD -MT third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate.cpp.o -MF third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate.cpp.o.d -o third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate.cpp.o -c ../../third_party/spirv-tools/source/val/validate.cpp
../../third_party/spirv-tools/source/val/validate.cpp:145:21: error: loop variable 'other_id_name' of type 'const std::__1::basic_string<char>' creates a copy from type 'const std::__1::basic_string<char>' [-Werror,-Wrange-loop-construct]
    for (const auto other_id_name : other_id_names) {
                    ^
../../third_party/spirv-tools/source/val/validate.cpp:145:10: note: use reference type 'const std::__1::basic_string<char> &' to prevent copying
    for (const auto other_id_name : other_id_names) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
                    &
../../third_party/spirv-tools/source/val/validate.cpp:434:19: error: loop variable 'inst' of type 'const spvtools::val::Instruction' creates a copy from type 'const spvtools::val::Instruction' [-Werror,-Wrange-loop-construct]
  for (const auto inst : vstate->ordered_instructions()) {
                  ^
../../third_party/spirv-tools/source/val/validate.cpp:434:8: note: use reference type 'const spvtools::val::Instruction &' to prevent copying
  for (const auto inst : vstate->ordered_instructions()) {
       ^~~~~~~~~~~~~~~~~
                  &
2 errors generated.
[310/1284] Building CXX object third_party/spirv-tools/source/CMakeFiles/SPIRV-Tools-shared.dir/val/validate_annotation.cpp.o
ninja: build stopped: subcommand failed.
@nmdnm nmdnm changed the title Compiling error Compilation error May 23, 2020
@kpeeters
Copy link

This needs to be const auto& or auto.

@nmdnm
Copy link
Author

nmdnm commented May 23, 2020

Compilation is ok with this patch

diff --git a/third_party/spirv-tools/source/val/validate.cpp b/third_party/spirv-tools/source/val/validate.cpp
index 7f4b0dc..7c743c4 100644
--- a/third_party/spirv-tools/source/val/validate.cpp
+++ b/third_party/spirv-tools/source/val/validate.cpp
@@ -142,7 +142,7 @@ spv_result_t ValidateEntryPointNameUnique(ValidationState_t& _,
   for (const auto other_id : _.entry_points()) {
     if (other_id == id) continue;
     const auto other_id_names = CalculateNamesForEntryPoint(_, other_id);
-    for (const auto other_id_name : other_id_names) {
+    for (auto other_id_name : other_id_names) {
       if (names.find(other_id_name) != names.end()) {
         return _.diag(SPV_ERROR_INVALID_BINARY, _.FindDef(id))
                << "Entry point name \"" << other_id_name
@@ -431,7 +431,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState(
   if (auto error = ValidateBuiltIns(*vstate)) return error;
   // These checks must be performed after individual opcode checks because
   // those checks register the limitation checked here.
-  for (const auto inst : vstate->ordered_instructions()) {
+  for (auto inst : vstate->ordered_instructions()) {
     if (auto error = ValidateExecutionLimitations(*vstate, &inst)) return error;
     if (auto error = ValidateSmallTypeUses(*vstate, &inst)) return error;
   }
diff --git a/third_party/spirv-tools/source/val/validation_state.cpp b/third_party/spirv-tools/source/val/validation_state.cpp
index 51aebbe..281c34d 100644
--- a/third_party/spirv-tools/source/val/validation_state.cpp
+++ b/third_party/spirv-tools/source/val/validation_state.cpp
@@ -1052,7 +1052,7 @@ void ValidationState_t::ComputeFunctionToEntryPointMapping() {
 }
 
 void ValidationState_t::ComputeRecursiveEntryPoints() {
-  for (const Function func : functions()) {
+  for (auto func : functions()) {
     std::stack<uint32_t> call_stack;
     std::set<uint32_t> visited;

@romainguy
Copy link
Collaborator

Pending fix in #2562

@romainguy
Copy link
Collaborator

I merged the fix from #2562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants