mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
593 stars 43 forks source link

Compilation fails in debug mode #124

Closed maxfrei750 closed 1 year ago

maxfrei750 commented 1 year ago

Hello again!

I'm trying to debug an error and therefore wanted to compile mitsuba and drjit in debug mode. However, compilation fails with the following error:

cmake -GNinja .. && ninja:
#0 0.285 -- The CXX compiler identification is Clang 11.1.0
#0 0.324 -- The C compiler identification is Clang 11.1.0
#0 0.329 -- Detecting CXX compiler ABI info
#0 0.385 -- Detecting CXX compiler ABI info - done
#0 0.387 -- Check for working CXX compiler: /usr/bin/clang++-11 - skipped
#0 0.388 -- Detecting CXX compile features
#0 0.388 -- Detecting CXX compile features - done
#0 0.390 -- Detecting C compiler ABI info
#0 0.429 -- Detecting C compiler ABI info - done
#0 0.432 -- Check for working C compiler: /usr/bin/clang-11 - skipped
#0 0.432 -- Detecting C compile features
#0 0.432 -- Detecting C compile features - done
#0 0.433 -- Mitsuba v3.2.0 
#0 0.433 -- Mitsuba: targeting the native CPU architecture (specify MI_NATIVE_FLAGS to change this).
#0 0.676 -- Mitsuba: using libc++.
#0 0.806 -- Found Python: /usr/bin/python3.10 (found version "3.10.6") found components: Interpreter Development Development.Module Development.Embed 
#0 0.829 -- pybind11 v2.10.1 
#0 0.998 -- Mitsuba: building the following variants:
#0 0.998 --  * scalar_rgb
#0 0.998 --  * cuda_ad_rgb
#0 0.998 --  * llvm_ad_rgb
#0 0.999 --  * cuda_ad_mono
#0 0.999 --  * llvm_ad_mono
#0 1.000 -- Dr.Jit v0.4.0 
#0 1.000 -- Dr.Jit: building the CUDA & LLVM JIT backend.
#0 1.001 -- Dr.Jit-Core: LLVM will be loaded dynamically at runtime.
#0 1.001 -- Dr.Jit-Core: CUDA will be loaded dynamically at runtime.
#0 1.001 -- Dr.Jit-Core: OptiX support enabled.
#0 1.001 -- Dr.Jit: building the autodiff backend.
#0 1.002 -- Dr.Jit: building the Python plugin.
#0 1.005 -- Found Git: /usr/bin/git (found version "2.34.1") 
#0 1.007 -- CLANG detected
#0 1.172 -- Looking for pthread.h
#0 1.212 -- Looking for pthread.h - found
#0 1.212 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
#0 1.256 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
#0 1.256 -- Found Threads: TRUE  
#0 1.267 -- Configure ILMBASE Version: 2.5.5 Lib API: 25.0.4
#0 1.436 -- Configure OpenEXR Version: 2.5.5 Lib API: 25.0.4
#0 1.442 -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
#0 1.575 -- The ASM compiler identification is Clang with GNU-like command-line
#0 1.575 -- Found assembler: /usr/bin/clang-11
#0 2.859 -- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
#0 2.859 -- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
#0 2.860 -- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
#0 2.860 -- Tests are disabled. Set FASTFLOAT_TEST to ON to run tests.
#0 2.861 -- Mitsuba: using OptiX for GPU ray tracing.
#0 2.861 -- Mitsuba: using Embree for CPU ray tracing.
#0 2.878 -- Could NOT find Sphinx (missing: SPHINX_EXECUTABLE) 
#0 2.880 -- Configuring done
#0 3.004 -- Generating done
#0 3.020 -- Build files have been written to: /src/mitsuba3/build
#0 3.364 [1/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_memmgr.cpp.o
#0 3.741 [2/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/optix_api.cpp.o
#0 3.776 [3/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/log.cpp.o
#0 3.854 [4/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/cuda_api.cpp.o
#0 3.900 [5/1183] Building C object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/resources/kernels.c.o
#0 4.007 [6/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_core.cpp.o
#0 4.070 [7/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/strbuf.cpp.o
#0 4.081 [8/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/util.cpp.o
#0 4.120 [9/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/cuda_tex.cpp.o
#0 4.137 [10/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/malloc.cpp.o
#0 4.146 [11/1183] Building C object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/ext/lz4/lz4.c.o
#0 4.167 [12/1183] Building C object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/ext/lz4/xxhash.c.o
#0 4.178 [13/1183] Building CXX object ext/CMakeFiles/pugixml.dir/pugixml/src/pugixml.cpp.o
#0 4.191 [14/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/op.cpp.o
#0 4.191 FAILED: ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/op.cpp.o 
#0 4.191 /usr/bin/clang++-11 -DDRJIT_BUILD=1 -DDRJIT_DYNAMIC_CUDA=1 -DDRJIT_DYNAMIC_LLVM=1 -DDRJIT_ENABLE_OPTIX=1 -DLZ4LIB_VISIBILITY="" -Ddrjit_core_EXPORTS -I/src/mitsuba3/ext/drjit/ext/drjit-core/ext/nanothread/include -I/src/mitsuba3/ext/drjit/ext/drjit-core/ext/robin_map/include -I/src/mitsuba3/ext/drjit/ext/drjit-core/ext/lz4 -I/src/mitsuba3/ext/drjit/ext/drjit-core/include -stdlib=libc++ -D_LIBCPP_VERSION -fcolor-diagnostics -g -fPIC -fvisibility=hidden   -fno-math-errno -ffp-contract=fast -fno-trapping-math -march=native -Wall -Wextra -Wno-unused-local-typedefs -std=gnu++17 -MD -MT ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/op.cpp.o -MF ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/op.cpp.o.d -o ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/op.cpp.o -c /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:98:23: error: constexpr if condition evaluates to 4, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsIntOrBool) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<4, unsigned int, 0>' requested here
#0 4.191     return jitc_var_check_impl<Flags>(
#0 4.191            ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:327:23: note: in instantiation of function template specialization 'jitc_var_check<4, unsigned int>' requested here
#0 4.191     auto [info, v0] = jitc_var_check<IsIntOrBool>("jit_var_not", a0);
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:112:23: error: constexpr if condition evaluates to 16, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsFloat) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<16, unsigned int, 0>' requested here
#0 4.191     return jitc_var_check_impl<Flags>(
#0 4.191            ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:350:23: note: in instantiation of function template specialization 'jitc_var_check<16, unsigned int>' requested here
#0 4.191     auto [info, v0] = jitc_var_check<IsFloat>("jit_var_sqrt", a0);
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:98:23: error: constexpr if condition evaluates to 4, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsIntOrBool) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<4, unsigned int, unsigned int, 0, 1>' requested here
#0 4.191     return jitc_var_check_impl<Flags>(
#0 4.191            ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:512:27: note: in instantiation of function template specialization 'jitc_var_check<4, unsigned int, unsigned int>' requested here
#0 4.191     auto [info, v0, v1] = jitc_var_check<IsIntOrBool>("jit_var_mod", a0, a1);
#0 4.191                           ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:91:23: error: constexpr if condition evaluates to 2, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsInt) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<2, unsigned int, unsigned int, 0, 1>' requested here
#0 4.191     return jitc_var_check_impl<Flags>(
#0 4.191            ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:551:27: note: in instantiation of function template specialization 'jitc_var_check<2, unsigned int, unsigned int>' requested here
#0 4.191     auto [info, v0, v1] = jitc_var_check<IsInt>("jit_var_mulhi", a0, a1);
#0 4.191                           ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:105:23: error: constexpr if condition evaluates to 8, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsNotVoid) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<8, unsigned int, unsigned int, 0, 1>' requested here
#0 4.191     return jitc_var_check_impl<Flags>(
#0 4.191            ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:761:27: note: in instantiation of function template specialization 'jitc_var_check<8, unsigned int, unsigned int>' requested here
#0 4.191     auto [info, v0, v1] = jitc_var_check<IsNotVoid>("jit_var_eq", a0, a1);
#0 4.191                           ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:91:23: error: constexpr if condition evaluates to 2, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.191         if constexpr (Flags & IsInt) {
#0 4.191                       ^
#0 4.191 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<2, unsigned int, 0>' requested here
#0 4.192     return jitc_var_check_impl<Flags>(
#0 4.192            ^
#0 4.192 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:942:23: note: in instantiation of function template specialization 'jitc_var_check<2, unsigned int>' requested here
#0 4.192     auto [info, v0] = jitc_var_check<IsInt>("jit_var_popc", a0);
#0 4.192                       ^
#0 4.192 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:112:23: error: constexpr if condition evaluates to 16, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.192         if constexpr (Flags & IsFloat) {
#0 4.192                       ^
#0 4.192 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<48, unsigned int, 0>' requested here
#0 4.193     return jitc_var_check_impl<Flags>(
#0 4.193            ^
#0 4.193 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:1249:23: note: in instantiation of function template specialization 'jitc_var_check<48, unsigned int>' requested here
#0 4.193     auto [info, v0] = jitc_var_check<IsFloat | IsCUDA>("jit_var_sin", a0);
#0 4.193                       ^
#0 4.193 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:119:23: error: constexpr if condition evaluates to 32, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.193         if constexpr (Flags & IsCUDA) {
#0 4.193                       ^
#0 4.193 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:105:23: error: constexpr if condition evaluates to 8, which cannot be narrowed to type 'bool' [-Wc++11-narrowing]
#0 4.193         if constexpr (Flags & IsNotVoid) {
#0 4.193                       ^
#0 4.193 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:193:12: note: in instantiation of function template specialization 'jitc_var_check_impl<8, unsigned int, 0>' requested here
#0 4.193     return jitc_var_check_impl<Flags>(
#0 4.194            ^
#0 4.194 /src/mitsuba3/ext/drjit/ext/drjit-core/src/op.cpp:1338:23: note: in instantiation of function template specialization 'jitc_var_check<8, unsigned int>' requested here
#0 4.194     auto [info, v0] = jitc_var_check<IsNotVoid>("jit_var_cast", a0);
#0 4.194                       ^
#0 4.194 9 errors generated.
#0 4.194 [15/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/api.cpp.o
#0 4.226 [16/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_mcjit.cpp.o
#0 4.264 [17/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/loop.cpp.o
#0 4.270 [18/1183] Linking CXX shared library libpugixml.so
#0 4.274 [19/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_orcv2.cpp.o
#0 4.341 [20/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/registry.cpp.o
#0 4.362 [21/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/var.cpp.o
#0 4.372 [22/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_api.cpp.o
#0 4.377 [23/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/optix_core.cpp.o
#0 4.383 [24/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/cuda_core.cpp.o
#0 4.398 [25/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/vcall.cpp.o
#0 4.404 [26/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/llvm_eval.cpp.o
#0 4.421 [27/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/eval.cpp.o
#0 4.501 [28/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/cuda_eval.cpp.o
#0 4.504 [29/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/io.cpp.o
#0 4.506 [30/1183] Building CXX object ext/drjit/ext/drjit-core/ext/nanothread/CMakeFiles/nanothread.dir/src/nanothread.cpp.o
#0 4.508 [31/1183] Building CXX object ext/drjit/ext/drjit-core/ext/nanothread/CMakeFiles/nanothread.dir/src/queue.cpp.o
#0 4.540 [32/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff.dir/common.cpp.o
#0 4.627 [33/1183] Building CXX object ext/drjit/ext/drjit-core/CMakeFiles/drjit-core.dir/src/init.cpp.o
#0 5.146 [34/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-scalar-f32.dir/autodiff.cpp.o
#0 5.310 [35/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-cuda-f32.dir/autodiff.cpp.o
#0 5.404 [36/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-llvm-f32.dir/autodiff.cpp.o
#0 5.418 [37/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-cuda-f64.dir/autodiff.cpp.o
#0 5.434 [38/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-scalar-f64.dir/autodiff.cpp.o
#0 5.817 [39/1183] Building CXX object ext/drjit/src/autodiff/CMakeFiles/drjit-autodiff-llvm-f64.dir/autodiff.cpp.o
#0 5.817 ninja: build stopped: subcommand failed.

Compiling in release mode works just fine. I suspect it might be related to the clang version (11.1)?

As always, any help is greatly appreciated.

PS: Code version is master (mitsuba 43a6b65ba435de3ce29a33cf27a38823a5db8afe).

njroussel commented 1 year ago

Hi @maxfrei750

Looks like compilers disagree on the C++ standard: https://stackoverflow.com/a/54899693 I can also confirm that this is no longer an issue with clang 14.

I guess we should have explicit narrowing on those lines, i.e. if constexpr (bool(Flags & SomeFlag)) or if constexpr ((Flags & SomeFlag) != 0). I'll push a patch later today.

njroussel commented 1 year ago

This is now fixed on master (https://github.com/mitsuba-renderer/drjit/commit/02f716223bdfd92e85e24dd4ddcb8927e0ff8f8d).

maxfrei750 commented 1 year ago

Thanks for the quick fix and the tip regarding clang 14. I noticed that the mitsuba repository still references an older version of drjit as a submodule. Is this only updated periodically, or would you mind pushing the changes to the mitsuba repository as well? Thanks!

njroussel commented 1 year ago

We try not to go overboard with the number of submodule updates, it keeps the history cleaner which is really helpful when bisecting. There's nothing stopping you from pulling the new submodule yourself. Or am I missing something?

maxfrei750 commented 1 year ago

I was suspecting something along those lines. Thanks for elaborating! I was just hoping for a push to the mitsuba repo, since then it would just require minute changes in my dockerfile to get the latest version. But that's no problem, you already helped me more than enough today. :smile: Thanks once again!