[squid-dev] bizarre build behaviour from PoolingAllocator on OpenBSD/clang

Stuart Henderson stu at spacehopper.org
Mon Aug 16 11:29:41 UTC 2021


On 2021-08-15, Alex Rousskov <rousskov at measurement-factory.com> wrote:
> 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?

Hi, OpenBSD port maintainer here (I admit to not knowing much C++ though!).
On OpenBSD, on all archs where the base system compiler is clang,
it's configured to use the clang standard library (libc++) by default,

>> /usr/include/c++/v1/initializer_list:99:1: note: candidate template

and these are the correct headers for libc++. (Post-6.9 gcc is no longer
installed in the base OS on any of the "base is clang" archs, it is
present in ports but used only very rarely).

I just gave it a spin, after adding a missed inclusion of sys/socket.h
for SOL_SOCKET in Tcp.cc I hit the same problem with access.log.cc,
there is a clue on the immediately previous line, which I think is
pointing at something to do with const vs non-const SBuf, is that enough
of a clue?


[...]
Making all in log
Making all in DB
Making all in file
depbase=`echo access_log.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /usr/bin/libtool  --tag=CXX    --mode=compile c++ -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE=\"/etc/squid/squid.conf\"  -DDEFAULT_SQUID_DATA_DIR=\"/usr/local/share/squid\"  -DDEFAULT_SQUID_CONFIG_DIR=\"/etc/squid\"    -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/include  -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/lib -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src  -I../../include -I/usr/local/include    -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include  -Werror -Wextra -Wno-unused-private-field -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Wmissing-declarations  -D_REENTRANT -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include     -I/usr/local/include -I/usr/local/include/p11-kit-1  -O2 -pipe -MT access_log.lo -MD -MP -MF $depbase.Tpo -c -o access_log.lo /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc && mv -f $depbase.Tpo $depbase.Plo
c++ -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE="/etc/squid/squid.conf" -DDEFAULT_SQUID_DATA_DIR="/usr/local/share/squid" -DDEFAULT_SQUID_CONFIG_DIR="/etc/squid" -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/include -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/lib -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src -I../../include -I/usr/local/include -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include -Werror -Wextra -Wno-unused-private-field -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Wmissing-declarations -D_REENTRANT -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include/p11-kit-1 -O2 -pipe -MT access_log.lo -MD -MP -MF .deps/access_log.Tpo -c /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc -fPIC -DPIC -o .libs/access_log.o
In file included from /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc:12:
In file included from /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/AccessLogEntry.h:19:
In file included from /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/HttpHeader.h:13:
In file included from /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/base/LookupTable.h:15:
/usr/include/c++/v1/unordered_map:857:5: error: static_assert failed due to requirement 'is_same<std::__1::pair<const SBuf, unsigned long long>, std::__1::pair<SBuf, unsigned long long>>::value' "Invalid allocator::value_type"
    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
    ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc:65: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;
                         ^
/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc:459: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];
      ~~~~~~~~~~~~~~~~~~^~~~
/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc:466: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:1752: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:1770: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:1778: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())
^                                     ~~~~~
/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc:488: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();
    ~~~~~~~~~~~~~~~~~~ ^
4 errors generated.
Error while executing c++ -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE="/etc/squid/squid.conf" -DDEFAULT_SQUID_DATA_DIR="/usr/local/share/squid" -DDEFAULT_SQUID_CONFIG_DIR="/etc/squid" -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/include -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/lib -I/usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src -I../../include -I/usr/local/include -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include -Werror -Wextra -Wno-unused-private-field -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Wmissing-declarations -D_REENTRANT -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include/p11-kit-1 -O2 -pipe -MT access_log.lo -MD -MP -MF .deps/access_log.Tpo -c /usr/obj/ports/squid-5.1pl20210816/squid-742d042ea820b4ecac2a651a889e0c37f327618e/src/log/access_log.cc -fPIC -DPIC -o .libs/access_log.o
*** Error 1 in src/log (Makefile:923 'access_log.lo')



More information about the squid-dev mailing list