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 with gcc 13.1 #33634

Closed
Nathan-M-code opened this issue Jul 7, 2023 · 6 comments
Closed

compilation error with gcc 13.1 #33634

Nathan-M-code opened this issue Jul 7, 2023 · 6 comments

Comments

@Nathan-M-code
Copy link

What version of gRPC and what language are you using?

v1.56.0

What operating system (Linux, Windows,...) and version?

Windows 10, cmake 3.26.4, ninja, ccache, lld

What runtime / compiler are you using (e.g. python version or version of gcc)

compiler from : winlibs-x86_64-posix-seh-gcc-13.1.0-llvm-16.0.5-mingw-w64msvcrt-11.0.0-r5
-- The CXX compiler identification is GNU 13.1.0

What did you do?

Please provide either 1) A unit test for reproducing the bug or 2) Specific steps for us to follow to reproduce the bug. If there’s not enough information to debug the problem, gRPC team may close the issue at their discretion. You’re welcome to re-open the issue once you have a reproduction.

In a powershell script :

$repoUrl = "https://github.com/grpc/grpc"
$gitTag = "v1.56.0"

git clone --recurse-submodules -b $gitTag --depth 1 --shallow-submodules $repoUrl

cd grpc
md my_build
cd my_build

cmake -GNinja -DCMAKE_CXX_FLAGS="-fuse-ld=lld -w" -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$installPath" ..
cmake --build .
cmake --install .

What did you expect to see?

correct compilation

What did you see instead?

[51/2602] Building CXX object CMakeFiles/grpc.dir/src/core/ext/filters/backend_metrics/backend_metric_filter.cc.obj
FAILED: CMakeFiles/grpc.dir/src/core/ext/filters/backend_metrics/backend_metric_filter.cc.obj 
C:\PROGRA~1\mingw64\bin\C__~1.EXE -DCARES_STATICLIB -D_WIN32_WINNT=0x600 -IC:/FactoryCapi/external_deps/grpc/third_party/re2 -IC:/FactoryCapi/external_deps/grpc/third_party/zlib -IC:/FactoryCapi/external_deps/grpc/include -IC:/FactoryCapi/external_deps/grpc -IC:/FactoryCapi/external_deps/grpc/third_party/address_sorting/include -IC:/FactoryCapi/external_deps/grpc/my_build/third_party/re2 -IC:/FactoryCapi/external_deps/grpc/third_party/boringssl-with-bazel/src/include -IC:/FactoryCapi/external_deps/grpc/src/core/ext/upb-generated -IC:/FactoryCapi/external_deps/grpc/src/core/ext/upbdefs-generated -IC:/FactoryCapi/external_deps/grpc/third_party/upb -IC:/FactoryCapi/external_deps/grpc/third_party/utf8_range -IC:/FactoryCapi/external_deps/grpc/third_party/xxhash -IC:/FactoryCapi/external_deps/grpc/my_build/third_party/zlib -IC:/FactoryCapi/external_deps/grpc/my_build/third_party/cares/cares -IC:/FactoryCapi/external_deps/grpc/third_party/cares/cares -IC:/FactoryCapi/external_deps/grpc/third_party/cares/cares/include -IC:/FactoryCapi/external_deps/grpc/third_party/abseil-cpp -fuse-ld=lld -w  -O3 -DNDEBUG -MD -MT CMakeFiles/grpc.dir/src/core/ext/filters/backend_metrics/backend_metric_filter.cc.obj -MF CMakeFiles\grpc.dir\src\core\ext\filters\backend_metrics\backend_metric_filter.cc.obj.d -o CMakeFiles/grpc.dir/src/core/ext/filters/backend_metrics/backend_metric_filter.cc.obj -c C:/FactoryCapi/external_deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc
In file included from C:/FactoryCapi/external_deps/grpc/src/core/lib/channel/channelz.h:43,
                 from C:/FactoryCapi/external_deps/grpc/src/core/lib/surface/channel.h:47,
                 from C:/FactoryCapi/external_deps/grpc/src/core/lib/surface/call.h:51,
                 from C:/FactoryCapi/external_deps/grpc/src/core/lib/channel/promise_based_filter.h:66,
                 from C:/FactoryCapi/external_deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.h:28,
                 from C:/FactoryCapi/external_deps/grpc/src/core/ext/filters/backend_metrics/backend_metric_filter.cc:17:
C:/FactoryCapi/external_deps/grpc/src/core/lib/gprpp/per_cpu.h: In instantiation of 'grpc_core::PerCpu<T>::PerCpu(grpc_core::PerCpuOptions) [with T = grpc_core::channelz::PerCpuCallCountingHelper::PerCpuData]':
C:/FactoryCapi/external_deps/grpc/src/core/lib/channel/channelz.h:182:70:   required from here
C:/FactoryCapi/external_deps/grpc/src/core/lib/gprpp/per_cpu.h:70:30: internal compiler error: Segmentation fault
   70 |   std::unique_ptr<T[]> data_{new T[cpus_]};
      |                              ^~~~~~~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.

Anything else we should know about your project / environment?

With GCC 12.3 it's ok, should I send a report to gcc or you can fix it yourself ?

@cheese
Copy link

cheese commented Jul 10, 2023

I met the same issue on Linux. It can be worked around by moving the code to the member-initializer.

index 5d287f8c7f..f2263eff2c 100644
--- a/src/core/lib/gprpp/per_cpu.h
+++ b/src/core/lib/gprpp/per_cpu.h
@@ -56,7 +56,7 @@ class PerCpu {
  public:
   // Options are not defaulted to try and force consideration of what the
   // options specify.
-  explicit PerCpu(PerCpuOptions options) : cpus_(options.Shards()) {}
+  explicit PerCpu(PerCpuOptions options) : cpus_(options.Shards()), data_{new T[cpus_]} {}
 
   T& this_cpu() { return data_[ExecCtx::Get()->starting_cpu() % cpus_]; }
 
@@ -67,7 +67,7 @@ class PerCpu {
 
  private:
   const size_t cpus_;
-  std::unique_ptr<T[]> data_{new T[cpus_]};
+  std::unique_ptr<T[]> data_;
 };
 
 }  // namespace grpc_core

@cheese
Copy link

cheese commented Jul 11, 2023

I built GCC from git 1e6a948cd22f2f142cdc828296f78c7af9e283c8 and found the issue is also fixed.

@cheese
Copy link

cheese commented Jul 11, 2023

@Nathan-M-code
Copy link
Author

I met the same issue on Linux. It can be worked around by moving the code to the member-initializer.

This indeed resolve the file compilation, thank you !

But then, there is another problem with protobuf linking, did you have the same issue ?

[2080/2550] Linking CXX executable third_party\protobuf\protoc.exe
FAILED: third_party/protobuf/protoc.exe 
cmd.exe /C "cd . && C:\PROGRA~1\mingw64\bin\C__~1.EXE -fuse-ld=lld -w  -O3 -DNDEBUG  @CMakeFiles\protoc.rsp -o third_party\protobuf\protoc.exe -Wl,--out-implib,third_party\protobuf\libprotoc.dll.a -Wl,--major-image-version,23,--minor-image-version,1  && cd ."
lld: error: unable to find library -ldbghelp
lld: error: unable to find library -ladvapi32
lld: error: unable to find library -lkernel32
lld: error: unable to find library -luser32
lld: error: unable to find library -lgdi32
lld: error: unable to find library -lwinspool
lld: error: unable to find library -lshell32
lld: error: unable to find library -lole32
lld: error: unable to find library -loleaut32
lld: error: unable to find library -luuid
lld: error: unable to find library -lcomdlg32
lld: error: unable to find library -ladvapi32
lld: error: unable to find library -lstdc++
lld: error: unable to find library -lmingw32
lld: error: unable to find library -lgcc_s
lld: error: unable to find library -lgcc
lld: error: unable to find library -lmoldname
lld: error: unable to find library -lmingwex
lld: error: unable to find library -lmsvcrt
lld: error: unable to find library -lkernel32
lld: error: too many errors emitted, stopping now
collect2.exe: error: ld returned 1 exit status

@eugeneo
Copy link
Contributor

eugeneo commented Jul 18, 2023

This seems like a compiler bug and environment issue.

@eugeneo eugeneo closed this as completed Jul 18, 2023
@orzel
Copy link

orzel commented Aug 22, 2023

I have the same problem with gcc 12.2.1. Exact version is "12.2.1_p20230428-r1 p2", from gentoo.

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

No branches or pull requests

4 participants