Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 487600 - sys-apps/memtest86-4.3.3-r1: x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
Summary: sys-apps/memtest86-4.3.3-r1: x86_64-pc-linux-gnu-gcc: error: unrecognized opt...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-11 06:30 UTC by Juergen Rose
Modified: 2013-10-19 01:13 UTC (History)
5 users (show)

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


Attachments
memtest86-4.3.3-build-nopie.patch.patch (memtest86-4.3.3-build-nopie.patch.patch,1.22 KB, patch)
2013-10-17 11:51 UTC, Alexander Tsoy
Details | Diff
memtest86-4.3.3-r1.ebuild.patch (memtest86-4.3.3-r1.ebuild.patch,645 bytes, patch)
2013-10-17 11:52 UTC, Alexander Tsoy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Rose 2013-10-11 06:30:45 UTC
'emerge memtest86' fails with:

>>> Emerging (1 of 5) sys-apps/memtest86-4.3.3-r1
 * memtest86-4.3.3-src.tar.gz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                                                         [ ok ]
>>> Unpacking source...
>>> Unpacking memtest86-4.3.3-src.tar.gz to /var/tmp/portage/sys-apps/memtest86-4.3.3-r1/work
>>> Source unpacked in /var/tmp/portage/sys-apps/memtest86-4.3.3-r1/work
>>> Preparing source in /var/tmp/portage/sys-apps/memtest86-4.3.3-r1/work/src ...
 * Applying memtest86-4.3.3-build-nopie.patch ...                                                                                                                          [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-apps/memtest86-4.3.3-r1/work/src ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sys-apps/memtest86-4.3.3-r1/work/src ...
make -j7 
rm -f *.o *.s *.iso memtest.bin memtest memtest_shared \
        memtest_shared.bin memtest.iso
x86_64-pc-linux-gnu-gcc -E -traditional head.S -o head.s
x86_64-pc-linux-gnu-gcc -c -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie  -fno-strict-aliasing reloc.c
x86_64-pc-linux-gnu-gcc -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o main.o main.c
x86_64-pc-linux-gnu-gcc -c -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding  -fno-stack-protector -nopie -o test.o test.c
x86_64-pc-linux-gnu-gcc -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o init.o init.c
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
make: *** [reloc.o] Error 1




root@caiman:/root(4)# emerge --info '=sys-apps/memtest86-4.3.3-r1::gentoo'
Portage 2.2.7 (default/linux/amd64/13.0, gcc-4.7.3, glibc-2.17, 3.10.10-gentoo x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.10.10-gentoo-x86_64-AMD_Phenom-tm-_II_X6_1090T_Processor-with-gentoo-2.2
KiB Mem:    16178648 total,   1522248 free
KiB Swap:  100663280 total, 100636756 free
Timestamp of tree: Fri, 11 Oct 2013 02:00:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.5-r2, 3.2.5-r2, 3.3.2-r2
dev-util/cmake:           2.8.11.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.2
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.10.3, 1.11.6, 1.12.6, 1.13.4, 1.14
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1, 4.8.1-r1
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.11 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo x11 science sunrise x-portage g-cpan g-octave
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA PUEL Intel-SDP dlj-1.1 skype-eula skype-4.0.0.7-copyright googleearth AdobeFlash-11.x cadsoft Oracle-BCLA-JavaSE MakeMKV-EULA NVIDIA-CUDA Nero-AAC-EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=amdfam10 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/php/cli-php5.5/ext-active/ /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=amdfam10 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7"
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"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage_caiman"
PORTDIR_OVERLAY="/var/lib/layman/x11 /var/lib/layman/science /var/lib/layman/sunrise /usr/local/portage /var/lib/cpan /var/lib/g-octave"
USE="3dnow 3dnowext 64bit R X Xaw3d a52 aac acl acpi admin afs alsa amd64 ao apache2 apng applet archive armadillo arpack asf aspell atlas audacious audiofile automap automount bash-completion berkdb blas blast bluetooth bluray boost bzip2 cairo cdda cddb cdf cdio cdparanoia cdr cgi chm cli cmake consolekit cracklib crypt css cups curl cxx daap db dbi dbm dbus declarative designer devhelp device-mapper dga dia dirac djvu doc dot dri ds2490 ds9097 ds9097u dts dv dvb dvd dvdr dvi dynamicplugin eds egl elf emacs emboss emf encode epiphany evo examples exif expat extensions extra extras faac faad ffmpeg fftw firefox fits flac fltk fontconfig foomaticdb fortran fortran95 fpm fpx fuse g3dvl gcj gd gdal gdbm gdu gedit geoip geolocation geos gfortran gif gimp git glade glib glpk gml gmp gnome gnome-keyring gnome-print gnuplot gnutls gold gphoto2 gpm grammar graphics graphtft graphviz grass gsl gsm gstreamer gtk gtk3 gudev guile hddtemp hdf hdf5 hdri html http httpd hvm hwdb iconv icq icu id3 id3tag ide imagemagick imap inotify introspection ipod ipv6 irda ithreads jabber jadetex java java6 jbig john jpeg jpeg2k kate kdepim kdrive kerberos keymap kpathsea kvm ladspa lame lapack latex lcms ldap lensfun libffi libkms libnotify libsamplerate live lm_sensors lua lzma lzo mad mail maildir mapnik math matroska media-library mercurial mikmod mkl mmx mmxext mng mod modules mono motif mozilla mp3 mp4 mpeg mpi mplayer mtp mudflap multilib multimedia musepack musicbrainz mysql mysqli nautilus ncurses netcdf netpbm network networking networkmanager nfs nls nntp nptl nsplugin ntfs ntp numpy obex objc ocaml ocr octave odbc ofa ogdi ogg openexr opengl openmp openvg pam pango pcre pda pdf perl plasma plotutils plugins png podcast policykit portaudio posix postgres postscript ppds preview-latex proj projectm projectx pstricks pulseaudio python python-bindings q16 q32 qemu qhull qt3support qt4 quicktime raw readline real reiserfs reports rhythmbox rle romio rpc rrdcgi rrdtool sage samba sasl schroedinger science sdk sdl secure-delete semantic-desktop server session shout sip slang slp smart smbclient smp sms sndfile snmp soap sockets sound soup sox speex spell sql sqlite sse sse2 ssl stlport subtitles subversion sudo suexec svg svm swig systemd szip t1lib tcl tcpd tex tex4ht texmacs tgif theora thesaurus threads thunderbird tidy tiff tk toolbar tools truetype udev udisks unicode usb userlocales utempter v4l vaapi vala valgrind vdpau video virt-network virtualbox visio vorbis vpx wav webdav webdav-serf webkit wmf wxwidgets x264 xa xattr xcb xemacs xetex xext xft xine xml xmlreader xmlrpc xpm xv xvid xvmc yaml youtube zlib zvbi" ABI_X86="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="actions alias auth_basic auth_digest authn_anon authn_dbd authn_core authn_dbm authn_default authn_file authz_core authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgid dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info lbmethod_byrequests log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif slotmem_shm so socache_shmcb speling status unique_id unixd userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="canon fuji ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CURL_SSL="nss" DRACUT_MODULES="caps lvm mdraid 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 void" KERNEL="linux" LCD_DEVICES="cfontz hd44780 mtxorb ncurses X lcd2usb lcdlinux png usblcd" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de fr ru" NETBEANS_MODULES="apisupport cnd dlight enterprise ergonomics groovy gsf harness ide identity j2ee java mobility nb php profiler ruby websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="arm i386 x86_64" QEMU_USER_TARGETS="arm i386 x86_64" RUBY_TARGETS="ruby19 ruby18" USERLAND="GNU" VIDEO_CARDS="radeon displaylink" 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:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON



root@caiman:/root(5)# emerge -pqv '=sys-apps/memtest86-4.3.3-r1::gentoo'
[ebuild     U ] sys-apps/memtest86-4.3.3-r1 [4.0s] USE="-serial"
Comment 1 Sven 2013-10-11 12:57:35 UTC
I believe, the option is called -fno-pie. The option -nopie may be some deprecated form, that stopped working with gcc 4.7 (I'm using sys-devel/gcc-4.7.3-r1).
Comment 2 Tony Vroon (RETIRED) gentoo-dev 2013-10-11 16:24:29 UTC
My apologies. Let's see if we can fix this without a revision bump, after all, those affected will not be able to merge this.
Comment 3 Alexander Tsoy 2013-10-17 11:03:05 UTC
How about test-flags-CC from flag-o-matic.eclass? See the usage example in lilo ebuilds.
Comment 4 Alexander Tsoy 2013-10-17 11:51:49 UTC
Created attachment 361112 [details, diff]
memtest86-4.3.3-build-nopie.patch.patch

Patch for "files/memtest86-4.3.3-build-nopie.patch"
Comment 5 Alexander Tsoy 2013-10-17 11:52:40 UTC
Created attachment 361114 [details, diff]
memtest86-4.3.3-r1.ebuild.patch

Patch for ebuild. I've performed compile test only.
Comment 6 Anthony Basile gentoo-dev 2013-10-17 13:07:40 UTC
(In reply to Sven from comment #1)
> I believe, the option is called -fno-pie. The option -nopie may be some
> deprecated form, that stopped working with gcc 4.7 (I'm using
> sys-devel/gcc-4.7.3-r1).

I don't get this.  We add -nopie to gentoo's gcc:

yellow ~ # echo "int main() { return 0 ; }" > test.c
yellow ~ # gcc -nopie -o test test.c 
yellow ~ # ./test 
yellow ~ # gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-cloog --without-ppl --disable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-esp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5'
Thread model: posix
gcc version 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)
Comment 7 Roc Vallès 2013-10-17 13:12:24 UTC
With 4.8.1:

$ echo "int main() { return 0 ; }" > test.c
$ gcc -nopie -o test test.c
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.1/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.8.1-r1/work/gcc-4.8.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-cloog --disable-isl-version-check --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/python --enable-checking=release --enable-libstdcxx-time --enable-objc-gc --enable-languages=c,c++,java,objc,obj-c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.1-r1 p1.2, pie-0.5.7'
Thread model: posix
gcc version 4.8.1 (Gentoo 4.8.1-r1 p1.2, pie-0.5.7)

And, with 4.7.3-r1:

$ . /etc/profile
$ gcc -nopie -o test test.c
gcc: error: unrecognized option ‘-nopie’
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-cloog --with-ppl --with-cloog-include=/usr/include/cloog-ppl --disable-ppl-version-check --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.3/python --enable-checking=release --enable-libstdcxx-time --enable-objc-gc --enable-languages=c,c++,java,objc,obj-c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.7.3-r1 p1.3, pie-0.5.5'
Thread model: posix
gcc version 4.7.3 (Gentoo 4.7.3-r1 p1.3, pie-0.5.5)
Comment 8 Roc Vallès 2013-10-17 13:15:36 UTC
(In reply to Anthony Basile from comment #6)
> gcc version 4.7.3 (Gentoo Hardened 4.7.3-r1 p1.3, pie-0.5.5)

I notice your profile is hardened. That's why -nopie works for you. I've just confirmed memtest86 builds just fine on a hardened profile box.
Comment 9 Juergen Rose 2013-10-17 14:06:47 UTC
(In reply to Alexander Tsoy from comment #5)
> Created attachment 361114 [details, diff] [details, diff]
> memtest86-4.3.3-r1.ebuild.patch
> 
> Patch for ebuild. I've performed compile test only.

I tried this patch, but it still fails:
...
x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o init.o init.c
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
make: *** [reloc.o] Error 1

root@leopard:/usr/local/portage/sys-apps/memtest86(35)# emerge -pvD memtest86

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

Calculating dependencies... done!
[ebuild     U  ] sys-apps/memtest86-4.3.3-r1::x-portage [4.0s::gentoo] USE="-serial" 0 kB


root@leopard:/usr/local/portage/sys-apps/memtest86(37)# diff memtest86-4.3.3-r1.ebuild memtest86-4.3.3-r1.ebuild_saved 
7c7
< inherit flag-o-matic mount-boot eutils toolchain-funcs
---
> inherit mount-boot eutils toolchain-funcs
46,50d45
< 
< src_compile() {
<       HARDENED_CFLAGS=$(test-flags-CC -nopie)
<       emake CC="$(tc-getCC) ${HARDENED_CFLAGS}"
< }


I.e.: the patch from Commnet 4 is not included in this modified ebuild. Is this intentionally?
Comment 10 Alexander Tsoy 2013-10-17 14:09:02 UTC
(In reply to Anthony Basile from comment #6)
> (In reply to Sven from comment #1)
> > I believe, the option is called -fno-pie. The option -nopie may be some
> > deprecated form, that stopped working with gcc 4.7 (I'm using
> > sys-devel/gcc-4.7.3-r1).
> 
> I don't get this.  We add -nopie to gentoo's gcc:

But what if gcc is compiled with USE=nopie? From toolchan.eclass:

want_pie() {
    ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
    ...
}

do_gcc_PIE_patches() {
    want_pie || return 0
    ...
}

(In reply to Roc Vallès from comment #8)
> I notice your profile is hardened. That's why -nopie works for you. I've
> just confirmed memtest86 builds just fine on a hardened profile box.

Do you have USE=nopie enabled on non-hardened box?
Comment 11 Alexander Tsoy 2013-10-17 14:12:26 UTC
(In reply to Juergen Rose from comment #9)
> (In reply to Alexander Tsoy from comment #5)
> > Created attachment 361114 [details, diff] [details, diff] [details, diff]
> > memtest86-4.3.3-r1.ebuild.patch
> > 
> > Patch for ebuild. I've performed compile test only.
> 
> I tried this patch, but it still fails:
> ...
> x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> init.o init.c
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> make: *** [reloc.o] Error 1
> 
> root@leopard:/usr/local/portage/sys-apps/memtest86(35)# emerge -pvD memtest86
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> [ebuild     U  ] sys-apps/memtest86-4.3.3-r1::x-portage [4.0s::gentoo]
> USE="-serial" 0 kB
> 
> 
> root@leopard:/usr/local/portage/sys-apps/memtest86(37)# diff
> memtest86-4.3.3-r1.ebuild memtest86-4.3.3-r1.ebuild_saved 
> 7c7
> < inherit flag-o-matic mount-boot eutils toolchain-funcs
> ---
> > inherit mount-boot eutils toolchain-funcs
> 46,50d45
> < 
> < src_compile() {
> <       HARDENED_CFLAGS=$(test-flags-CC -nopie)
> <       emake CC="$(tc-getCC) ${HARDENED_CFLAGS}"
> < }
> 
> 
> I.e.: the patch from Commnet 4 is not included in this modified ebuild. Is
> this intentionally?

I guess you forgot to patch the "files/memtest86-4.3.3-build-nopie.patch" file.
Comment 12 Roc Vallès 2013-10-17 14:25:34 UTC
(In reply to Alexander Tsoy from comment #10)
> Do you have USE=nopie enabled on non-hardened box?

No. It's not part of the default USEs in the standard profile, either.
Comment 13 Alexander Tsoy 2013-10-17 14:38:09 UTC
(In reply to Roc Vallès from comment #12)
> (In reply to Alexander Tsoy from comment #10)
> > Do you have USE=nopie enabled on non-hardened box?
> 
> No. It's not part of the default USEs in the standard profile, either.

Also check for nopie here, please. Just in case, :)

$ cat /var/db/pkg/sys-devel/gcc-4.7.3-r1/USE
abi_x86_64 amd64 cxx elibc_glibc hardened kernel_linux mudflap multilib nls nptl openmp userland_GNU
Comment 14 Roc Vallès 2013-10-17 14:53:17 UTC
(In reply to Alexander Tsoy from comment #13)
> (In reply to Roc Vallès from comment #12)
> > (In reply to Alexander Tsoy from comment #10)
> > > Do you have USE=nopie enabled on non-hardened box?
> > 
> > No. It's not part of the default USEs in the standard profile, either.
> 
> Also check for nopie here, please. Just in case, :)
> 
> $ cat /var/db/pkg/sys-devel/gcc-4.7.3-r1/USE
> abi_x86_64 amd64 cxx elibc_glibc hardened kernel_linux mudflap multilib nls
> nptl openmp userland_GNU

Nope :)

$ cat /var/db/pkg/sys-devel/gcc-4.7.3-r1/USE
abi_x86_64 amd64 cxx elibc_glibc fortran gcj graphite kernel_linux lto mudflap multilib nls nptl objc objc++ objc-gc openmp userland_GNU

$ cat /var/db/pkg/sys-devel/gcc-4.8.1-r1/USE 
abi_x86_64 amd64 cxx elibc_glibc fortran gcj graphite kernel_linux lto mudflap multilib nls nptl objc objc++ objc-gc openmp userland_GNU
Comment 15 Juergen Rose 2013-10-17 15:13:31 UTC
(In reply to Juergen Rose from comment #9)
> (In reply to Alexander Tsoy from comment #5)
> > Created attachment 361114 [details, diff] [details, diff] [details, diff]
> > memtest86-4.3.3-r1.ebuild.patch
> > 
> > Patch for ebuild. I've performed compile test only.
> 
> I tried this patch, but it still fails:
> ...
> x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> init.o init.c
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> make: *** [reloc.o] Error 1
> 
> root@leopard:/usr/local/portage/sys-apps/memtest86(35)# emerge -pvD memtest86
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> [ebuild     U  ] sys-apps/memtest86-4.3.3-r1::x-portage [4.0s::gentoo]
> USE="-serial" 0 kB
> 
> 
> root@leopard:/usr/local/portage/sys-apps/memtest86(37)# diff
> memtest86-4.3.3-r1.ebuild memtest86-4.3.3-r1.ebuild_saved 
> 7c7
> < inherit flag-o-matic mount-boot eutils toolchain-funcs
> ---
> > inherit mount-boot eutils toolchain-funcs
> 46,50d45
> < 
> < src_compile() {
> <       HARDENED_CFLAGS=$(test-flags-CC -nopie)
> <       emake CC="$(tc-getCC) ${HARDENED_CFLAGS}"
> < }
> 
> 
> I.e.: the patch from Commnet 4 is not included in this modified ebuild. Is
> this intentionally?

If I still add the patch from Comment 4, emerge can do a little more:
...
x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o init.o init.c
x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o lib.o lib.c
x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o patn.o patn.c
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
make: *** [reloc.o] Error 1
(In reply to Alexander Tsoy from comment #11)
> (In reply to Juergen Rose from comment #9)
> > (In reply to Alexander Tsoy from comment #5)
> > > Created attachment 361114 [details, diff] [details, diff] [details, diff] [details, diff]
> > > memtest86-4.3.3-r1.ebuild.patch
> > > 
> > > Patch for ebuild. I've performed compile test only.
> > 
> > I tried this patch, but it still fails:
> > ...
> > x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> > -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> > init.o init.c
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > make: *** [reloc.o] Error 1
> > 
> > root@leopard:/usr/local/portage/sys-apps/memtest86(35)# emerge -pvD memtest86
> > 
> > These are the packages that would be merged, in order:
> > 
> > Calculating dependencies... done!
> > [ebuild     U  ] sys-apps/memtest86-4.3.3-r1::x-portage [4.0s::gentoo]
> > USE="-serial" 0 kB
> > 
> > 
> > root@leopard:/usr/local/portage/sys-apps/memtest86(37)# diff
> > memtest86-4.3.3-r1.ebuild memtest86-4.3.3-r1.ebuild_saved 
> > 7c7
> > < inherit flag-o-matic mount-boot eutils toolchain-funcs
> > ---
> > > inherit mount-boot eutils toolchain-funcs
> > 46,50d45
> > < 
> > < src_compile() {
> > <       HARDENED_CFLAGS=$(test-flags-CC -nopie)
> > <       emake CC="$(tc-getCC) ${HARDENED_CFLAGS}"
> > < }
> > 
> > 
> > I.e.: the patch from Commnet 4 is not included in this modified ebuild. Is
> > this intentionally?
> 
> I guess you forgot to patch the "files/memtest86-4.3.3-build-nopie.patch"
> file.

Yes, I added memtest86-4.3.3-build-nopie.patch.patch to the files directory and added a 
epatch "${FILESDIR}"/memtest86-4.3.3-build-nopie.patch.patch
to the ebuild. After patching files/memtest86-4.3.3-build-nopie.patch I was now able to emerge memtest86-4.3.3-r1.(In reply to Alexander Tsoy from comment #11)
> (In reply to Juergen Rose from comment #9)
> > (In reply to Alexander Tsoy from comment #5)
> > > Created attachment 361114 [details, diff] [details, diff] [details, diff] [details, diff]
> > > memtest86-4.3.3-r1.ebuild.patch
> > > 
> > > Patch for ebuild. I've performed compile test only.
> > 
> > I tried this patch, but it still fails:
> > ...
> > x86_64-pc-linux-gnu-gcc  -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> > -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> > init.o init.c
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > make: *** [reloc.o] Error 1
> > 
> > root@leopard:/usr/local/portage/sys-apps/memtest86(35)# emerge -pvD memtest86
> > 
> > These are the packages that would be merged, in order:
> > 
> > Calculating dependencies... done!
> > [ebuild     U  ] sys-apps/memtest86-4.3.3-r1::x-portage [4.0s::gentoo]
> > USE="-serial" 0 kB
> > 
> > 
> > root@leopard:/usr/local/portage/sys-apps/memtest86(37)# diff
> > memtest86-4.3.3-r1.ebuild memtest86-4.3.3-r1.ebuild_saved 
> > 7c7
> > < inherit flag-o-matic mount-boot eutils toolchain-funcs
> > ---
> > > inherit mount-boot eutils toolchain-funcs
> > 46,50d45
> > < 
> > < src_compile() {
> > <       HARDENED_CFLAGS=$(test-flags-CC -nopie)
> > <       emake CC="$(tc-getCC) ${HARDENED_CFLAGS}"
> > < }
> > 
> > 
> > I.e.: the patch from Commnet 4 is not included in this modified ebuild. Is
> > this intentionally?
> 
> I guess you forgot to patch the "files/memtest86-4.3.3-build-nopie.patch"
> file.


Yes, I added memtest86-4.3.3-build-nopie.patch.patch to the files directory and added a 
epatch "${FILESDIR}"/memtest86-4.3.3-build-nopie.patch.patch
to the ebuild. After patching files/memtest86-4.3.3-build-nopie.patch I was now able to emerge memtest86-4.3.3-r1.
Comment 16 Attila Tóth 2013-10-17 17:47:06 UTC
There are currently two patches in the files directory:
1. memtest86-4.3.3-build-nopie.patch - which is good for hardened
2. memtest86-4.3.3-build.patch - which is good for non-hardened

memtest86-4.3.3.ebuild applies the non-hardened patch, while memtest86-4.3.3-r1.ebuild applies the hardened version.

Current code in src_prepare for hardened in memtest86-4.3.3-r1.ebuild:
        epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726

Current code in src_prepare for non-hardened in memtest86-4.3.3.ebuild:
        epatch "${FILESDIR}"/${P}-build.patch #66630


My suggestion:
        if use hardened ; then
                epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726
        else
                epatch "${FILESDIR}"/${P}-build.patch #66630
        fi

It will be fine for everyone thereafter.
Comment 17 Alexander Tsoy 2013-10-17 18:02:30 UTC
(In reply to Attila Tóth from comment #16)
> My suggestion:
>         if use hardened ; then
>                 epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726
>         else
>                 epatch "${FILESDIR}"/${P}-build.patch #66630
>         fi
> 
> It will be fine for everyone thereafter.

Not a good solution as it requires to mantain two patches. IMHO my solution with test-flags-CC is better.
Comment 18 Attila Tóth 2013-10-17 18:51:01 UTC
(In reply to Alexander Tsoy from comment #17)
> (In reply to Attila Tóth from comment #16)
> > My suggestion:
> >         if use hardened ; then
> >                 epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726
> >         else
> >                 epatch "${FILESDIR}"/${P}-build.patch #66630
> >         fi
> > 
> > It will be fine for everyone thereafter.
> 
> Not a good solution as it requires to mantain two patches. IMHO my solution
> with test-flags-CC is better.

I have just took a look at your suggestion and I agree, that it's better than maintaining two patches.
Comment 19 Attila Tóth 2013-10-17 19:10:16 UTC
(In reply to Alexander Tsoy from comment #17)
> Not a good solution as it requires to mantain two patches. IMHO my solution
> with test-flags-CC is better.

The difference between the specific patch and the test-flags-CC approach is that for the latter nopie gets appended to every compilation...
Comment 20 Anthony Basile gentoo-dev 2013-10-18 18:11:36 UTC
(In reply to Attila Tóth from comment #19)
> (In reply to Alexander Tsoy from comment #17)
> > Not a good solution as it requires to mantain two patches. IMHO my solution
> > with test-flags-CC is better.
> 
> The difference between the specific patch and the test-flags-CC approach is
> that for the latter nopie gets appended to every compilation...

Just use -fno-pie instead of -nopie and that should work on both hardened and vanilla compilers.
Comment 21 Anthony Basile gentoo-dev 2013-10-18 19:14:10 UTC
(In reply to Anthony Basile from comment #20)
> (In reply to Attila Tóth from comment #19)
> > (In reply to Alexander Tsoy from comment #17)
> > > Not a good solution as it requires to mantain two patches. IMHO my solution
> > > with test-flags-CC is better.
> > 
> > The difference between the specific patch and the test-flags-CC approach is
> > that for the latter nopie gets appended to every compilation...
> 
> Just use -fno-pie instead of -nopie and that should work on both hardened
> and vanilla compilers.

I just made this change, can people please do a compile and run test for me.
Comment 22 Roc Vallès 2013-10-18 20:47:37 UTC
Compiled ok.

Qemu doesn't want to run it and I don't want to reboot now, so that'll have to wait.
Comment 23 Konstantin Münning 2013-10-18 23:21:26 UTC
(In reply to Anthony Basile from comment #21)
> I just made this change, can people please do a compile and run test for me.

I modified the existing nopie-patch myself a few days ago to use -fno-pie as suggested in comment #1 and was wondering about the long discussion. So with -fno-pie it compiles and works fine on my x86 and amd64-systems.