secure-software-engineering / phasar

A LLVM-based static analysis framework.
Other
930 stars 140 forks source link

LLVM not buildable on Ubuntu 20.04 #526

Closed printerboi closed 1 year ago

printerboi commented 1 year ago

Bug description

With the current configuration the project isn't buildable. The building of LLVM 14.0.0 fails with the following message

/tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:38:3: note: candidate: ‘constexpr std::__1::__compressed_pair_elem<_Tp, _Idx, _CanBeEmptyBase>::__compressed_pair_elem(std::__1::__default_init_tag) [with _Tp = std::__1::__builtin_new_allocator::__builtin_new_deleter; int _Idx = 1; bool _CanBeEmptyBase = false]’ 38 | __compressed_pair_elem(__default_init_tag) {} | ^~~~~~~~~~~~~~~~~~~~~~ /tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:38:26: note: no known conversion for argument 1 from ‘std::__1::__builtin_new_allocator::__builtin_new_deleter’ to ‘std::__1::__default_init_tag’ 38 | __compressed_pair_elem(__default_init_tag) {} | ^~~~~~~~~~~~~~~~~~ /tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:32:8: note: candidate: ‘constexpr std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>::__compressed_pair_elem(const std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>&)’ 32 | struct __compressed_pair_elem { | ^~~~~~~~~~~~~~~~~~~~~~ /tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:32:8: note: no known conversion for argument 1 from ‘std::__1::__builtin_new_allocator::__builtin_new_deleter’ to ‘const std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>&’ /tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:32:8: note: candidate: ‘constexpr std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>::__compressed_pair_elem(std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>&&)’ /tmp/llvm-10_build.X8LBSiTM/llvm-project/build/include/c++/v1/__memory/compressed_pair.h:32:8: note: no known conversion for argument 1 from ‘std::__1::__builtin_new_allocator::__builtin_new_deleter’ to ‘std::__1::__compressed_pair_elem<std::__1::__builtin_new_allocator::__builtin_new_deleter, 1, false>&&’ [3313/6673] Building CXX object tools/lli/CMakeFiles/lli.dir/ExecutionUtils.cpp.o [3314/6673] Building CXX object tools/llc/CMakeFiles/llc.dir/llc.cpp.o [3315/6673] Building CXX object tools/lli/CMakeFiles/lli.dir/lli.cpp.o [3316/6673] Building CXX object lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilder.cpp.o ninja: build stopped: subcommand failed.

If the LLVM-Version is switched to a version <14, PhASAR can't be builded as it requires Opaque Pointers, which appeared for the first time in LLVM14.0.0.

All attempts using the docker-variant also failed, as the DOCKERFILE in the development-branch builds 12.0.0, which leads to the above mentioned error regarding Opaque Pointers. Changing the version of LLVM to 14.0.0 also fails, at the above mentioned step.

Steps to reproduce

Actual result: The installation of the project fails, as either LLVM or phasar could not be build.

Expected result: The installation completes and the phasar-llvm can be executed using the cli

Context (Environment)

Operating System:

Build Type:

Possible solution

Example files

Log containing the output of bootstrap.sh during installation: install.log

jusito commented 1 year ago

Seems like llvm-13 and above doesn't support gcc below 10. For ubuntu 20.04 there is gcc-10 and clang-12 available in the official repositories, that should fix it.

printerboi commented 1 year ago

Switching the version of gcc (gcc version 10.3.0) ), g++ and clang (Ubuntu clang version 12.0.0-3ubuntu1~20.04.5) seems to fix the above building problem, but the building of LLVM still doesn't complete:

[3310/6673] Copying compiler-rt's sanitizer/allocator_interface.h...
[3311/6673] Building CXX object projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_aux_runtime.cpp.o
[3312/6673] Building CXX object projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o
FAILED: projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o 
/usr/bin/c++  -DHAVE___CXA_THREAD_ATEXIT_IMPL -D_GNU_SOURCE -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCXXABI_BUILDING_LIBRARY -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxxabi/src -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src -Iinclude -I/tmp/llvm-10_build.en5t8IPh/llvm-project/llvm/include -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/include -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/../libcxx/src -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections  -O3 -DNDEBUG -fPIC   -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wunused-function -Wshadow -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-suggest-override -Wno-error -pedantic -fstrict-aliasing -funwind-tables -D_DEBUG -UNDEBUG -I/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1 -std=c++2a -MD -MT projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o -MF projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o.d -o projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o -c /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/cxa_default_handlers.cpp
In file included from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/strong_order.h:12,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/weak_order.h:14,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/partial_order.h:14,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/compare_partial_order_fallback.h:13,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/compare:144,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/utility:236,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__functional_base:26,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/memory:808,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/../libcxx/src/include/atomic_support.h:13,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/cxa_default_handlers.cpp:19:
/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__bit/bit_cast.h: In function ‘constexpr _ToType std::__1::bit_cast(const _FromType&)’:
/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__bit/bit_cast.h:31:38: error: expected primary-expression before ‘,’ token
   31 |     return __builtin_bit_cast(_ToType, __from);
      |                                      ^
[3313/6673] Building CXX object projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o
FAILED: projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o 
/usr/bin/c++  -DHAVE___CXA_THREAD_ATEXIT_IMPL -D_GNU_SOURCE -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCXXABI_BUILDING_LIBRARY -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxxabi/src -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src -Iinclude -I/tmp/llvm-10_build.en5t8IPh/llvm-project/llvm/include -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/include -I/tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/../libcxx/src -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections  -O3 -DNDEBUG -fPIC   -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wunused-function -Wshadow -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-suggest-override -Wno-error -pedantic -fstrict-aliasing -funwind-tables -D_DEBUG -UNDEBUG -I/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1 -std=c++2a -MD -MT projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o -MF projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o.d -o projects/libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o -c /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/cxa_demangle.cpp
In file included from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/strong_order.h:12,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/weak_order.h:14,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/partial_order.h:14,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__compare/compare_partial_order_fallback.h:13,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/compare:144,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/utility:236,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__algorithm/search.h:16,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/functional:493,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/algorithm:667,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/array:114,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/demangle/Utility.h:20,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/demangle/ItaniumDemangle.h:25,
                 from /tmp/llvm-10_build.en5t8IPh/llvm-project/libcxxabi/src/cxa_demangle.cpp:13:
/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__bit/bit_cast.h: In function ‘constexpr _ToType std::__1::bit_cast(const _FromType&)’:
/tmp/llvm-10_build.en5t8IPh/llvm-project/build/include/c++/v1/__bit/bit_cast.h:31:38: error: expected primary-expression before ‘,’ token
   31 |     return __builtin_bit_cast(_ToType, __from);
      |                                      ^
[3314/6673] Building CXX object tools/lli/CMakeFiles/lli.dir/ExecutionUtils.cpp.o
[3315/6673] Building CXX object tools/llc/CMakeFiles/llc.dir/llc.cpp.o
[3316/6673] Building CXX object tools/lli/CMakeFiles/lli.dir/lli.cpp.o
[3317/6673] Building CXX object lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilder.cpp.o
ninja: build stopped: subcommand failed.

Full log from this attempt: install.log

Update:

Revisiting the llvm-project-Repo, I found that there might be an Problem with gcc-10 and LLVM-14. I will give gcc-11 a try and will report back on it!

printerboi commented 1 year ago

By experimenting with the gcc versions, I came to the conclusion, that gcc-11 is mandatory in order to build llvm-14. But gcc-11 is not available in the basic package repo for Ubuntu 20.04. I got gcc-11 from ppa:ubuntu-toolchain-r/test. I therefore suggest to update bootstrap.sh to specifically download gcc-11 and g++-11.

jusito commented 1 year ago

Thanks for the feedback, we should put it in the docs at least, currently testing it for clang-12 because it would be available without ppa.

Edit: clang-10 and above is working