Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 413801 - sys-boot/grub-2.00_beta3-r2 link failure with hardened toolchain and use=static?
Summary: sys-boot/grub-2.00_beta3-r2 link failure with hardened toolchain and use=static?
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal with 1 vote (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-27 22:17 UTC by Robin Johnson
Modified: 2019-06-28 15:05 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
grub-2.00_beta3-r2:20120427-215128.log.gz (grub-2.00_beta3-r2:20120427-215128.log.gz,18.95 KB, application/octet-stream)
2012-04-27 22:17 UTC, Robin Johnson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2012-04-27 22:17:49 UTC
Created attachment 310305 [details]
grub-2.00_beta3-r2:20120427-215128.log.gz

/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libc.a(memcpy.o): In function `memcpy':
(.text+0x10): multiple make[2]: definition of*** [grub-mklayout] Error 1 `
memcpy'
libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0x1dd): first defined here
collect2: ld returned 1 exit status
make[2]: *** [grub-mkrelpath] Error 1
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libc.a(memcpy.o): In function `memcpy':
(.text+0x10): multiple definition of `memcpy'
libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0x1dd): first defined here
collect2: ld returned 1 exit status
make[2]: *** [grub-fstest] Error 1
make[2]: Leaving directory `/var/tmp/portage/sys-boot/grub-2.00_beta3-r2/work/build-pc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/sys-boot/grub-2.00_beta3-r2/work/build-pc'
make: *** [all] Error 2
 * ERROR: sys-boot/grub-2.00_beta3-r2 failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of 'emerge --info =sys-boot/grub-2.00_beta3-r2',
 * the complete build log and the output of 'emerge -pqv =sys-boot/grub-2.00_beta3-r2'.
 * The complete build log is located at '/var/log/portage/build/sys-boot/grub-2.00_beta3-r2:20120427-215128.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-boot/grub-2.00_beta3-r2/temp/environment'.
 * S: '/var/tmp/portage/sys-boot/grub-2.00_beta3-r2/work/grub-2.00~beta3'

# emerge -pv grub

These are the packages that would be merged, in order:

[ebuild  N    *] sys-boot/grub-2.00_beta3-r2  USE="static -custom-cflags -debug -device-mapper -efiemu -libzfs -mount -nls -sdl -truetype" GRUB_PLATFORMS="efi-64 pc -coreboot -efi-32 -emu -ieee1275 -multiboot -qemu -qemu-mips -yeeloong" 0 kB

Portage 2.1.10.44 (hardened/linux/amd64, gcc-4.5.3, glibc-2.12.2, 2.6.37-gentoo-r4 x86_64)
=================================================================
System uname: Linux-2.6.37-gentoo-r4-x86_64-Intel-R-_Xeon-R-_CPU_X3440_@_2.53GHz-with-gentoo-2.0.3
Timestamp of tree: Thu, 26 Apr 2012 05:00:01 +0000
app-shells/bash:          4.1_p9
dev-lang/python:          2.7.1-r1, 3.1.3-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.4
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.20.1-r1
sys-devel/gcc:            4.4.5, 4.5.3-r2
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.2.10
sys-devel/make:           3.82
sys-kernel/linux-headers: 2.6.36.1 (virtual/os-headers)
sys-libs/glibc:           2.12.2
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dev.d /etc/env.d /etc/gconf /etc/gentoo-release /etc/init.d /etc/revdep-rebuild /etc/sandbox.d /etc/scsi_id.config /etc/terminfo /etc/udev"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs buildpkg collision-protect distlocks ebuild-locks fixlafiles multilib-strict parallel-fetch protect-owned sandbox sfperms split-elog split-log splitdebug strict unknown-features-warn unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 bash-completion berkdb bzip2 cli cracklib crypt cxx dri gdbm gpm hardened iconv ipv6 jpeg justify libwww maildir mmx modules mudflap multilib ncurses nptl nptlonly openmp pam pax_kernel pcre perl png pppd python readline session snmp sse sse2 ssl sysfs tcpd unicode urandom vim-syntax xml xorg zlib" 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" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="account chaos checksum condition delude dhcpmac echo fuzzy geoip gradm iface ipmark ipp2p ipset ipv4options length2 logmark lscan pknock psd quota2 rawnat steal sysrq tarpit tee"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2012-04-27 22:29:19 UTC
looks to be due to USE=static
Comment 2 Mike Gilbert gentoo-dev 2012-04-28 03:19:09 UTC
I am not able to reproduce this, though I did find some unrelated missing dependencies with USE=static.

My system has a newer toolchain than yours.

Portage 2.2.0_alpha101 (default/linux/amd64/10.0/desktop/kde, gcc-4.6.2, glibc-2.14.1-r3, 3.3.3 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.3.3-x86_64-AMD_Phenom-tm-_II_X6_1055T_Processor-with-gentoo-2.0.3
Timestamp of tree: Unknown
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.5.4-r4, 2.6.8, 2.7.3-r1, 3.1.5, 3.2.3
dev-util/cmake:           2.8.7-r5
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.10.3, 1.11.1
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.4.7, 4.5.3-r2, 4.6.2
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo mgorny floppym local
Installed sets: 
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /opt/google/chrome/google-chrome /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.0/conf /usr/share/openvpn/easy-rsa /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-gtk/gtk-3.0 /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /usr/share/themes"
CXXFLAGS="-O2 -pipe -march=native"
DISTDIR="/var/portage/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask=n --with-bdeps=y --quiet-build=n --jobs=7"
FEATURES="assume-digests binpkg-logs buildpkg clean-logs distlocks ebuild-locks fakeroot fixlafiles news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms sign strict unknown-features-warn unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_US"
MAKEOPTS="-j7"
PKGDIR="/var/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--ipv4"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/tmp"
PORTDIR="/home/floppym/gentoo-x86"
PORTDIR_OVERLAY="/home/floppym/overlays/mgorny /home/floppym/overlays/floppym /home/floppym/overlays/local"
SYNC="cvs://floppym@cvs.gentoo.org:/var/cvsroot"
USE="3dnow 3dnowext X a52 aac acl acpi alsa amd64 bash-completion berkdb bluetooth branding bzip2 cairo caps cdda cdr cli consolekit cracklib crypt css cups cxx dbus declarative dri dts dvd dvdr emboss encode exif fam ffmpeg firefox flac fontconfig fortran gdbm gdu gif gles gpm gtk iconv imap ipv6 jpeg kde kipi lcms libnotify lzma mad mmx mmxext mng modules mono mp3 mp4 mpeg mudflap multilib ncurses nls nptl nptlonly nsplugin offensive ogg opengl openmp pam pango pcre pdf perl phonon plasma png policykit ppds pppd python qt3support qt4 readline samba sdl semantic-desktop session spell sse sse2 sse3 ssl startup-notification suid svg sysfs taglib tcpd theora threads tiff truetype udev unicode usb vaapi vdpau vim-syntax vorbis wxwidgets x264 xattr xcb xcomposite xinerama xml xorg xscreensaver xulrunner xv xvid zlib zsh-completion" 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" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="btrfs" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" PHP_TARGETS="php5-3" PYTHON_TARGETS="python2_5 python2_6 python2_7 pypy1_8" QEMU_SOFTMMU_TARGETS="arm i386 x86_64" QEMU_USER_TARGETS="arm i386 x86_64" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nouveau nvidia" 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"
USE_PYTHON="2.5 2.6 2.7 2.7-pypy-1.8 3.1 3.2"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS

=================================================================
                        Package Settings
=================================================================
USE="(consolekit) (multilib) nls (policykit) sdl static truetype -custom-cflags -debug -device-mapper -efiemu -libzfs -mount" GRUB_PLATFORMS="pc -coreboot -efi-32 -efi-64 -emu -ieee1275 -multiboot -qemu -qemu-mips -yeeloong"

sys-boot/grub-2.00_beta3-r2 was built with the following:
CFLAGS=""
LDFLAGS="-static"
Comment 3 Mick Reed aka ykill and petlab 2012-05-11 21:46:29 UTC
The difference in your toolchains is "hardened."  USE="static" breaks it for me, without static, it succeeds.

I read that grub has its own custom memcpy and that conflicts with the glibc one.  That's all I know, I'm not a programmer.

I was emerging a new system, and stumbling thru USE flags to get things built (cryptsetup,grub,genkernel,lvm2,...)  At some point portage was telling me to build grub with USE=static.  Or, I am mistaken, probably.

HTH

Portage 2.1.10.49 (hardened/linux/amd64/selinux, gcc-4.6.3, glibc-2.14.1-r3, 3.3.0-gentoo-r1 x86_64)
=================================================================
System uname: Linux-3.3.0-gentoo-r1-x86_64-AMD_Phenom-tm-_II_X6_1100T_Processor-with-gentoo-2.0.3
Timestamp of tree: Thu, 10 May 2012 16:30:01 +0000
app-shells/bash:          4.2_p20
dev-lang/python:          2.7.2-r3, 3.2.2
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.9
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2, 4.6.3
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -floop-interchange -floop-strip-mine -floop-block"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native -floop-interchange -floop-strip-mine -floop-block"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --load-average=10 --with-bdeps=y"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox selinux sesandbox sfperms unknown-features-warn unmerge-logs unmerge-orphans userfetch xattr"
FFLAGS=""
GENTOO_MIRRORS="http://ftp.ntua.gr/pub/linux/gentoo/ http://gentoo.mirrors.easynews.com/linux/gentoo/ ftp://ftp.ntua.gr/pub/linux/gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_US"
MAKEOPTS="-j7 -l7 -s --no-print-directory"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 berkdb bzip2 cli cracklib crypt cups cxx dri gdbm gpm graphite hardened iconv justify mmx modules mudflap multilib ncurses nls nptl open_perms openmp pam pax_kernel pcre pppd readline selinux session sse sse2 ssl tcpd unicode urandom xattr xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp 
[snip]
Comment 4 Magnus Granberg gentoo-dev 2013-01-13 03:05:49 UTC
It looks like it miss to add -fno-stack-protector and -fno-PIE to the CFLAGS
for the libgrubkern part. The needed cflags is added to TARGET_CFLAGS in the configure checks.
Comment 5 Mike Gilbert gentoo-dev 2017-02-04 20:07:38 UTC
Do you still encounter this problem with newer versions of grub?
Comment 6 Magnus Granberg gentoo-dev 2018-10-12 00:56:47 UTC
Still problem with newer grub and gcc?