Ubuntu Jammy can’t compile fuzz tests with libc++? #24289

issue MarcoFalke openend this issue on February 8, 2022
  1. MarcoFalke commented at 11:20 am on February 8, 2022: member

    Steps to reproduce on a fresh Ubuntu install:

    0export DEBIAN_FRONTEND=noninteractive && apt update && apt install curl wget htop git vim ccache -y && git clone https://github.com/bitcoin/bitcoin.git bitcoin-core && cd bitcoin-core && apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq     libevent-dev libboost-system-dev libboost-test-dev  clang llvm libc++-dev libc++abi-dev  -y   &&  ./autogen.sh && ./configure CC=clang CXX='clang++ -stdlib=libc++'   --enable-fuzz --with-sanitizers=fuzzer && make -j$(nproc)
    

    Ubuntu Focal: (Passes) Ubuntu Jammy: (fails)

    0checking whether the linker accepts -fsanitize=fuzzer... no
    1configure: error: linker did not accept requested flags, you are missing required libraries
    
  2. MarcoFalke added the label Build system on Feb 8, 2022
  3. MarcoFalke added the label Questions and Help on Feb 8, 2022
  4. MarcoFalke added the label Tests on Feb 8, 2022
  5. MarcoFalke commented at 11:37 am on February 8, 2022: member
    Debian Bullseye: (Passes) Debian Bookworm: Fails with the same error
  6. MarcoFalke added the label Upstream on Feb 8, 2022
  7. MarcoFalke commented at 12:11 pm on February 8, 2022: member

    Minimized test case:

    0cat /tmp/a.cpp 
    1#include <stdint.h>
    2#include <stddef.h>
    3extern "C" int LLVMFuzzerTestOneInput(const uint8_t *, size_t ) {   return 0; }
    
    0clang++ -fsanitize=fuzzer /tmp/a.cpp # (passes)
    
    0clang++ -stdlib=libc++ -fsanitize=fuzzer /tmp/a.cpp # (fails)
    
  8. MarcoFalke commented at 12:54 pm on February 8, 2022: member

    Error message snippets:

     0$ clang++ -stdlib=libc++  -fuse-ld=lld -fsanitize=fuzzer /tmp/a.cpp
     1ld.lld: error: undefined symbol: std::ios_base::ios_base()
     2>>> referenced by FuzzerDataFlowTrace.cpp.o:(fuzzer::BlockCoverage::AppendCoverage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt
     3.fuzzer-x86_64.a
     4>>> referenced by FuzzerDataFlowTrace.cpp.o:(fuzzer::BlockCoverage::AppendCoverage(std::istream&)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a
     5>>> referenced by FuzzerFork.cpp.o:(fuzzer::FuzzWithFork(fuzzer::Random&, fuzzer::FuzzingOptions const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fuzzer::fuzzer_allocator<std::__cxx11::b
     6asic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fuzzer::fuzzer_allocator<std::__cxx11::basic_string<char, std::char_
     7traits<char>, std::allocator<char> > > > const&, int)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a
     8>>> referenced 6 more times
     9
    10ld.lld: error: undefined symbol: vtable for std::basic_ios<char, std::char_traits<char> >
    11>>> referenced by FuzzerDataFlowTrace.cpp.o:(fuzzer::BlockCoverage::AppendCoverage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt
    12.fuzzer-x86_64.a
    13>>> referenced by FuzzerDataFlowTrace.cpp.o:(fuzzer::BlockCoverage::AppendCoverage(std::istream&)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a
    14>>> referenced by FuzzerFork.cpp.o:(fuzzer::FuzzWithFork(fuzzer::Random&, fuzzer::FuzzingOptions const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fuzzer::fuzzer_allocator<std::__cxx11::b
    15asic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fuzzer::fuzzer_allocator<std::__cxx11::basic_string<char, std::char_
    16traits<char>, std::allocator<char> > > > const&, int)) in archive /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a
    17>>> referenced 4 more times
    18>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
    19
    20...
    
     0$ clang++ -stdlib=libc++   -fsanitize=fuzzer /tmp/a.cpp
     1/usr/bin/ld: /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerIO.cpp.o): in function `fuzzer::FileToVector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long,
     2 bool)':
     3(.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x30): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::__cxx11::basic_string<char, std::char_traits<c
     4har>, std::allocator<char> > const&, std::_Ios_Openmode)'
     5/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x64): undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
     6/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x6c): undefined reference to `std::istream::tellg()'
     7/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x93): undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
     8/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x1f1): undefined reference to `std::istream::read(char*, long)'
     9/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x207): undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
    10/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x233): undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
    11/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x243): undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
    12/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x24f): undefined reference to `std::__basic_file<char>::~__basic_file()'
    13/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x256): undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
    14/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x26d): undefined reference to `std::locale::~locale()'
    15/usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x29b): undefined reference to `std::ios_base::~ios_base()'
    16/usr/bin/ld: /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerIO.cpp.o): in function `fuzzer::FileToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    17(.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x23): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::__cxx11::basic_string<char, std::char_traits<cha
    18r>, std::allocator<char> > const&, std::_Ios_Openmode)'
    19/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x59): undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
    20/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x85): undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
    21/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x95): undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
    22/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa1): undefined reference to `std::__basic_file<char>::~__basic_file()'
    23/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa8): undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
    24/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xbf): undefined reference to `std::locale::~locale()'
    25/usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xed): undefined reference to `std::ios_base::~ios_base()'
    26/usr/bin/ld: /usr/lib/llvm-13/lib/clang/13.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerIO.cpp.o): in function `fuzzer::CopyFileToErr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    27(.text._ZN6fuzzer13CopyFileToErrERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x23): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::__cxx11::basic_string<char, std::char_traits<ch
    28ar>, std::allocator<char> > const&, std::_Ios_Openmode)'
    29...
    
  9. MarcoFalke closed this on Feb 14, 2022

  10. DrahtBot locked this on Feb 14, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me