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

C++ port_def.inc: don't set PROTOBUF_CONSTINIT on mingw-w64 #8299

Closed
wants to merge 2 commits into from
Closed

C++ port_def.inc: don't set PROTOBUF_CONSTINIT on mingw-w64 #8299

wants to merge 2 commits into from

Commits on Feb 16, 2021

  1. port_def.inc: Remove duplicate PROTOBUF_CONSTINIT

    Signed-off-by: Christopher Degawa <ccom@randomderp.com>
    1480c1 committed Feb 16, 2021
    Configuration menu
    Copy the full SHA
    e9b4c3f View commit details
    Browse the repository at this point in the history
  2. port_def.inc: Don't set PROTOBUF_CONSTINIT on mingw-w64

    Currently errors out any clang compilation on windows with mingw-w64
    as std::mutex is not set with constexpr
    
    full error:
    ```c++
    ../../src/google/protobuf/struct.pb.cc:42:76: error: variable does not have a constant initializer
    PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY StructDefaultTypeInternal _Struct_default_instance_;
                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~
    ../../src/google/protobuf/struct.pb.cc:42:1: note: required by 'require_constant_initialization' attribute here
    PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY StructDefaultTypeInternal _Struct_default_instance_;
    ^~~~~~~~~~~~~~~~~~
    ../../src\google/protobuf/port_def.inc:580:30: note: expanded from macro 'PROTOBUF_CONSTINIT'
    \#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../src\google/protobuf/stubs/mutex.h:132:17: note: non-constexpr constructor 'mutex' cannot be used in a constant expression
      std::mutex mu_{};
                    ^
    ../../src\google/protobuf/map_field.h:336:9: note: in call to 'WrappedMutex()'
            mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED),
            ^
    ../../src\google/protobuf/map_field.h:485:9: note: in call to 'MapFieldBase({})'
          : MapFieldBase(tag) {}
            ^
    ../../src\google/protobuf/map_field.h:546:9: note: in call to 'TypeDefinedMapFieldBase({})'
          : TypeDefinedMapFieldBase<Key, T>(tag), impl_() {}
            ^
    ../../src/google/protobuf/struct.pb.cc:33:5: note: in call to 'MapField({})'
      : fields_(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}){}
        ^
    ../../src/google/protobuf/struct.pb.cc:36:7: note: in call to 'Struct({})'
        : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
          ^
    ../../src/google/protobuf/struct.pb.cc:42:76: note: in call to 'StructDefaultTypeInternal()'
    PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY StructDefaultTypeInternal _Struct_default_instance_;
                                                                               ^
    D:\mabs\msys64\mingw64\include\c++\10.2.0\bits/std_mutex.h:91:5: note: declared here
        mutex() noexcept = default;
        ^
    1 error generated.
    ```
    
    Signed-off-by: Christopher Degawa <ccom@randomderp.com>
    1480c1 committed Feb 16, 2021
    Configuration menu
    Copy the full SHA
    7c58123 View commit details
    Browse the repository at this point in the history