Opened 2 weeks ago

Last modified 2 weeks ago

#13177 new Bug report

filezilla + libfilezilla fail to build on systems with Clangs libcc 19.1.x: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'

Reported by: ernsteiswuerfel Owned by:
Priority: normal Component: FileZilla Client
Keywords: libcxx build failure Cc:
Component version: 3.67.1 Operating system type: Linux
Operating system version: Gentoo Linux 2.16

Description

Both libfilezilla and filezilla fail to build on my Gentoo Linux musl/llvm system since libcc 19.1.x is used (libcc 18.1.x was fine).

filezilla 3.67.1 build error:

libtool: compile:  clang++ -std=c++17 -DHAVE_CONFIG_H -I../../config -DBUILDING_FILEZILLA -DNDEBUG -fvisibility=hidden -Os -march=bdver2 -pipe -Wall -Werror=partial-availability -c activity_logger_layer.cpp  -fPIC -DPIC -o .libs/libfzclient_private_la-activity_logger_layer.o
/bin/sh ../../libtool  --tag=CXX   --mode=compile clang++ -std=c++17 -DHAVE_CONFIG_H   -I../../config  -DBUILDING_FILEZILLA -DNDEBUG -fvisibility=hidden -Os -march=bdver2 -pipe -Wall -Werror=partial-availability -c -o libfzclient_private_la-commands.lo `test -f 'commands.cpp' || echo './'`commands.cpp
libtool: compile:  clang++ -std=c++17 -DHAVE_CONFIG_H -I../../config -DBUILDING_FILEZILLA -DNDEBUG -fvisibility=hidden -Os -march=bdver2 -pipe -Wall -Werror=partial-availability -c commands.cpp  -fPIC -DPIC -o .libs/libfzclient_private_la-commands.o
In file included from commands.cpp:1:
In file included from ./filezilla.h:1:
In file included from ./../include/libfilezilla_engine.h:12:
In file included from /usr/include/libfilezilla/libfilezilla.hpp:7:
In file included from /usr/include/libfilezilla/string.hpp:9:
In file included from /usr/include/c++/v1/string:647:
/usr/include/c++/v1/string_view:300:42: error: implicit instantiation of undefined
      template 'std::char_traits<unsigned char>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/usr/include/libfilezilla/hash.hpp:112:44: note: in instantiation of template
      class 'std::basic_string_view<unsigned char>' requested here
  112 |           std::enable_if_t<sizeof(typename PasswordContainer::value_type) == sizeof(uint8_t) &&
      |                                            ^
/usr/include/libfilezilla/hash.hpp:114:22: note: while substituting prior template
      arguments into non-type template parameter [with PasswordContainer =
      std::basic_string_view<uint8_t>, SaltContainer = std::basic_string_view<uint8_t>]
  114 |   ...pbkdf2_hmac_sha256(PasswordContainer const& password, SaltContainer const& salt, size_t length, unsigned int iterations)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/libfilezilla/hash.hpp:116:9: note: while substituting deduced
      template arguments into function template 'pbkdf2_hmac_sha256' [with PasswordContainer =
      std::basic_string_view<uint8_t>, SaltContainer = std::basic_string_view<uint8_t>, $2 =
      (no value)]
  116 |         return pbkdf2_hmac_sha256(std::basic_string_view<uint8_t>(reinterpret_cast<uint8_t cons...
      |                ^
/usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
      |        ^
1 error generated.
make[3]: *** [Makefile:996: libfzclient_private_la-commands.lo] Error 1
make[3]: Leaving directory '/var/tmp/portage/net-ftp/filezilla-3.67.1/work/filezilla-3.67.1/src/engine'
make[2]: *** [Makefile:690: all] Error 2
make[2]: Leaving directory '/var/tmp/portage/net-ftp/filezilla-3.67.1/work/filezilla-3.67.1/src/engine'
make[1]: *** [Makefile:439: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/net-ftp/filezilla-3.67.1/work/filezilla-3.67.1/src'
make: *** [Makefile:635: all-recursive] Error 1

libfilezilla 0.48.1 build error:

make[1]: Entering directory '/var/tmp/portage/dev-libs/libfilezilla-0.48.1/work/libfilezilla-0.48.1/lib'
/bin/sh ../libtool  --tag=CXX   --mode=compile clang++ -std=c++17 -DHAVE_CONFIG_H    -I../config -DBUILDING_LIBFILEZILLA    -I. -I./libfilezilla   -fvisibility=hidden -Os -march=bdver2 -pipe -Wall -g -Werror=partial-availability -c -o aio/libfilezilla_la-aio.lo `test -f 'aio/aio.cpp' || echo './'`aio/aio.cpp
libtool: compile:  clang++ -std=c++17 -DHAVE_CONFIG_H -I../config -DBUILDING_LIBFILEZILLA -I. -I./libfilezilla -fvisibility=hidden -Os -march=bdver2 -pipe -Wall -g -Werror=partial-availability -c aio/aio.cpp  -fPIC -DPIC -o aio/.libs/libfilezilla_la-aio.o
In file included from aio/aio.cpp:1:
In file included from aio/../libfilezilla/aio/aio.hpp:8:
In file included from aio/../libfilezilla/aio/../event.hpp:4:
In file included from aio/../libfilezilla/aio/../libfilezilla.hpp:7:
In file included from aio/../libfilezilla/aio/../string.hpp:9:
In file included from /usr/include/c++/v1/string:647:
/usr/include/c++/v1/string_view:300:42: error: implicit instantiation of undefined
      template 'std::char_traits<unsigned char>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
aio/../libfilezilla/util.hpp:72:44: note: in instantiation of template class
      'std::basic_string_view<unsigned char>' requested here
   72 |           std::enable_if_t<sizeof(typename First::value_type) == sizeof(uint8_t) &&
      |                                            ^
aio/../libfilezilla/util.hpp:74:13: note: while substituting prior template
      arguments into non-type template parameter [with First = std::basic_string_view<uint8_t>, Second
      = std::basic_string_view<uint8_t>]
   74 | inline bool equal_consttime(First const& lhs, Second const& rhs)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aio/../libfilezilla/util.hpp:76:9: note: while substituting deduced template
      arguments into function template 'equal_consttime' [with First = std::basic_string_view<uint8_t>,
      Second = std::basic_string_view<uint8_t>, $2 = (no value)]
   76 |         return equal_consttime(std::basic_string_view<uint8_t>(reinterpret_cast<uint8_t const*>...
      |                ^
/usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
      |        ^
1 error generated.
make[1]: *** [Makefile:900: aio/libfilezilla_la-aio.lo] Error 1
make[1]: Leaving directory '/var/tmp/portage/dev-libs/libfilezilla-0.48.1/work/libfilezilla-0.48.1/lib'
make: *** [Makefile:495: all-recursive] Error 1

This is Gentoo downstream bug report https://bugs.gentoo.org/941779 and https://bugs.gentoo.org/941775.

Attachments (2)

filezilla-3.67.1:20241103-224757.log (20.9 KB ) - added by ernsteiswuerfel 2 weeks ago.
filezilla build.log (3.67.1)
libfilezilla-0.48.1:20241103-223642.log (15.6 KB ) - added by ernsteiswuerfel 2 weeks ago.
libfilezilla build.log (0.48.1)

Download all attachments as: .zip

Change History (4)

by ernsteiswuerfel, 2 weeks ago

filezilla build.log (3.67.1)

by ernsteiswuerfel, 2 weeks ago

libfilezilla build.log (0.48.1)

comment:1 by Tim Kosse, 2 weeks ago

Status: newmoreinfo

Please try adding this to lib/libfilezilla/string.hpp after the include directives:

template<class CharT, class BaseT>
class traits_cloner
{
public:
    using char_type = CharT;

    using base_type = BaseT;
    using base_traits = std::char_traits<base_type>;

    static std::size_t length(char_type const* s) {
        return base_traits::length(reinterpret_cast<base_type const*>(s));
    }
    static int compare(char_type const* s1, char_type const* s2, std::size_t count) {
        return base_traits::compare(reinterpret_cast<base_type const*>(s1), reinterpret_cast<base_type const*>(s2), count);
    }
    static char_type* copy(char_type* dest, char_type const* src, std::size_t count) {
        return reinterpret_cast<char_type*>(base_traits::copy(reinterpret_cast<base_type*>(dest), reinterpret_cast<base_type const*>(src), count));
    }
    static void assign(char_type& c1, char_type const& c2) noexcept {
        c1 = c2;
    }
    static char_type const* find(char_type const* ptr, std::size_t count, char_type const& ch) {
        return reinterpret_cast<char_type const*>(base_traits::find(reinterpret_cast<base_type const*>(ptr), count, reinterpret_cast<base_type const&>(ch)));
    }
};

template<>
class std::char_traits<uint8_t> : public traits_cloner<uint8_t, char>
{};

in reply to:  1 comment:2 by ernsteiswuerfel, 2 weeks ago

Status: moreinfonew

Replying to Tim Kosse:

Please try adding this to lib/libfilezilla/string.hpp after the include directives:

template<class CharT, class BaseT>
class traits_cloner
{
public:
    using char_type = CharT;

    using base_type = BaseT;
    using base_traits = std::char_traits<base_type>;

    static std::size_t length(char_type const* s) {
        return base_traits::length(reinterpret_cast<base_type const*>(s));
    }
    static int compare(char_type const* s1, char_type const* s2, std::size_t count) {
        return base_traits::compare(reinterpret_cast<base_type const*>(s1), reinterpret_cast<base_type const*>(s2), count);
    }
    static char_type* copy(char_type* dest, char_type const* src, std::size_t count) {
        return reinterpret_cast<char_type*>(base_traits::copy(reinterpret_cast<base_type*>(dest), reinterpret_cast<base_type const*>(src), count));
    }
    static void assign(char_type& c1, char_type const& c2) noexcept {
        c1 = c2;
    }
    static char_type const* find(char_type const* ptr, std::size_t count, char_type const& ch) {
        return reinterpret_cast<char_type const*>(base_traits::find(reinterpret_cast<base_type const*>(ptr), count, reinterpret_cast<base_type const&>(ch)));
    }
};

template<>
class std::char_traits<uint8_t> : public traits_cloner<uint8_t, char>
{};

Thanks!

After patching lib/libfilezilla/string.hpp from libfilezilla like this libfilezilla-0.48.1 and also filezilla-3.67.1 build fine again.

Note: See TracTickets for help on using tickets.