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?

http://www.catb.org/esr/faqs/smart-questions.html#beprecise

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)/ext-toolchain.sh , 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)
endef

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
        fi

Maybe run the ext-toolchain.sh manually and see where it fails? It provides some very useful debugging hints

bjorn@canardo:/usr/local/src/lede$ scripts/ext-toolchain.sh

Usage:

  ext-toolchain.sh --toolchain {directory} --print-libc
    Print the libc implementation and exit.

  ext-toolchain.sh --toolchain {directory} --print-target
    Print the GNU target name and exit.

  ext-toolchain.sh --toolchain {directory} --print-bin {program}
    Print executables belonging to given program,
    omit program argument to get a list of names.

  ext-toolchain.sh --toolchain {directory} --print-libs {library}
    Print shared objects belonging to given library,
    omit library argument to get a list of names.

  ext-toolchain.sh --toolchain {directory} --test {feature}
    Test given feature, exit code indicates success.
    Possible features are 'c', 'c++', 'softfloat',
    'lfs', 'rpc', 'ipv6', 'wchar', 'locale' and 
    'threads'.

  ext-toolchain.sh --toolchain {directory} --wrap {directory}
    Create wrapper scripts for C and C++ compiler, 
    linker, assembler and other key executables in 
    the directory given with --wrap.

  ext-toolchain.sh --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.

  ext-toolchain.sh --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/ext-toolchain.sh --toolchain /usr --print-libc
glibc
bjorn@canardo:/usr/local/src/lede$ scripts/ext-toolchain.sh --toolchain /usr --print-target
x86_64-linux-gnu
bjorn@canardo:/usr/local/src/lede$ scripts/ext-toolchain.sh --toolchain /usr --test threads && echo OK || echo NOT OK
OK
bjorn@canardo:/usr/local/src/lede$ scripts/ext-toolchain.sh --toolchain /usr --test c++ && echo OK || echo NOT OK
NOT OK
1 Like

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

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

Bjorn,

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

user@user-KVM:~/openwrt$ scripts/ext-toolchain.sh --toolchain /usr --print-libc
glibc
user@user-KVM:~/openwrt$ scripts/ext-toolchain.sh --toolchain /usr --print-target
x86_64-linux-gnu
user@user-KVM:~/openwrt$ scripts/ext-toolchain.sh --toolchain /usr --test threads && echo OK || echo NOT OK
OK
user@user-KVM:~/openwrt$ scripts/ext-toolchain.sh --toolchain /usr --test c++ && echo OK || echo NOT OK
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?