Search code examples
attributesglibcyoctoconfiguregcov

configure: error: missing __attribute__ ((constructor)) support?


I am trying to build glibc library using bitbake environment inside Yocto Project. I am able to build it successfully but when i alter the C compiler flag in local.conf file it is giving missing attribute error.

build/conf/local.conf file.

here i add one line :

TARGET_CFLAGS += "-fprofile-arcs -ftest-coverage"

then it is throwing errors : missing attribute((constructor)) support?

I have added this line to local.conf file.

TARGET_CFLAGS += "-fprofile-arcs -ftest-coverage"

Please find the link for config.log file : https://drive.google.com/open?id=14tiQJ8JIFE_tDWt3H9tS8zBBQROcZDNa

Sstate summary: Wanted 7 Found 1 Missed 6 Current 51 (14% match, 89% complete)
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: glibc-2.28-r0 do_configure: configure failed
ERROR: glibc-2.28-r0 do_configure: Function failed: do_configure (log file is located at /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/temp/log.do_configure.19973)
ERROR: Logfile of failure stored in: /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/temp/log.do_configure.19973
Log data follows:
| DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
| DEBUG: Executing shell function autotools_preconfigure
| Previously configured separate build directory detected, cleaning /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/build-i586-poky-linux
| DEBUG: Shell function autotools_preconfigure finished
| DEBUG: Executing python function autotools_aclocals
| DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
| DEBUG: Python function autotools_aclocals finished
| DEBUG: Executing shell function do_configure
| NOTE: Running ../git/configure  --build=x86_64-linux        --host=i586-poky-linux          --target=i586-poky-linux        --prefix=/usr           --exec_prefix=/usr          --bindir=/usr/bin           --sbindir=/usr/sbin         --libexecdir=/usr/libexec           --datadir=/usr/share        --sysconfdir=/etc           --sharedstatedir=/com           --localstatedir=/var        --libdir=/usr/lib           --includedir=/usr/include           --oldincludedir=/usr/include        --infodir=/usr/share/info           --mandir=/usr/share/man         --disable-silent-rules          --disable-dependency-tracking           --with-libtool-sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot --enable-kernel=3.2.0                 --disable-profile                 --disable-debug --without-gd                 --enable-clocale=gnu                 --with-headers=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot/usr/include                 --without-selinux                 --enable-tunables                 --enable-bind-now                 --enable-stack-protector=strong                 --enable-stackguard-randomization                 --disable-crypt                 --with-default-link                                    --enable-nscd --disable-static
| checking build system type... x86_64-pc-linux-gnu
| checking host system type... i586-poky-linux-gnu
| checking for i586-poky-linux-gcc... i586-poky-linux-gcc  -m32 -march=i586  --sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot
| checking for suffix of object files... o
| checking whether we are using the GNU C compiler... yes
| checking whether i586-poky-linux-gcc  -m32 -march=i586  --sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot accepts -g... yes
| checking for gcc... gcc
| checking for i586-poky-linux-readelf... i586-poky-linux-readelf
| checking whether we are using the GNU C++ compiler... yes
| checking whether i586-poky-linux-g++  -m32 -march=i586  --sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot accepts -g... yes
| checking whether i586-poky-linux-g++  -m32 -march=i586  --sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot can link programs... no
| checking for sysdeps preconfigure fragments... aarch64 alpha arm hppa i386 m68k microblaze mips nios2 powerpc riscv s390 sh sparc x86_64
| checking for use of fpu sysdeps directories... yes
| checking for -fstack-protector... (cached) no
| checking for -fstack-protector-strong... (cached) no
| checking for -fstack-protector-all... (cached) no
| checking for assembler and linker STT_GNU_IFUNC support... yes
| checking for gcc attribute ifunc support... yes
| checking if compiler warns about alias for function with incompatible types... yes
| checking sysdep dirs... sysdeps/unix/sysv/linux/i386 sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl sysdeps/i386/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/i386 sysdeps/unix sysdeps/posix sysdeps/i386/i586 sysdeps/i386/fpu sysdeps/x86/fpu sysdeps/i386 sysdeps/x86 sysdeps/wordsize-32 sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/ieee754 sysdeps/generic
| checking for a BSD-compatible install... /scratch/work/day8/poky/build/tmp/hosttools/install -c
| checking whether ln -s works... yes
| checking whether /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/as is GNU as... yes
| checking whether /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/ld is GNU ld... yes
| checking for /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/as... /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/as
| checking version of /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/as... 2.31.1.20181224, ok
| checking for /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/ld... /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/ld
| checking version of /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot-native/usr/bin/i586-poky-linux/../../libexec/i586-poky-linux/gcc/i586-poky-linux/8.2.0/ld... 2.31.1.20181224, ok
| checking for gnumake... make
| checking version of make... 4.2.1, ok
| checking for gnumsgfmt... no
| checking for gmsgfmt... no
| checking for msgfmt... no
| checking for makeinfo... makeinfo
| checking version of makeinfo... 6.1, ok
| checking for sed... sed
| checking version of sed... 4.2.2, ok
| checking for gawk... gawk
| checking version of gawk... 4.1.3, ok
| checking for bison... bison
| checking version of bison... 3.0.4, ok
| checking if i586-poky-linux-gcc  -m32 -march=i586  --sysroot=/scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/recipe-sysroot is sufficient to build libc... yes
| checking for i586-poky-linux-nm... i586-poky-linux-nm
| checking for python3... python3
| configure: WARNING:
| *** These auxiliary programs are missing or incompatible versions: msgfmt
| *** some features or tests will be disabled.
| *** Check the INSTALL file for required versions.
| checking LD_LIBRARY_PATH variable... ok
| checking for bash... (cached) /bin/bash
| checking for perl... /scratch/work/day8/poky/build/tmp/hosttools/perl
| checking for install-info... /usr/bin/install-info
| checking for .set assembler directive... no
| checking linker support for protected data symbol... yes
| checking linker support for INSERT in linker script... no
| checking for broken __attribute__((alias()))... no
| checking whether to put _rtld_local into .sdata section... no
| checking whether to use .ctors/.dtors header and trailer... configure: error: missing __attribute__ ((constructor)) support??
| NOTE: The following config.log files may provide further information.
| NOTE: /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/build-i586-poky-linux/config.log
| ERROR: configure failed
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_configure (log file is located at /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/temp/log.do_configure.19973)
ERROR: Task (/scratch/work/day8/poky/meta/recipes-core/glibc/glibc_2.28.bb:do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 388 tasks of which 387 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /scratch/work/day8/poky/meta/recipes-core/glibc/glibc_2.28.bb:do_configure
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

Solution

  • Since you enabled code coverage support by adding these CFLAGS -fprofile-arcs -ftest-coverage - these CFLAGS must have been propagated to compilation of conftest binary that is built by autoconf. This binary is built to test if one specific feature (as it says "whether to use .ctors/.dtors header and trailer") is supported or not (actually, there are several similar builds occur in configuration process to test for specific features). I cannot prove that, because detailed error prints should be in specific log file that you haven't shared:

    | NOTE: The following config.log files may provide further information.
    | NOTE: /scratch/work/day8/poky/build/tmp/work/i586-poky-linux/glibc/2.28-r0/build-i586-poky-linux/config.log
    

    But, I bet, it should contain something like:

    conftest.c:(.text+0xae): undefined reference to `__gcov_init'
    ...
    collect2: ld returned 1 exit status
    

    This is because the code is instrumented with some function calls and linker can't find its implementations (even in these conftest binaries where they are absolutely have no sense).

    It is possible to skip this particular configuration test by specifying corresponding configuration option - libc_cv_ctors_header (in this case, name is taken from glib's configure.ac) - adding EXTRA_OECONF to local.conf (e.g. EXTRA_OECONF = "libc_cv_ctors_header=yes"), but those flags, actually affect all such tests, and we shouldn't want to guess yes/no values and so on.

    Thus, it'd be better to make linker be aware of coverage support - i.e. provide the same flags for TARGET_LDFLAGS:

    TARGET_LDFLAGS += "-fprofile-arcs -ftest-coverage"