Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 480508 - app-emulation/wine-1.7.0 CFLAGS=-O3 - .../work/wine-1.7.0/loader/preloader.c:463: undefined reference to `memset'
Summary: app-emulation/wine-1.7.0 CFLAGS=-O3 - .../work/wine-1.7.0/loader/preloader.c:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Wine Maintainers
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-08-10 15:28 UTC by Konstantin (elxa)
Modified: 2013-09-01 17:13 UTC (History)
1 user (show)

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


Attachments
Fixes compilation when using -O3 in CFLAGS (gcc-O3-optimization-cflags.patch,1.93 KB, patch)
2013-08-10 15:33 UTC, Konstantin (elxa)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin (elxa) 2013-08-10 15:28:58 UTC
## The error:

x86_64-pc-linux-gnu-gcc -m32 -o wine-preloader -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000 preloader.o ../libs/port/libwine_port.a -Wl,-O1 -Wl,--as-needed
preloader.o: In function `wld_memset':
/var/tmp/portage/app-emulation/wine-1.7.0/work/wine-1.7.0/loader/preloader.c:463: undefined reference to `memset'
/var/tmp/portage/app-emulation/wine-1.7.0/work/wine-1.7.0/loader/preloader.c:463: undefined reference to `memset'
collect2: error: ld returned 1 exit status
make[1]: *** [wine-preloader] Error 1
make[1]: Leaving directory `/var/tmp/portage/app-emulation/wine-1.7.0/work/wine-1.7.0-x86/loader'
make: *** [loader] Error 2
make: *** Waiting for unfinished jobs....

(full build log attached)

## The cause:

GCC option -ftree-loop-distribute-patterns, which is enabled by -O3 according to the man page.


## The solution:

Compile loader/preloader.c with GCC option -fno-tree-loop-distribute-patterns when using -O3.

--------------------------------------
## The patch:

Adding -fno-tree-loop-distribute-patterns  was suggested at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888#c3 .

Patches for wine were extracted from the patch posted at http://bugs.winehq.org/show_bug.cgi?id=33521#c12 .

I extracted the relevant parts from this patch into the one attached below. I am not sure if the other stuff is relevant for gentoo.

## My tests:

Emerging wine with -O2 without the patch: works
Emerging wine with -O3 without the patch: does not work
Emerging wine with -O3 with the patch: works
Comment 1 Konstantin (elxa) 2013-08-10 15:30:01 UTC
emerge --info app-emulation/wine
Portage 2.2.0_alpha196 (default/linux/amd64/13.0/desktop/gnome, gcc-4.8.1, glibc-2.17, 3.10.5 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.10.5-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q6600_@_2.40GHz-with-gentoo-2.2
KiB Mem:     8167652 total,   1994656 free
KiB Swap:          0 total,         0 free
Timestamp of tree: Sat, 10 Aug 2013 10:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.1
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.5-r1, 3.2.5-r1, 3.3.2-r1
dev-util/cmake:           2.8.11.1
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
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.1
sys-devel/gcc:            4.7.3, 4.8.1
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r5::gnome
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo x11 gnome local
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -ggdb -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /usr/share/polkit-1/actions /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/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O3 -ggdb -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs --keep-going"
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 splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://ftp.wh2.tu-dresden.de/pub/mirrors/gentoo http://gentoo.mneisen.org/ http://mirror.netcologne.de/gentoo/ ftp://mirror.netcologne.de/gentoo/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/ ftp://ftp.halifax.rwth-aachen.de/gentoo/ http://ftp.halifax.rwth-aachen.de/gentoo/ ftp://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/ http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/ ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo http://ftp.uni-erlangen.de/pub/mirrors/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5 -l5"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="xz"
PORTAGE_COMPRESS_FLAGS="-9"
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/run/media/dice/Daten"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/x11 /var/lib/layman/gnome /usr/local/portage"
SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"
USE="X a52 aac acl acoustid acpi alsa amd64 audit avahi berkdb branding bzip2 cairo cdda cdr cleartype cli colord corefonts cracklib crypt cryptsetup cue cups cxx dbus dri dts dvd dvdr eds emboss encode evo exif fam ffmpeg firefox flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk gtk3 gtkstyle iconv icu infinality introspection ipv6 jpeg lame lcms ldap libnotify libsamplerate libsecret mad mmx mng modules mp3 mp4 mpeg mudflap multilib musicbrainz nautilus ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt3support qt4 readline sdl session sndfile socialweb spell sse sse2 ssl startup-notification svg systemd tcpd threads tiff truetype type3 udev udisks unicode upower usb vorbis wavpack wxwidgets x264 xcb xml xv xvid zeroconf zlib" 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="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" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="biosdevname crypt systemd" 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="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de en" NETBEANS_MODULES="cnd enterprise ergonomics groovy mobility php webcommon" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-4" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby20" USERLAND="GNU" VIDEO_CARDS="radeon" 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, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

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

app-emulation/wine-1.7.0 was built with the following:
USE="X alsa cups custom-cflags fontconfig gecko gstreamer jpeg lcms ldap mono mp3 ncurses nls opengl osmesa perl png prelink pulseaudio run-exes ssl threads truetype udisks xcomposite xml -capi -dos -gphoto2 -gsm -odbc -openal -opencl -oss -samba -scanner (-selinux) -test -v4l -xinerama" ABI_X86="32 64 -x32" LINGUAS="de en -ar -bg -ca -cs -da -el -en_US -eo -es -fa -fi -fr -he -hi -hr -hu -it -ja -ko -lt -ml -nb_NO -nl -or -pa -pl -pt_BR -pt_PT -rm -ro -ru -sk -sl -sr_RS@cyrillic -sr_RS@latin -sv -te -th -tr -uk -wa -zh_CN -zh_TW"
Comment 2 Konstantin (elxa) 2013-08-10 15:33:47 UTC
Created attachment 355624 [details, diff]
Fixes compilation when using -O3 in CFLAGS

Problem: -O3 enables -ftree-loop-distribute-patterns and the compilation fails.
Patch: Add -fno-tree-loop-distribute-patterns to wine's CFLAGS and the compilation succeeds.
Comment 3 Alexandre Rostovtsev (RETIRED) gentoo-dev 2013-08-12 04:36:17 UTC
Cannot reproduce with gcc-4.7.3.

Does this error only happen if using gcc-4.8.x?
Comment 4 Alexandre Rostovtsev (RETIRED) gentoo-dev 2013-08-13 03:24:26 UTC
I see, this happens only with USE=custom-cflags.
Comment 5 Alexandre Rostovtsev (RETIRED) gentoo-dev 2013-09-01 15:32:11 UTC
Fixed in >=wine-1.6

Thank you for finding a patch!

+  01 Sep 2013; Alexandre Rostovtsev <tetromino@gentoo.org> wine-1.6.ebuild,
+  wine-1.7.0.ebuild, wine-9999.ebuild, +files/wine-1.6-memset-O3.patch:
+  Fix USE=custom-cflags build with -O3 and recent gcc versions (bug #480508,
+  thanks to Konstantin).
Comment 6 Konstantin (elxa) 2013-09-01 17:13:42 UTC
You are welcome :)