google / bloaty

Bloaty: a size profiler for binaries
Apache License 2.0
4.71k stars 340 forks source link

Doesn't build on Ubuntu 21.10 / clang-13 #296

Open jwbee opened 2 years ago

jwbee commented 2 years ago

Out of the box one of the submodules fails to build with:

../third_party/googletest/googlemock/include/gmock/gmock-matchers.h:891:3: error: definition of implicit copy constructor for 'EndsWithMatcher<std::basic_string<wchar_t>>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]

Upstream googletest seems to build fine at head. Perhaps update the submodule?

zchrissirhcz commented 2 years ago

I'm using ubuntu20.04 with Clang14 compiler, build the latest commit(8210e31), also meet similar compilation error.

compiler

CC and CXX env vars pointing to Clang compiler, which with version:

Ubuntu clang version 14.0.0-++20211207052700+51dc466642c5-1~exp1~20211207173249.80
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

During running cmake it verifies this:

$ cd bloaty
$ mkdir build && cd build && cmake .. -GNinja && cmake --build .
...
-- The C compiler identification is Clang 14.0.0
-- The CXX compiler identification is Clang 14.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
...

Full error

/home/zz/work/github/bloaty/src/pe.cc:32:18: warning: unused variable 'kSymbol32Size' [-Wunused-const-variable]
constexpr size_t kSymbol32Size = 20;
                 ^
3 warnings generated.
[131/140] Building CXX object third_party/googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
FAILED: third_party/googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o 
/usr/bin/clang++ -DUSE_RE2 -D_LIBCXXABI_FUNC_VIS="" -I/home/zz/work/github/bloaty/third_party/re2 -I/home/zz/work/github/bloaty/third_party/capstone/include -I/home/zz/work/github/bloaty/. -I/home/zz/work/github/bloaty/src -I/home/zz/work/github/bloaty/third_party/abseil-cpp -I/home/zz/work/github/bloaty/build/linux-x64/src -I/home/zz/work/github/bloaty/third_party/googletest/googlemock/include -I/home/zz/work/github/bloaty/third_party/googletest/googlemock -isystem /home/zz/work/github/bloaty/third_party/googletest/googletest/include -isystem /home/zz/work/github/bloaty/third_party/googletest/googletest -W -Wall -Wno-sign-compare -fdiagnostics-color=always -O2 -Wall -Wshadow -Werror -Wconversion -DGTEST_HAS_PTHREAD=1 -fexceptions -W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls -pthread -std=c++11 -MD -MT third_party/googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o -MF third_party/googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o.d -o third_party/googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o -c /home/zz/work/github/bloaty/third_party/googletest/googlemock/src/gmock-all.cc
In file included from /home/zz/work/github/bloaty/third_party/googletest/googlemock/src/gmock-all.cc:39:
In file included from /home/zz/work/github/bloaty/third_party/googletest/googlemock/include/gmock/gmock.h:59:
/home/zz/work/github/bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:454:3: error: definition of implicit copy constructor for 'PolymorphicAction<testing::internal::ReturnNullAction>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
  ^
/home/zz/work/github/bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:679:8: note: expanded from macro 'GTEST_DISALLOW_ASSIGN_'
  void operator=(type const &) = delete
       ^
/home/zz/work/github/bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1010:10: note: in implicit copy constructor for 'testing::PolymorphicAction<testing::internal::ReturnNullAction>' first required here
  return MakePolymorphicAction(internal::ReturnNullAction());
greenrobot commented 2 years ago

With Ubuntu 22.04 and clang 14 I'm getting 12 compile errors like these:

bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:454:3: error: definition of implicit copy constructor for 'PolymorphicAction<testing::internal::ReturnNullAction>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
  ^
greenrobot commented 2 years ago

PS.: gcc on Ubuntu 22.04 worked: cmake -B build -G Ninja -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -S .

Maybe mention this in the readme?

keith commented 1 year ago

If you don't actually need to run the tests you can just build the bloaty binary only directly with cd build && ninja bloaty