| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| |
| --- a/src/google/protobuf/port_def.inc |
| +++ b/src/google/protobuf/port_def.inc |
| @@ -435,13 +435,15 @@ |
| # endif |
| #else |
| -# if defined(__cpp_constinit) && !defined(__CYGWIN__) |
| +// Emscripten's libc++ std::string is not constexpr-constructible (heap alloc). |
| +# if defined(__cpp_constinit) && !defined(__CYGWIN__) && !defined(__EMSCRIPTEN__) |
| # define PROTOBUF_CONSTINIT constinit |
| # define PROTOBUF_CONSTEXPR constexpr |
| # define PROTOBUF_CONSTINIT_DEFAULT_INSTANCES |
| // Some older Clang versions incorrectly raise an error about |
| // constant-initializing weak default instance pointers. Versions 12.0 and |
| // higher seem to work, except that XCode 12.5.1 shows the error even though it |
| // uses Clang 12.0.5. |
| -#elif !defined(__CYGWIN__) && !defined(__MINGW32__) && \ |
| +#elif !defined(__CYGWIN__) && !defined(__MINGW32__) && \ |
| + !defined(__EMSCRIPTEN__) && \ |
| ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) && \ |
| ((defined(__APPLE__) && PROTOBUF_CLANG_MIN(13, 0)) || \ |
| (!defined(__APPLE__) && PROTOBUF_CLANG_MIN(12, 0))) |