Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 642590 - =dev-lang/python-2.7.14: hostlibdirs in LDFLAGS cause bootstrap to fail
Summary: =dev-lang/python-2.7.14: hostlibdirs in LDFLAGS cause bootstrap to fail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All OS X
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-29 01:24 UTC by Michael Weiser
Modified: 2017-12-29 13:25 UTC (History)
0 users

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 Michael Weiser 2017-12-29 01:24:14 UTC
bootstrap on 10.13 fails for me in stage3 when merging python-2.7.14 (full error below). Turns out, the freshly compiled python.exe in the build dir is linked against the system framework:

# otool -L /Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/work/x86_64-apple-darwin17/python.exe
/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/work/x86_64-apple-darwin17/python.exe:
        /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

This again is caused by -L/usr/lib being on the linker command line:

x86_64-apple-darwin17-clang -Wl,-dead_strip_dylibs -L/Users/michael/nobak/gentoo/lib -L/Users/michael/nobak/gentoo/usr/lib -L/usr/lib -L. -u _PyMac_Error -o python.exe \
                Modules/python.o \
                -L. -lpython2.7 -ldl  -framework CoreFoundation    

It's put there by the ebuild:

        if use prefix ; then
                # for Python's setup.py not to do false assumptions (only looking in
                # host paths) we need to make explicit where Prefix stuff is
                append-cppflags -I"${EPREFIX}"/usr/include
                append-ldflags -L"${EPREFIX}"/$(get_libdir)
                append-ldflags -L"${EPREFIX}"/usr/$(get_libdir)
                # fix compilation on some 64-bits Linux hosts, #381163, #473520
                for hostlibdir in /usr/lib32 /usr/lib64 /usr/lib /lib32 /lib64; do
                        [[ -d ${hostlibdir} ]] || continue
                        append-ldflags -L${hostlibdir}
                done

Python's Makefile actually wants to link against libpython.2.7.dylib in the current directory (-L.). It would be found in EPREFIX/usr/lib because that -L option is first on the command line (that's why the problem doesn't show in a finished prefix install). But during stage3 of bootstrap it's not there yet. It is however found in /usr/lib where it is a symlink to /System/Library/Frameworks/Python.framework/Versions/2.7/Python.

The following change to the ebuild makes the problem go away:

--- /usr/local/gentoo/usr/portage/dev-lang/python/python-2.7.14.ebuild  2017-10-31 10:29:13.000000000 +0100
+++ python-2.7.14.ebuild        2017-12-29 01:38:27.854184364 +0100
@@ -238,7 +238,7 @@
                # fix compilation on some 64-bits Linux hosts, #381163, #473520
                for hostlibdir in /usr/lib32 /usr/lib64 /usr/lib /lib32 /lib64; do
                        [[ -d ${hostlibdir} ]] || continue
-                       append-ldflags -L${hostlibdir}
+                       [[ ${CHOST} == *-darwin* ]] || append-ldflags -L${hostlibdir}
                done
                # Have to move $(CPPFLAGS) to before $(CFLAGS) to ensure that
                # local include paths - set in $(CPPFLAGS) - are searched first.

I have no idea why this blows up only now (the code in the ebuild has been around since at least 2013). Those symlinks in /usr/lib have been there for a number of releases of macOS as well. I can only think, that an ealier version of bootstrap put a libpython.2.7.dylib into EPREFIX/usr/lib before starting stage3.

Full error message:

x86_64-apple-darwin17-clang -Wl,-dead_strip_dylibs -L/Users/michael/nobak/gentoo/lib -L/Users/michael/nobak/gentoo/usr/lib -L/usr/lib -L. -u _PyMac_Error -o python.exe \
                Modules/python.o \
                -L. -lpython2.7 -ldl  -framework CoreFoundation     
DYLD_LIBRARY_PATH=/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/x86_64-apple-darwin17 ./python.exe -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
        echo "generate-posix-vars failed" ; \
        rm -f ./pybuilddir.txt ; \
        exit 1 ; \
fi
running build
running build_ext
Traceback (most recent call last):
  File "/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/Python-2.7.12/setup.py", line 2088, in <module>
    main()
  File "/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/Python-2.7.12/setup.py", line 2082, in main
    'Lib/smtpd.py']
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
    self.build_extensions()
  File "/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/Python-2.7.12/setup.py", line 195, in build_extensions
    missing = self.detect_modules()
  File "/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/Python-2.7.12/setup.py", line 1562, in detect_modules
    addMacExtension('_CF', core_kwds, ['cf/pycfbridge.c'])
  File "/Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.12/work/Python-2.7.12/setup.py", line 1553, in addMacExtension
    raise RuntimeError("%s not found" % name)
RuntimeError: _CF not found
make: *** [Makefile:562: sharedmods] Error 1
 * ERROR: dev-lang/python-2.7.12::gentoo_prefix failed (compile phase):
 *   emake failed
 * 


Reproducible: Always
Comment 1 Michael Weiser 2017-12-29 01:51:11 UTC
I forgot to mention that the bootstrap had previously failed because the python framework contained an invalid install name:

 * QA Notice: install_name references ${D}: /Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/image//Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Python in /Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/bin/pythonw2.7
 * QA Notice: install_name references ${D}: /Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/image//Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Python in /Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/bin/python2.7
 * QA Notice: invalid self-reference install_name /Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/image//Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Python in /Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Python
 * QA Notice: install_name references ${D}: /Users/michael/nobak/gentoo/var/tmp/portage/dev-lang/python-2.7.14/image//Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Python in /Users/michael/nobak/gentoo/usr/lib/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

This made me switch off the aqua use flag for python which got me to the error, this bug is about. Maybe I'm just wandering off the beaten path here...
Comment 2 Fabian Groffen gentoo-dev 2017-12-29 13:21:26 UTC
I had the same experience, also switched off aqua, then forgot about it :)
Comment 3 Larry the Git Cow gentoo-dev 2017-12-29 13:25:47 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=1896ea58f9eef2916986ade1d46aa3e727fbccc7

commit 1896ea58f9eef2916986ade1d46aa3e727fbccc7
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2017-12-29 13:25:28 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2017-12-29 13:25:28 +0000

    dev-lang/python: fix bootstrapping on Darwin, bug #642590
    
    Closes: https://bugs.gentoo.org/642590
    Package-Manager: Portage-2.3.18-prefix, Repoman-2.3.6

 dev-lang/python/python-2.7.12.ebuild | 10 ++++---
 dev-lang/python/python-2.7.14.ebuild | 53 ++++++++++++++++++------------------
 2 files changed, 33 insertions(+), 30 deletions(-)