Building OpenWrt with glibc

I'm running into some problems building OpenWRT instead of musl. I have some special requirements that I am using glibc for. However, when I compile I get the error:

error: config_package_libpthread is enabled but the external toolchain does not support it

I have looked around and libpthread and I do not see any good way to remove the dependency nor do I see a way to enable thread support in the external toolchain.

Is there a way around this?

I don't see the problem with that question? It could of course be more verbose, but the error message is enough info along with using a glibc toolchain.

bjorn@canardo:/usr/local/src/lede$ git grep "but the external toolchain does not support it"
toolchain/wrapper/Makefile:             echo "ERROR: $(1) is enabled but the external toolchain does not support it"; \

toolchain/wrapper/Makefile simply calls $(SCRIPT_DIR)/ , pointing to the configured toolchain for these 4 features:

define Host/Prepare
        $(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
        $(call toolchain_test,CONFIG_IPV6,ipv6)
        $(call toolchain_test,CONFIG_NLS,wchar)
        $(call toolchain_test,CONFIG_PACKAGE_libpthread,threads)

So the "threads" feature test is failing with the configured glibc toolchain. The reason for this requires more research. AFAICS, the script will simply assume all features are supported for anything which isn't uclibc:

        # assume eglibc/glibc supports all libc features
        if [ "$LIBC_TYPE" != "uclibc" ]; then
                return 0

Maybe run the manually and see where it fails? It provides some very useful debugging hints

bjorn@canardo:/usr/local/src/lede$ scripts/

Usage: --toolchain {directory} --print-libc
    Print the libc implementation and exit. --toolchain {directory} --print-target
    Print the GNU target name and exit. --toolchain {directory} --print-bin {program}
    Print executables belonging to given program,
    omit program argument to get a list of names. --toolchain {directory} --print-libs {library}
    Print shared objects belonging to given library,
    omit library argument to get a list of names. --toolchain {directory} --test {feature}
    Test given feature, exit code indicates success.
    Possible features are 'c', 'c++', 'softfloat',
    'lfs', 'rpc', 'ipv6', 'wchar', 'locale' and 
    'threads'. --toolchain {directory} --wrap {directory}
    Create wrapper scripts for C and C++ compiler, 
    linker, assembler and other key executables in 
    the directory given with --wrap. --toolchain {directory} --config {target}
    Analyze the given toolchain and print a suitable
    .config for the given target. Omit target 
    argument to get a list of names. --help
    Display this help text and exit.

  Most commands also take a --cflags parameter which 
  is used to specify C flags to be passed to the 
  cross compiler when performing tests.
  This paremter may be repeated multiple times.

For example, trying out my native Debian toolchain:

bjorn@canardo:/usr/local/src/lede$ scripts/ --toolchain /usr --print-libc
bjorn@canardo:/usr/local/src/lede$ scripts/ --toolchain /usr --print-target
bjorn@canardo:/usr/local/src/lede$ scripts/ --toolchain /usr --test threads && echo OK || echo NOT OK
bjorn@canardo:/usr/local/src/lede$ scripts/ --toolchain /usr --test c++ && echo OK || echo NOT OK
1 Like

Master or some branch for instance would be helpful
Are other chages done than just switching to glibc?

I've tried both master and the 18.06 branch with the same results.


Thank you for your detailed response. That is helpful! I ran and funny enough, I got the same exact results you did:

user@user-KVM:~/openwrt$ scripts/ --toolchain /usr --print-libc
user@user-KVM:~/openwrt$ scripts/ --toolchain /usr --print-target
user@user-KVM:~/openwrt$ scripts/ --toolchain /usr --test threads && echo OK || echo NOT OK
user@user-KVM:~/openwrt$ scripts/ --toolchain /usr --test c++ && echo OK || echo NOT OK

/usr points to the host toolchain, but the target toolchain is in openwrt/toolchain right? So am I looking for the issue as libraries on the host or do I need to change things in the .config on the target?

My build system is Ubuntu 18
uname -a
Linux user-KVM 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

These are the configuration changes made to the default OpenWRT config:

Target System: x86
Subtarget: x86_64

[] Advanced configuration options (for developers) (NEW)
|- [
] Use external toolchain (NEW)
|- Toolchain libc (glibc)

Global build settings
|- [] Enable IPv6 support in packages

Are there any other troubleshooting steps I can take?