Skip to content

Protobuf incompatible with nvcc #252

Closed

Description

@kmorel

When you compile MGARD with CUDA and a recent version of protobuf, you get an error like this:

[ 99%] Building CUDA object CMakeFiles/mgard-library.dir/src/mgard-x/RuntimeX/DeviceAdapters/DeviceAdapterCuda.cu.o
/home/software/spack/[padded-to-256-chars]/linux-x86_64_v3/cuda-12.9.1-pdix7w7d3ugenere6g6rwm7yvkxtzeqb/bin/nvcc -forward-unknown-to-host-compiler -ccbin=/usr/bin/g++ -DMGARD_ENABLE_CUDA -DMGARD_ENABLE_OPENMP -DMGARD_ENABLE_SERIAL -DMGARD_TIMING -DMGARD_ZSTD -Dmgard_library_EXPORTS --options-file CMakeFiles/mgard-library.dir/includes_CUDA.rsp --expt-relaxed-constexpr -w --generate-line-info -O3 -DNDEBUG -std=c++17 "--generate-code=arch=compute_90,code=[compute_90,sm_90]" -Xcompiler=-fPIC -DPROTOBUF_USE_DLLS -Wnon-virtual-dtor -DNOMINMAX -MD -MT CMakeFiles/mgard-library.dir/src/mgard-x/RuntimeX/DeviceAdapters/DeviceAdapterCuda.cu.o -MF CMakeFiles/mgard-library.dir/src/mgard-x/RuntimeX/DeviceAdapters/DeviceAdapterCuda.cu.o.d -x cu -rdc=true -c /tmp/root/spack-stage/spack-stage-mgard-1.6.0-7kee2kkxudejqwlbzpntujj6okwu2426/spack-src/src/mgard-x/RuntimeX/DeviceAdapters/DeviceAdapterCuda.cu -o CMakeFiles/mgard-library.dir/src/mgard-x/RuntimeX/DeviceAdapters/DeviceAdapterCuda.cu.o
/home/software/spack/[padded-to-256-chars]/linux-x86_64_v3/protobuf-33.1-mc3sumwwz6wj7h3optmympl4n6fhrkwz/include/google/protobuf/message_lite.h(298): error: variable cannot have incomplete type "google::protobuf::internal::EnumTraitsImpl::Undefined"
    static Undefined value;
    ^

The problem is that recent versions of protobuf rely on inline variables and relaxed rules around static data members to make this particular code legal without a full definition. This is completely legal in C++17 (which the host compiler fully supports), but this is a part of the C++17 spec not supported by the nvcc wrapper.

This problem was observed when adding the 1.6.0 release to mgard.

The best advice is to avoid using protobuf in code compiled with nvcc. However, the protobuf use seems most likely coming from Metadata.hpp, and that seems like a core feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions