Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 302137 - python fails to compile with the OS X 10.4 (Tiger) toolchain with -mcpu/-mtune
Summary: python fails to compile with the OS X 10.4 (Tiger) toolchain with -mcpu/-mtune
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Prefix
URL: http://nxg.me.uk/note/2004/restFP/
Whiteboard:
Keywords:
: 318071 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-25 04:25 UTC by kfm
Modified: 2010-08-05 06:27 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kfm 2010-01-25 04:25:26 UTC
My recent attempt at preparing a prefix on Mac OS X 10.4.11 failed at the very last step - that is, python as provided by "emerge -e system":

That was with these settings:

CHOST="powerpc-apple-darwin8"
CFLAGS="-mcpu=G4 -mtune=G4 -O2 -pipe"

Firstly, this is a consequence of defining -mpcu and -mtune prior to the final phase of installation but these options are not themselves to blame. The underlying nature of this issue is described here:

http://nxg.me.uk/note/2004/restFP/

I understand that the "powerpc-apple-darwin7" platform is similarly affected, although I am not able to test Panther.

As it turns out, the issue has come up before in the macports.org project:

http://trac.macports.org/ticket/13322

In principle, the solution is to pass "-lgcc_dynamic" to the linker but I suspect that, in practice, applying the fix to python would not be straightforward. For instance, it has to be at the end of the link line and, upon my attempt to add it to LDFLAGS via /etc/portage/env/dev-lang/python, I found that it simply resulted in "C compiler cannot create executables".

So far, I've found that these two workarounds work for me:

1) Changing -O2 to -O3 in CFLAGS (*)
2) Stripping -mcpu/-mtune (not a particularly favourable compromise, I'd say)

(*) I noticed that someone had reported on the macports.org thread that -O3 is a viable workaround. I put it to the test and, remarkably, it did indeed allow me to compile python without error.
Comment 1 kfm 2010-01-25 04:31:16 UTC
Just to say also that the version of gcc outside the prefix is:

$ gcc_select 
Current default compiler:
gcc version 4.0.1 (Apple Computer, Inc. build 5370)

That's as provided by Xcode 2.5 and all available updates.
Comment 2 Fabian Groffen gentoo-dev 2010-01-25 07:58:52 UTC
This is remarkable.

I recently hit the same thing, and noticed that -O3 did the trick.  I didn't want to "fix" the ebuild, because someone with a G4 reported that -O2 worked fine.

I hence don't know how to reliably "catch" the persons that will find this problem.
Comment 3 kfm 2010-01-25 10:16:44 UTC
It's clearly an issue. I suppose you might consider filtering -mtune and -mcpu until a better solution can be found. In any case, I will look into the issue further as time permits but the fact that the machine I'm using is so slow makes the investigative process frustrating, to say the least!
Comment 4 Fabian Groffen gentoo-dev 2010-01-25 10:20:12 UTC
I'd rather bump the optimisation from -O2 to -O3 than drop -mtune and -mcpu.

Since it only happens for us, I'd be ok to apply this patch:

[[ ${CHOST} == powerpc*-apple-darwin8 ]] && has-flags "-mtune=*" && replace-flags -O2 -O3

or something similar
Comment 5 kfm 2010-01-25 11:54:56 UTC
Your proposal certainly gets the thumbs up from me, although I think darwin7 needs to be covered also. I'll notify you in the event that I figure out a less intrusive fix.
Comment 6 Fabian Groffen gentoo-dev 2010-01-27 20:16:21 UTC
I applied the "workaround".
Comment 7 Robert Steinhäußer 2010-02-23 00:48:23 UTC
On my PowerBook G4 (Mac OS X 10.5.8, Darwin 9.8.0) I need one more tweak until python 2.6.4 will build without the restFP/saveFP error. The variable OPT (in the Makefile) still contains "-O2 -mtune=G4". After manually changing it to -O3, the rest of the build runs fine.
Comment 8 Fabian Groffen gentoo-dev 2010-02-23 07:34:30 UTC
hmmm, weird why it does compile for me then, what exactly are your CFLAGS?
Comment 9 Robert Steinhäußer 2010-02-23 18:21:25 UTC
My setting is: CFLAGS="-O2 -pipe -mcpu=G4 -mtune=G4". But it seems to me that the "replace-flags" command in python-2.6.4.ebuild does not apply to the OPT variable. While editing var/tmp/portage/dev-lang/python-2.6.4/work/Python-2.6.4/Makefile I saw CFLAGS="-O3..." and at the same time OPT="-O2...".

$ emerge --info
Portage 2.2.00.15431-prefix (prefix/darwin/macos/10.5/ppc, gcc-4.2.1, unavailable, 9.8.0 Power Macintosh)
=================================================================
System uname: Darwin-9.8.0-Power_Macintosh-powerpc-32bit
Timestamp of tree: Mon, 22 Feb 2010 18:35:53 +0000
distcc 2.18.5-Apple.1 powerpc-apple-darwin9.0 (protocols 1 and 2) (default port 3632) [disabled]
app-shells/bash:     4.0_p37
dev-lang/python:     2.6.4
sys-devel/autoconf:  2.63-r01.1
sys-devel/automake:  1.10.2-r00.1, 1.11.1
sys-devel/gcc-config: 1.4.1-r00.2
sys-devel/libtool:   2.2.6b
ACCEPT_KEYWORDS="~ppc-macos"
ACCEPT_LICENSE="* -@EULA"
ACCEPT_PROPERTIES="*"
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 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"
ARCH="ppc-macos"
AUTOCLEAN="yes"
Apple_PubSub_Socket_Render="/tmp/launch-zeiiNM/Render"
CBUILD="powerpc-apple-darwin9"
CFLAGS="-O2 -pipe -mcpu=G4 -mtune=G4"
CHOST="powerpc-apple-darwin9"
CLEAN_DELAY="5"
COLLISION_IGNORE="/lib/modules"
COMMAND_MODE="legacy"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CVS_RSH="ssh"
CXXFLAGS="-O2 -pipe -mcpu=G4 -mtune=G4"
DEFAULT_PATH="/Users/robert/Gentoo/usr/sbin:/Users/robert/Gentoo/usr/bin:/Users/robert/Gentoo/sbin:/Users/robert/Gentoo/bin"
DISPLAY="/tmp/launch-6JPqfD/:0"
DISTDIR="/Users/robert/Gentoo/usr/portage/distfiles"
ELIBC="Darwin"
EMERGE_DEFAULT_OPTS="--verbose --with-bdeps=y"
EMERGE_WARNING_DELAY="3"
EPREFIX="/Users/robert/Gentoo"
EROOT="/Users/robert/Gentoo/"
EXTRA_PATH="/usr/bin:/bin"
FEATURES="assume-digests collision-protect distlocks fixpackages news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unmerge-logs unmerge-orphans userfetch"
FETCHCOMMAND="/Users/robert/Gentoo/usr/bin/wget -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
GCC_SPECS=""
GENTOO_MIRRORS="http://locutus.wlan http://distfiles.gentoo.org"
HOME="/Users/robert"
INFOPATH="/Users/robert/Gentoo/usr/share/info:/Users/robert/Gentoo/usr/share/gcc-data/powerpc-apple-darwin9/4.2.1/info"
INPUT_DEVICES="keyboard mouse"
KERNEL="Darwin"
LANG="de_DE.UTF-8"
LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
LC_COLLATE="de_DE.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LDFLAGS=""
LESS="-R -M --shift 5"
LESSOPEN="|lesspipe.sh %s"
LINGUAS="de en"
LOGNAME="robert"
MACOSX_DEPLOYMENT_TARGET="10.5"
MAKEOPTS="-j2"
MANPATH="/usr/share/man:/usr/local/share/man:/usr/X11/man"
NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
NOCOLOR="true"
OLDPWD="/Users/robert/Gentoo/var/tmp/portage/dev-lang/python-2.6.4/work/Python-2.6.4"
PAGER="/Users/robert/Gentoo/usr/bin/less"
PATH="/Users/robert/Gentoo/usr/bin:/Users/robert/Gentoo/bin:/Users/robert/Gentoo/usr/local/bin:/Users/robert/Gentoo/usr/sbin:/Users/robert/Gentoo/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
PKGDIR="/Users/robert/Gentoo/usr/portage/packages"
PKG_CONFIG_PATH="/Users/robert/Gentoo/usr/lib/pkgconfig:/Users/robert/Gentoo/usr/share/pkgconfig"
PORTAGE_ARCHLIST="ppc x86-openbsd ppc-openbsd ppc64 x86-winnt x86-fbsd ppc-aix alpha arm x86-freebsd s390 amd64 arm-linux x86-macos x64-openbsd ia64-hpux hppa x86-netbsd amd64-linux ia64-linux x86 sparc-solaris x64-freebsd sparc64-solaris x86-linux x64-macos sparc m68k-mint ia64 mips ppc-macos x86-interix hppa-hpux amd64-fbsd x64-solaris mips-irix m68k sh x86-solaris sparc-fbsd"
PORTAGE_BINHOST_CHUNKSIZE="3000"
PORTAGE_BIN_PATH="/Users/robert/Gentoo/usr/lib/portage/bin"
PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
PORTAGE_CONFIGROOT="/Users/robert/Gentoo/"
PORTAGE_DEBUG="0"
PORTAGE_DEPCACHEDIR="/Users/robert/Gentoo/var/cache/edb/dep"
PORTAGE_ELOG_CLASSES="log warn error"
PORTAGE_ELOG_MAILFROM="robert@localhost"
PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}"
PORTAGE_ELOG_MAILURI="robert"
PORTAGE_ELOG_SYSTEM="save_summary echo"
PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5"
PORTAGE_FETCH_RESUME_MIN_SIZE="350K"
PORTAGE_GID="20"
PORTAGE_GROUP="staff"
PORTAGE_INST_GID="20"
PORTAGE_INST_UID="502"
PORTAGE_PYM_PATH="/Users/robert/Gentoo/usr/lib/portage/pym"
PORTAGE_ROOT_USER="robert"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_RSYNC_RETRIES="3"
PORTAGE_TMPDIR="/Users/robert/Gentoo/var/tmp"
PORTAGE_USER="robert"
PORTAGE_VERBOSE="1"
PORTAGE_WORKDIR_MODE="0700"
PORTDIR="/Users/robert/Gentoo/usr/portage"
PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
PWD="/Users/robert"
PYTHONDONTWRITEBYTECODE="1"
RESUMECOMMAND="/Users/robert/Gentoo/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
ROOT="/"
ROOTPATH="/Users/robert/Gentoo/opt/bin:/Users/robert/Gentoo/usr/powerpc-apple-darwin9/gcc-bin/4.2.1"
RPMDIR="/Users/robert/Gentoo/usr/portage/rpm"
RUBY_TARGETS="ruby18"
SECURITYSESSIONID="d3b860"
SHELL="/bin/bash"
SHLVL="1"
SSH_AUTH_SOCK="/tmp/launch-iS1QZ9/Listeners"
SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix"
TERM="linux"
TERM_PROGRAM="iTerm.app"
TMPDIR="/var/folders/U+/U+s-Rrk8HS0i-7EM6jJmYU+++TM/-Tmp-/"
USE="aqua coreaudio cracklib cxx modules ncurses nls objc objc++ ppc-macos prefix readline ssl unicode zlib" 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 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" ELIBC="Darwin" INPUT_DEVICES="keyboard mouse" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de en" RUBY_TARGETS="ruby18" USERLAND="GNU" 
USER="robert"
USERLAND="GNU"
USE_EXPAND="APACHE2_MODULES APACHE2_MPMS CAMERAS CROSSCOMPILE_OPTS DVB_CARDS ELIBC FCDSL_CARDS FOO2ZJS_DEVICES FRITZCAPI_CARDS INPUT_DEVICES KERNEL LCD_DEVICES LINGUAS LIRC_DEVICES MISDN_CARDS NETBEANS_MODULES QEMU_SOFTMMU_TARGETS QEMU_USER_TARGETS RUBY_TARGETS SANE_BACKENDS USERLAND VIDEO_CARDS"
USE_EXPAND_HIDDEN="CROSSCOMPILE_OPTS ELIBC KERNEL USERLAND"
USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d"
_="/Users/robert/Gentoo/usr/bin/emerge"
__CF_USER_TEXT_ENCODING="0x1F6:0:3"
Comment 10 Fabian Groffen gentoo-dev 2010-04-25 09:15:57 UTC
In the current ebuild OPT is set to "", and EXTRA_CFLAGS=${CFLAGS}, does this still hold?
Comment 11 Robert Steinhäußer 2010-04-26 19:37:53 UTC
Yesterday I updated python:2.6 without any errors:

> Installed versions:  2.6.5-r1(2.6)(13:27:06 25.04.2010)(aqua ncurses readline ssl threads wide-unicode xml -berkdb -build -doc -elibc_uclibc -examples -gdbm -ipv6 -sqlite -tk -wininst)
Comment 12 Fabian Groffen gentoo-dev 2010-04-26 20:12:56 UTC
thx
Comment 13 Fabian Groffen gentoo-dev 2010-05-02 16:30:48 UTC
*** Bug 318071 has been marked as a duplicate of this bug. ***
Comment 14 Johan Hattne 2010-08-04 22:01:15 UTC
I just hit this on my iBook G3 with 10.4 (darwin8).  My CFLAGS were set "-mcpu=750 -Os -pipe", and I found that I needed to "replace-flags -Os -O3" in order to get past this hurdle.  Any chance of seeing that applied to the ebuild as well?

I'd like to reopen this bug, but I can't (I'm neither the reporter nor a dev).
Comment 15 Fabian Groffen gentoo-dev 2010-08-05 06:27:07 UTC
added, thanks