Bug 6381

Summary: setting DISTRO_FEATURES with '+=' may result in expected build failures
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Chen Qi <Qi.Chen>
Component: coreAssignee: Chen Qi <Qi.Chen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, liezhi.yang, meta.mr.watcher, meta.watcher, raj.khem, richard.purdie
Version: 1.7   
Target Milestone: 1.7 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Chen Qi 2014-05-29 08:37:28 UTC
If we set in local.conf:
DISTRO_FEATURES += "systemd"
we would get the following error.

i586-poky-linux-gcc  -m32 -march=i586 --sysroot=/buildarea/lyang1/testm3/tmp/sysroots/qemux86-tcbootstrap   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs -Wl,-dynamic-linker=/lib/ld-linux.so.2 -B/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/csu/
-Wl,--version-script=/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc.map -Wl,-soname=libc.so.6 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e __libc_main -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/math -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/dlfcn -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nss -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nis -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/rt -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/resolv -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/crypt -L/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nptl -Wl,-rpath-link=/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/math:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/dlfcn:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nss:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nis:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/rt:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/resolv:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/crypt:/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/nptl -o /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc.so -T /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/shlib.lds /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/csu/abi-note.o /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf/soinit.os /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc_pic.os /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf/sofini.os /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf/interp.os /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf/ld.so -lgcc
ln -s ld.so /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/elf/ld-linux.so.2
/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc_pic.os: In function `internal_getgrouplist':
/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/eglibc-2.19/libc/grp/initgroups.c:57: undefined reference to `__nss_not_use_nscd_group'
/buildarea/lyang1/testm3/tmp/sysroots/x86_64-linux/usr/libexec/i586-poky-linux.gcc-cross-initial-i586/gcc/i586-poky-linux/4.8.2/ld: /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc_pic.os: relocation R_386_GOTOFF against undefined hidden symbol `__nss_not_use_nscd_group' can not be used when making a shared object
/buildarea/lyang1/testm3/tmp/sysroots/x86_64-linux/usr/libexec/i586-poky-linux.gcc-cross-initial-i586/gcc/i586-poky-linux/4.8.2/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/build-i586-poky-linux/libc.so] Error 1
make[2]: Leaving directory `/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/eglibc-2.19/libc/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/eglibc-2.19/libc'
make: *** [all] Error 2
ERROR: oe_runmake failed
WARNING: /buildarea/lyang1/testm3/tmp/work/i586-poky-linux/eglibc/2.19-r0/temp/run.do_compile.9330:1 exit 1 from

If we set in local.conf:
DISTRO_FEATURES_append = " systemd"
everything builds fine.

//Chen Qi
Comment 1 Paul Eggleton 2014-05-29 15:06:44 UTC
The reason this happens is that DISTRO_FEATURES is being set with ?= in poky.conf (or defaultsetup.conf if you're not using poky), and local.conf is parsed *before* the distro config - so if you "add" to DISTRO_FEATURES with += in local.conf that means it has a value when bitbake parses the ?= and thus it doesn't set the default value. The result is that DISTRO_FEATURES only contains " systemd". This in turn means that all of the libc features from DISTRO_FEATURES_LIBC are disabled, and eglibc can't build in that configuration.

We've known about this problem for a while. Ideally DISTRO_FEATURES shouldn't be manipulated in local.conf at all (a custom distro config is the most appropriate place), however if you must set it there the suggested workaround has been to use e.g. DISTRO_FEATURES_append = " systemd" instead, since _append happens at the end of parsing whereas += is immediate.

However, given that this situation is easy for users to hit and the error isn't really related to the cause, I think there are a few things we might want to look at:

1) People do want to add to DISTRO_FEATURES from local.conf, and grudgingly we probably have to support that at least for experimentation. We might consider changing the ?= in defaultsetup.conf / local.conf to = so that the problem doesn't occur. However, the side-effect of that is that you'll no longer be able to set DISTRO_FEATURES with = from local.conf, which almost the same use case as the one that we're trying to enable.

2) There's no warning that you've done this by accident and eglibc fails with an incomprehensible error. Even if we do nothing with #1, we should try to warn the user that something has gone wrong, well before eglibc fails to compile.

3) (Possibly the same as #2) eglibc shouldn't be able to be configured in a way that causes its build to fail with an error like this. Clearly one of the libc features that claims to be optional actually isn't.
Comment 2 Chen Qi 2014-05-30 01:45:53 UTC
How about doing a sanity check to see whether all items in DISTRO_FEATURES_LIBC also belong to DISTRO_FEATURES?

I think if an item is in DISTRO_FEATURES_LIBC but not in DISTRO_FEATURES, that usually leads to unexpected results.

If this sanity check passes, we can be sure that at least the eglibc is compiled with features that we need. In this way, we can avoid the error in the above comment.

//Chen Qi
Comment 3 Chen Qi 2014-07-18 05:58:34 UTC
Module: openembedded-core.git
Branch: master
Commit: 82d9d12a3364914a5c1f354671adac1f0a71eea3
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=82d9d12a3364914a5c1f354671adac1f0a71eea3

Author: Chen Qi <Qi.Chen@windriver.com>
Date:   Thu Jul  3 11:23:42 2014 +0800

eglibc: check for required distro features

If users accidently override the DISTRO_FEATURES in local.conf,
then build failures occur for lack of libc functions.

All features in DISTRO_FEATURES_LIBC should be in DISTRO_FEATURES.
That's why this patch let the recipe inherit distro_features_check
class and set REQUIRED_DISTRO_FEATURES to "${DISTRO_FEATURES_LIBC}".

[YOCTO #6381]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Comment 4 Paul Eggleton 2014-07-18 09:39:45 UTC
The question is, will the user actually realise what they've done wrong when they get the error that this enables? I'm not sure that they will.