Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 617200

Summary: <sys-libs/glibc-2.25: when compiling sys-apps/busybox-1.26.2-r1: Compile error: undefined reference to __mempcpy_chk
Product: Gentoo Linux Reporter: Maciej Piechotka <uzytkownik2>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: candrews, chris, fsvm88, fuse809, leonchik1976, mvolaski, StormByte, whissi, xaviermiller, zoltan
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 628180    
Attachments: Build log
Fix static mempcpy_chk.

Description Maciej Piechotka 2017-05-01 15:30:28 UTC
Created attachment 471458 [details]
Build log

In function ‘__poll_alias’,
    inlined from ‘script_main’ at util-linux/script.c:141:8:
/usr/include/bits/poll2.h:41:9: warning: call to ‘__poll_chk_warn’ declared with attribute warning: poll called with fds buffer too small file nfds entries
  return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
         ^
In function ‘__poll_alias’,
    inlined from ‘ifplugd_main’ at networking/ifplugd.c:694:7:
/usr/include/bits/poll2.h:41:9: warning: call to ‘__poll_chk_warn’ declared with attribute warning: poll called with fds buffer too small file nfds entries
  return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
         ^
In function ‘__poll_alias’,
    inlined from ‘microcom_main’ at miscutils/microcom.c:141:27:
/usr/include/bits/poll2.h:41:9: warning: call to ‘__poll_chk_warn’ declared with attribute warning: poll called with fds buffer too small file nfds entries
  return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
         ^
libbb/inet_common.c:166: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/inet_common.c:140: warning: Using 'getnetbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/inet_common.c:39: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/inet_common.c:51: warning: Using 'getnetbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/inet_common.c:66: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/inet_common.c:51: warning: Using 'getnetbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
debianutils/mktemp.c:105: warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
networking/nslookup.c:90: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/netstat.c:385: warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/pscan.c:44: warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/xgethostbyname.c:13: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/xgethostbyname.c:13: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/include/bits/string3.h:67: error: undefined reference to '__mempcpy_chk'
/usr/include/bits/string3.h:67: error: undefined reference to '__mempcpy_chk'
libbb/xgethostbyname.c:13: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/xconnect.c:285: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/xconnect.c:130: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"

Portage 2.3.5 (python 3.4.6-final-0, default/linux/amd64/13.0/desktop/gnome/systemd, gcc-5.4.0, glibc-2.24-r1, 4.9.21-hardened x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.9.21-hardened-x86_64-Intel-R-_Xeon-R-_CPU_E3-1505M_v5_@_2.80GHz-with-gentoo-2.3
KiB Mem:    65875224 total,  47826724 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Sun, 30 Apr 2017 07:00:01 +0000
sh bash 4.4_p12
ld GNU gold (Gentoo 2.27 p1.0 2.27) 1.12
distcc 3.2rc1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:          4.4_p12::gentoo
dev-lang/perl:            5.24.1-r1::gentoo
dev-lang/python:          2.7.13::gentoo, 3.4.6::gentoo
dev-util/cmake:           3.8.0-r1::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.25::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r3::gentoo
sys-devel/automake:       1.11.6-r2::gentoo, 1.12.6-r1::gentoo, 1.13.4-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.27::gentoo
sys-devel/gcc:            5.4.0-r3::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r1::gentoo
sys-kernel/linux-headers: 4.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.24-r1::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

perforce
    location: /usr/local/overlay/perforce-overlay
    sync-type: git
    sync-uri: https://github.com/VladRassokhin/perforce-overlay.git
    masters: gentoo

haskell
    location: /var/lib/layman/haskell
    masters: gentoo
    priority: 50

steam-overlay
    location: /var/lib/layman/steam-overlay
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -ggdb"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/chromium/policies/managed/chrome-gnome-shell.json /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/opt/chrome/policies/managed/chrome-gnome-shell.json /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe -ggdb"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="-j8 --load-average=7"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs cgroup collision-protect compress-build-logs compressdebug config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch preserve-libs protect-owned sandbox sfperms split-elog split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -march=native -O2 -pipe -ggdb"
MAKEOPTS="-j8 -l7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi aes alsa amd64 archive avx avx2 berkdb bluetooth branding bzip2 cairo cdda cdr cli colord cracklib crossdev crypt cryptsetup cups cxx dbus device-mapper downloads-monitor dri dri3 dts dvd dvdr eds egl elfutils emacs emboss encode evo exif f16c fam firefox flac fma3 fortran fprint fuse gdbm gdm gif glamor gles glib gmp gnome gnome-keyring gnome-online-accounts gnuefi gold google googledrive gpg gphoto2 gpm graphite gssapi gstreamer gtk gtk3 hardened hidpi highlight iconv icu introspection ipv6 jemalloc jit jpeg jpeg2k justify kerberos latex lcms ldap libkms libnotify libproxy libsecret lz4 lzma mad mmx mmxext mng modules mp3 mp4 mpeg mtp multilib multitarget nautilus ncurses networkmanager nfs nls nptl ntlm ogg opengl openmp pam pango pax_kernel pcre pdf pie plymouth png policykit popcnt postgres ppds pulseaudio qt3support qt4 readline samba sasl sdl seccomp session smartcard smp spell sqlite sse sse2 sse3 sse4_1 sse4_2 ssh ssl ssp ssse3 startup-notification svg systemd tcpd telepathy theora threads tiff tracker truetype udev udisks unicode upower urandom usb uxa v4l vaapi vala vim-syntax vimeo vorbis vulcan wayland webkit webp wifi wireshark-plugins wxwidgets x264 xattr xcb xml xtpax xv xvid zeitgeist zeroconf zlib" ABI_X86="32 64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="BPF NVPTX X86 AArch64 ARM" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="intel nvidia i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

sys-apps/busybox-1.26.2::gentoo was built with the following:
USE="ipv6 static systemd -debug -livecd -make-symlinks -math -mdev -pam -savedconfig (-selinux) -sep-usr -syslog" ABI_X86="64"
CFLAGS="-march=native -O2 -pipe -ggdb -fno-strict-aliasing"
CXXFLAGS="-march=native -O2 -pipe -ggdb -fno-strict-aliasing"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"

(I build system with LTO and I did try to disable it for busybox without change of result
Comment 1 jy6x2b32pie9 2017-05-06 02:53:01 UTC
Experiencing same problem in the middle of world rebuild due to move from GCC 5.4.0-r1 to 6.3.0
Comment 2 fuse809 2017-05-07 19:53:06 UTC
I experience this bug too when compiling busybox with GCC 6.3.0.
Comment 3 fhede 2017-05-07 21:36:33 UTC
I have this bug too when compiling busybox with gcc 7.1.0
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2017-05-08 21:43:07 UTC
*** Bug 617828 has been marked as a duplicate of this bug. ***
Comment 5 Thomas Deutschmann (RETIRED) gentoo-dev 2017-05-08 21:44:46 UTC
(In reply to Peter Levine from bug 617828 comment #1)
> Maybe related to
> https://sourceware.org/git/?p=glibc.git;a=commit;
> h=fbe355fbd1973d6e29561084b3eaeb4bfe9d515a
Comment 6 Matthias Maier gentoo-dev 2017-05-08 22:32:11 UTC
It indeed is.

The patch in question has been added to the gentoo patchset for sys-libs/glibc-2.25 which we should keyword at some point.
Comment 7 Xavier Miller (RETIRED) gentoo-dev 2017-06-12 15:56:45 UTC
same problem with new profile, gcc-6.3.0 and glibc-2.24-r1
Comment 8 Zoltan Puskas 2017-07-03 01:29:25 UTC
This actually blocks new installations. After uncompressing stage 3 one has to run emerge -uND world and it breaks on this error.
Comment 9 David Carlos Manuelda 2017-07-17 19:51:29 UTC
Temporarily disabling static use flag makes it compile, but I don't know if that has bad consequences. If not, I would suggest hard masking static use flag for busybox for now.
Comment 10 Fabio Scaccabarozzi 2017-07-21 22:02:10 UTC
(In reply to David Carlos Manuelda from comment #9)
> Temporarily disabling static use flag makes it compile, but I don't know if
> that has bad consequences. If not, I would suggest hard masking static use
> flag for busybox for now.

As far as I understand, busybox is the default rescue shell when booting.
Parts of it are copied in the initramfs at kernel/initramfs compile time.
The end result is that you would end up with a non-working rescue shell at the next initramfs rebuild, because libc.so is not copied into the init image and busybox is not statically linked.

As for the bug: running GCC 6.3.0 and glibc 2.24-r3 here. I see that the patch 00_all_0032-x86_64-fix-static-build-of-__memcpy_chk-for-compiler.patch is now applied, but it's not working, busybox still fails at compile time.
Comment 11 Fabio Scaccabarozzi 2017-08-06 09:25:04 UTC
(In reply to Fabio Scaccabarozzi from comment #10)
> (In reply to David Carlos Manuelda from comment #9)
> > Temporarily disabling static use flag makes it compile, but I don't know if
> > that has bad consequences. If not, I would suggest hard masking static use
> > flag for busybox for now.
> 
> As far as I understand, busybox is the default rescue shell when booting.
> Parts of it are copied in the initramfs at kernel/initramfs compile time.
> The end result is that you would end up with a non-working rescue shell at
> the next initramfs rebuild, because libc.so is not copied into the init
> image and busybox is not statically linked.
> 
> As for the bug: running GCC 6.3.0 and glibc 2.24-r3 here. I see that the
> patch 00_all_0032-x86_64-fix-static-build-of-__memcpy_chk-for-compiler.patch
> is now applied, but it's not working, busybox still fails at compile time.

Just realized that the patch applied is for memcpy_chk, not memPcpy_chk.

I have attached a patch based on the upstream one that fixes the issue (likely identical to the one applied to 2.25). I can finally compile busybox with GCC 6.4.0 and glibc-2.24-r3. Just drop it in /etc/portage/patches/sys-libs/glibc/.

Can we please backport it for glibc-2.24? Or is glibc-2.25 going to be unmasked soon?
Comment 12 Fabio Scaccabarozzi 2017-08-06 09:25:47 UTC
Created attachment 488114 [details, diff]
Fix static mempcpy_chk.
Comment 13 Andreas K. Hüttel archtester gentoo-dev 2017-09-11 10:04:29 UTC
glibc-2.25 will be stabilized soon.
Comment 14 Andreas K. Hüttel archtester gentoo-dev 2017-10-19 19:26:27 UTC
Fixed in 2.25