rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.76k stars 312 forks source link

Bear build fails on Amazon Linux #467

Closed abialystok closed 2 years ago

abialystok commented 2 years ago

Bear build fails. output:

[ 19%] Built target grpc_dependency
[ 19%] Built target googletest_dependency
[ 39%] Built target nlohmann_json_dependency
[ 58%] Built target fmt_dependency
[ 78%] Built target spdlog_dependency
[ 80%] Performing configure step for 'BearSource'
loading initial cache file  <Build dir>/subprojects/tmp/BearSource/BearSource-cache-Release.cmake
-- Looking for protoc ...  <Build dir>/subprojects/Install/grpc_dependency/bin/protoc
-- Looking for grpc_cpp_plugin ...  <Build dir>/subprojects/Install/grpc_dependency/bin/grpc_cpp_plugin
-- Configuring done
CMake Error at intercept/CMakeLists.txt:32 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at citnames/CMakeLists.txt:20 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at bear/CMakeLists.txt:2 (add_executable):
  Cannot find source file:

   <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

-- Generating done
-- Build files have been written to:  <Build dir>/subprojects/Build/BearSource
make[2]: *** [subprojects/Stamp/BearSource/BearSource-configure] Error 1
make[1]: *** [CMakeFiles/BearSource.dir/all] Error 2
make: *** [all] Error 2

To Reproduce Clone bear repo, create a build directory, and from it run:

cmake -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF $BEAR_SOURCE_DIR
make all

make all fails.

Expected behavior Successfull build

Environment:

rizsotto commented 2 years ago

Thanks for the report @abialystok . Could you check what tools do you have available? (CMake version, make version, compiler version, etc...) Or alternatively, could you link the "Amazon Linux 2" docker image onto the ticket?

abialystok commented 2 years ago

Sure. Versions:

➜  ~ cmake3 --version                                                          
cmake3 version 3.13.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
➜  ~ make --version                                                                                                          
GNU Make 3.82
Built for x86_64-koji-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
➜  ~ gcc --version                                         
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

➜  ~ g++ --version
g++ (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Regarding docket image, I'm not sure but it could be this one: https://hub.docker.com/_/amazonlinux Let me know if there's any other info that can be useful

rizsotto commented 2 years ago

Ok, I could use that docker image... and here are my findings:

abialystok commented 2 years ago

Upgrading cmake did fix this error message. I upgraded to gcc10 (for some reason the gcc8 package doesn't exist here), but the filesystem thing doesn't work:

# gcc --version
gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# make all 
[  0%] Built target grpc_dependency
[  0%] Built target nlohmann_json_dependency
[  0%] Built target fmt_dependency
[  0%] Built target googletest_dependency
[  0%] Built target spdlog_dependency
[ 11%] Performing build step for 'BearSource'
[  1%] Built target flags_a
[  3%] Built target shell_a
[  4%] Building CXX object libsys/CMakeFiles/sys_a.dir/source/Path.cc.o
In file included from <Bear source dir>/source/libsys/source/Path.cc:20:0:
<Bear source dir>//source/libsys/include/libsys/Path.h:25:10: fatal error: filesystem: No such file or directory
 #include <filesystem>
          ^~~~~~~~~~~~
compilation terminated.
make[5]: *** [libsys/CMakeFiles/sys_a.dir/source/Path.cc.o] Error 1
make[4]: *** [libsys/CMakeFiles/sys_a.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [subprojects/Stamp/BearSource/BearSource-build] Error 2
make[1]: *** [CMakeFiles/BearSource.dir/all] Error 2
make: *** [all] Error 2

Should it work with GCC 10?

rizsotto commented 2 years ago

Yes, recent version of GCC will work. But multiple version of GCC on your machine might be an issue, if that's not properly configured. (Just a reminder, you need the C++ library to be C++17 compatible too. Not sure is that a separate package on your machine, or brought by the new version of the compiler.)

The filesystem header is part of the C++17 standard. So, if you have a properly configured C++17 env, this should compile.

selfbypass commented 2 years ago

Bear build fails. output:

[ 19%] Built target grpc_dependency
[ 19%] Built target googletest_dependency
[ 39%] Built target nlohmann_json_dependency
[ 58%] Built target fmt_dependency
[ 78%] Built target spdlog_dependency
[ 80%] Performing configure step for 'BearSource'
loading initial cache file  <Build dir>/subprojects/tmp/BearSource/BearSource-cache-Release.cmake
-- Looking for protoc ...  <Build dir>/subprojects/Install/grpc_dependency/bin/protoc
-- Looking for grpc_cpp_plugin ...  <Build dir>/subprojects/Install/grpc_dependency/bin/grpc_cpp_plugin
-- Configuring done
CMake Error at intercept/CMakeLists.txt:32 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at citnames/CMakeLists.txt:20 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at bear/CMakeLists.txt:2 (add_executable):
  Cannot find source file:

   <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

-- Generating done
-- Build files have been written to:  <Build dir>/subprojects/Build/BearSource
make[2]: *** [subprojects/Stamp/BearSource/BearSource-configure] Error 1
make[1]: *** [CMakeFiles/BearSource.dir/all] Error 2
make: *** [all] Error 2

To Reproduce Clone bear repo, create a build directory, and from it run:

cmake -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF $BEAR_SOURCE_DIR
make all

make all fails.

Expected behavior Successfull build

Environment:

  • OS name: Linux
  • OS version: Amazon Linux 2
  • OS architecture: x86_64
  • Bear version: from master branch.
  • Bear install method: Build from source.

Bear build fails. output:

[ 19%] Built target grpc_dependency
[ 19%] Built target googletest_dependency
[ 39%] Built target nlohmann_json_dependency
[ 58%] Built target fmt_dependency
[ 78%] Built target spdlog_dependency
[ 80%] Performing configure step for 'BearSource'
loading initial cache file  <Build dir>/subprojects/tmp/BearSource/BearSource-cache-Release.cmake
-- Looking for protoc ...  <Build dir>/subprojects/Install/grpc_dependency/bin/protoc
-- Looking for grpc_cpp_plugin ...  <Build dir>/subprojects/Install/grpc_dependency/bin/grpc_cpp_plugin
-- Configuring done
CMake Error at intercept/CMakeLists.txt:32 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at citnames/CMakeLists.txt:20 (add_library):
  Cannot find source file:

    <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at bear/CMakeLists.txt:2 (add_executable):
  Cannot find source file:

   <Build dir>/subprojects/Build/BearSource/libflags/CMakeFiles/flags_a.dir/source/Flags.cc.o

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

-- Generating done
-- Build files have been written to:  <Build dir>/subprojects/Build/BearSource
make[2]: *** [subprojects/Stamp/BearSource/BearSource-configure] Error 1
make[1]: *** [CMakeFiles/BearSource.dir/all] Error 2
make: *** [all] Error 2

To Reproduce Clone bear repo, create a build directory, and from it run:

cmake -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF $BEAR_SOURCE_DIR
make all

make all fails.

Expected behavior Successfull build

Environment:

  • OS name: Linux
  • OS version: Amazon Linux 2
  • OS architecture: x86_64
  • Bear version: from master branch.
  • Bear install method: Build from source.

Hi, I also meet this issue on ubuntu 16.04. Do you resolve it?

abialystok commented 2 years ago

Steps mentioned by @rizsotto should solve it. Unfortunately I didn't find a way to install the GCC version required on my Linux distro, with libraries and everything, so I gave up on it. Closing this issue now because I don't plan to continue working on it.

selfbypass commented 2 years ago

Ok, I could use that docker image... and here are my findings:

  • The CMake needs to be updated! I've downloaded the latest stable (3.23.3) from here, and it fixed the error message you got... To fix this in Bear could be: to fail if the CMake version is 3.13 or smaller. (Currently it fails if the version is smaller than 3.12)
  • The next failure you are going to face if you install a new CMake is the C++ compiler. You need full support of C++17, which is in 8.x version of GCC. (Otherwise you need to add the extra filesystem flags as CXXFLAGS. Not sure if that's going to work, because I do not test this on the builds)

Yes, I update to G++-9 and CMake(3.24.0) and solve this issue.

kailiangji commented 9 months ago

for the fmt dependency, I recommend using fmt 9.0.0. For fmt 10, I got the undefined reference error undefined reference to `spdlog::details::log_msg::log_msg(spdlog::source_loc, fmt::v10::basic_string_view, spdlog::level::level_enum, fmt::v10::basic_string_view)