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

issue MarcoFalke opened 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:

    export 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)

    checking whether the linker accepts -fsanitize=fuzzer... no
    configure: 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:

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

    Error message snippets:

    $ clang++ -stdlib=libc++  -fuse-ld=lld -fsanitize=fuzzer /tmp/a.cpp
    ld.lld: error: undefined symbol: std::ios_base::ios_base()
    >>> 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
    .fuzzer-x86_64.a
    >>> 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
    >>> 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
    asic_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_
    traits<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
    >>> referenced 6 more times
    
    ld.lld: error: undefined symbol: vtable for std::basic_ios<char, std::char_traits<char> >
    >>> 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
    .fuzzer-x86_64.a
    >>> 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
    >>> 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
    asic_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_
    traits<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
    >>> referenced 4 more times
    >>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
    
    ...
    
    $ clang++ -stdlib=libc++   -fsanitize=fuzzer /tmp/a.cpp
    /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,
     bool)':
    (.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
    har>, std::allocator<char> > const&, std::_Ios_Openmode)'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x64): undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x6c): undefined reference to `std::istream::tellg()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x93): undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x1f1): undefined reference to `std::istream::read(char*, long)'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x207): undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x233): undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x243): undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x24f): undefined reference to `std::__basic_file<char>::~__basic_file()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x256): undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x26d): undefined reference to `std::locale::~locale()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToVectorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb+0x29b): undefined reference to `std::ios_base::~ios_base()'
    /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&)':
    (.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
    r>, std::allocator<char> > const&, std::_Ios_Openmode)'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x59): undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x85): undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x95): undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa1): undefined reference to `std::__basic_file<char>::~__basic_file()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa8): undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xbf): undefined reference to `std::locale::~locale()'
    /usr/bin/ld: (.text._ZN6fuzzer12FileToStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xed): undefined reference to `std::ios_base::~ios_base()'
    /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&)':
    (.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
    ar>, std::allocator<char> > const&, std::_Ios_Openmode)'
    ...
    
  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: 2026-04-17 00:14 UTC

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