Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build with libc++ 14 #407

Closed
12101111 opened this issue Mar 27, 2022 · 4 comments
Closed

Failed to build with libc++ 14 #407

12101111 opened this issue Mar 27, 2022 · 4 comments

Comments

@12101111
Copy link

12101111 commented Mar 27, 2022

Build mold 1.1.1 using llvm 14.0.0:

elf/arch-riscv64.cc:206:18: error: no viable conversion from 'std::vector<i32>' (aka 'vector<int>') to 'std::span<i32>' (aka 'span<int>')
  std::span<i32> r_deltas = get_r_deltas();
                 ^          ~~~~~~~~~~~~~~
/usr/include/c++/v1/span:401:15: note: candidate constructor not viable: no known conversion from 'std::vector<i32>' (aka 'vector<int>') to
      'const std::span<int, 18446744073709551615> &' for 1st argument
    constexpr span           (const span&) noexcept = default;
              ^
/usr/include/c++/v1/span:425:15: note: candidate template ignored: could not match 'type_identity_t<std::span<int, 18446744073709551615>::element_type>[_Sz]'
      (aka 'int[_Sz]') against 'std::vector<i32>' (aka 'vector<int>')
    constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
              ^
/usr/include/c++/v1/span:430:15: note: candidate template ignored: could not match 'array' against 'vector'
    constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
              ^
/usr/include/c++/v1/span:435:15: note: candidate template ignored: could not match 'array' against 'vector'
    constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
              ^
/usr/include/c++/v1/span:445:19: note: candidate template ignored: could not match 'span' against 'vector'
        constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
                  ^

Full log: http://fars.ee/knKs

@rui314
Copy link
Owner

rui314 commented Mar 31, 2022

I believe this issue has been fixed with the above change. Can you try again?

@rui314 rui314 closed this as completed Mar 31, 2022
@12101111
Copy link
Author

5edd07e:

> make -j1 CXX=clang++
mkdir -p out/elf
touch out/elf/.keep
mkdir -p out/macho
touch out/macho/.keep
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/compress.o -MMD -MP -MF out/compress.d -O2 -c -o out/compress.o compress.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/demangle.o -MMD -MP -MF out/demangle.d -O2 -c -o out/demangle.o demangle.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/filepath.o -MMD -MP -MF out/filepath.d -O2 -c -o out/filepath.o filepath.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/hyperloglog.o -MMD -MP -MF out/hyperloglog.d -O2 -c -o out/hyperloglog.o hyperloglog.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/main.o -MMD -MP -MF out/main.d -O2 -c -o out/main.o main.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/perf.o -MMD -MP -MF out/perf.d -O2 -c -o out/perf.o perf.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/strerror.o -MMD -MP -MF out/strerror.d -O2 -c -o out/strerror.o strerror.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/tar.o -MMD -MP -MF out/tar.d -O2 -c -o out/tar.o tar.cc
clang++ -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Ithird-party/xxhash -DMOLD_VERSION=\"1.1.1\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"5edd07efd914f86cf68ba240703c251630a7e571\" -Ithird-party/mimalloc/include -Ithird-party/tbb/include -MT out/elf/arch-arm32.o -MMD -MP -MF out/elf/arch-arm32.d -O2 -c -o out/elf/arch-arm32.o elf/arch-arm32.cc
In file included from elf/arch-arm32.cc:28:
elf/mold.h:2057:12: error: no viable conversion from returned value
      of type 'std::vector<std::vector<mold::elf::ElfRel<mold::elf::ARM32>>>::value_type'
      (aka 'std::vector<mold::elf::ElfRel<mold::elf::ARM32>>') to function return type
      'std::span<ElfRel<ARM32>>'
    return file.sorted_rels[shndx];
           ^~~~~~~~~~~~~~~~~~~~~~~
elf/arch-arm32.cc:145:31: note: in instantiation of member function
      'mold::elf::InputSection<mold::elf::ARM32>::get_rels' requested here
  std::span<ElfRel<E>> rels = get_rels(ctx);
                              ^
/usr/include/c++/v1/span:401:15: note: candidate constructor not
      viable: no known conversion from
      'std::vector<std::vector<mold::elf::ElfRel<mold::elf::ARM32>>>::value_type' (aka
      'std::vector<mold::elf::ElfRel<mold::elf::ARM32>>') to 'const
      std::span<mold::elf::ElfRel<mold::elf::ARM32>, 18446744073709551615> &' for 1st
      argument
    constexpr span           (const span&) noexcept = default;
              ^
/usr/include/c++/v1/span:425:15: note: candidate template ignored:
      could not match 'type_identity_t<std::span<mold::elf::ElfRel<mold::elf::ARM32>,
      18446744073709551615>::element_type>[_Sz]' (aka
      'mold::elf::ElfRel<mold::elf::ARM32>[_Sz]') against
      'std::vector<std::vector<mold::elf::ElfRel<mold::elf::ARM32>>>::value_type' (aka
      'std::vector<mold::elf::ElfRel<mold::elf::ARM32>>')
    constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{...
              ^
/usr/include/c++/v1/span:430:15: note: candidate template ignored:
      could not match 'array' against 'vector'
    constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.d...
              ^
/usr/include/c++/v1/span:435:15: note: candidate template ignored:
      could not match 'array' against 'vector'
    constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{_...
              ^
/usr/include/c++/v1/span:445:19: note: candidate template ignored:
      could not match 'span' against 'vector'
        constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
                  ^
In file included from elf/arch-arm32.cc:28:
elf/mold.h:2099:18: error: no viable conversion from
      'std::vector<u32>' (aka 'vector<unsigned int>') to 'std::span<u32>'
      (aka 'span<unsigned int>')
  std::span<u32> offsets = m->frag_offsets;
                 ^         ~~~~~~~~~~~~~~~
elf/arch-arm32.cc:326:30: note: in instantiation of member function
      'mold::elf::InputSection<mold::elf::ARM32>::get_fragment' requested here
    std::tie(frag, addend) = get_fragment(ctx, rel);
                             ^
/usr/include/c++/v1/span:401:15: note: candidate constructor not
      viable: no known conversion from 'std::vector<u32>' (aka 'vector<unsigned int>') to
      'const std::span<unsigned int, 18446744073709551615> &' for 1st argument
    constexpr span           (const span&) noexcept = default;
              ^
/usr/include/c++/v1/span:425:15: note: candidate template ignored:
      could not match 'type_identity_t<std::span<unsigned int,
      18446744073709551615>::element_type>[_Sz]' (aka 'unsigned int[_Sz]') against
      'std::vector<u32>' (aka 'vector<unsigned int>')
    constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{...
              ^
/usr/include/c++/v1/span:430:15: note: candidate template ignored:
      could not match 'array' against 'vector'
    constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.d...
              ^
/usr/include/c++/v1/span:435:15: note: candidate template ignored:
      could not match 'array' against 'vector'
    constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{_...
              ^
/usr/include/c++/v1/span:445:19: note: candidate template ignored:
      could not match 'span' against 'vector'
        constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
                  ^
2 errors generated.
make: *** [Makefile:141: out/elf/arch-arm32.o] Error 1

@rui314 rui314 reopened this Mar 31, 2022
@rui314
Copy link
Owner

rui314 commented Apr 1, 2022

I installed Clang 14 and libc++14 from apt.llvm.org to a Docker runnning Ubuntu 20.04, then I tried to build mold with make -j CXXFLAGS=-stdlib=libc++ CXX=clang++-14, but I couldn't reproduce that build error.

I also tried to build mold on macOS which I believe uses libc++, and it compiled fine.

Is there anything special in your environment?

@12101111
Copy link
Author

12101111 commented Apr 1, 2022

So this is a bug in libc++ 14.0.0 and fixed in unreleased 14.0.1:
llvm/llvm-project@add3ab7
llvm/llvm-project@3f43d80

I can build mold after patching libc++, even the version 1.1.1 without 8e3cee9

Sorry for the inconvenience.

@12101111 12101111 closed this as completed Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants