[squid-dev] bizarre build behaviour from PoolingAllocator on OpenBSD/clang
Alex Rousskov
rousskov at measurement-factory.com
Sun Aug 15 21:57:23 UTC 2021
On 8/15/21 2:51 PM, Francesco Chemolli wrote:
> Hi all,
> I'm looking into OpenBSD compatibility for trunk, and there's a
> strange behaviour at build time on OpenBSD (6.9) / clang (10.0.1)
>
> When building src/log/access.log.cc, build fails with these errors:
>
> ------------------ begin quote -----------
> static_assert((is_same<value_type, typename
> allocator_type::value_type>::value),
> ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Are some compiler messages missing in the above quote? It feels like the
above line is not directly related to the lines below, but perhaps I am
misinterpreting the messy output.
> I'm puzzled: I wouldn't expect this to be an OS-specific failure.
We cannot be sure it is OS-specific, but STL implementation is full of
hacks and optimizations that may be OS- or environment-specific. It is
also possible that there is a conflict between GCC and clang
installation; we have seen those before and they manifest in weird ways.
It is strange that the error below mentions "unordered_map" when it
should say "std::unordered_map" or similar.
Are you building with clang standard library or GCC standard library (I
believe -stdlib controls that, but it is not my area of expertise)? If
you are building with GCC stdlib, perhaps try building with
clang-provided stdlib?
I wish I could be more helpful,
Alex.
> access_log.cc:66:26: note: in instantiation of template class
> 'std::__1::unordered_map<SBuf, unsigned long long,
> std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'
> requested here
> static HeaderValueCounts TheViaCounts;
> ^
> access_log.cc:460:25: error: type 'HeaderValueCounts' (aka
> 'unordered_map<SBuf, unsigned long long, hash<SBuf>, equal_to<SBuf>,
> PoolingAllocator<pair<SBuf, unsigned long long> > >') does not provide
> a subscript operator
> ++TheForwardedCounts[key];
> ~~~~~~~~~~~~~~~~~~^~~~
> access_log.cc:467:24: error: invalid range expression of type 'const
> std::__1::unordered_map<SBuf, unsigned long long,
> std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'; no
> viable 'begin' function available
> for (const auto &i : counts)
> ^ ~~~~~~
> /usr/include/c++/v1/initializer_list:99:1: note: candidate template
> ignored: could not match 'initializer_list' against 'unordered_map'
> begin(initializer_list<_Ep> __il) _NOEXCEPT
> ^
> /usr/include/c++/v1/iterator:1753:1: note: candidate template ignored:
> could not match '_Tp [_Np]' against 'const
> std::__1::unordered_map<SBuf, unsigned long long,
> std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'
> begin(_Tp (&__array)[_Np])
> ^
> /usr/include/c++/v1/iterator:1771:1: note: candidate template ignored:
> substitution failure [with _Cp = const std::__1::unordered_map<SBuf,
> unsigned long long, std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >]: no
> member named 'begin' in 'std::__1::unordered_map<SBuf, unsigned long
> long, std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'
> begin(_Cp& __c) -> decltype(__c.begin())
> ^ ~~~~~
> /usr/include/c++/v1/iterator:1779:1: note: candidate template ignored:
> substitution failure [with _Cp = std::__1::unordered_map<SBuf,
> unsigned long long, std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >]: no
> member named 'begin' in 'std::__1::unordered_map<SBuf, unsigned long
> long, std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'
> begin(const _Cp& __c) -> decltype(__c.begin())
> ^ ~~~~~
> access_log.cc:489:24: error: no member named 'clear' in
> 'std::__1::unordered_map<SBuf, unsigned long long,
> std::__1::hash<SBuf>, std::__1::equal_to<SBuf>,
> PoolingAllocator<std::__1::pair<SBuf, unsigned long long> > >'
> TheForwardedCounts.clear();
> ~~~~~~~~~~~~~~~~~~ ^
> ------------------ end quote -----------
>
> But then, removing the reference to PoolingAllocator in the definition
> of HeaderValueCounts, everything works.
> """
> using HeaderValueCounts = std::unordered_map<SBuf, uint64_t,
> std::hash<SBuf>, std::equal_to<SBuf> >;
> """
More information about the squid-dev
mailing list