Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7rc2 includes -isysroot twice on each gcc command line #53293

Closed
malemburg opened this issue Jun 21, 2010 · 10 comments
Closed

Python 2.7rc2 includes -isysroot twice on each gcc command line #53293

malemburg opened this issue Jun 21, 2010 · 10 comments
Assignees
Labels
build The build process and cross-build

Comments

@malemburg
Copy link
Member

BPO 9047
Nosy @malemburg, @ronaldoussoren, @tarekziade, @ned-deily, @merwok
Files
  • setup.py.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ronaldoussoren'
    closed_at = <Date 2011-03-16.14:51:00.635>
    created_at = <Date 2010-06-21.18:38:12.107>
    labels = ['build']
    title = 'Python 2.7rc2 includes -isysroot twice on each gcc command line'
    updated_at = <Date 2011-03-16.14:51:00.633>
    user = 'https://github.com/malemburg'

    bugs.python.org fields:

    activity = <Date 2011-03-16.14:51:00.633>
    actor = 'ronaldoussoren'
    assignee = 'ronaldoussoren'
    closed = True
    closed_date = <Date 2011-03-16.14:51:00.635>
    closer = 'ronaldoussoren'
    components = ['Build']
    creation = <Date 2010-06-21.18:38:12.107>
    creator = 'lemburg'
    dependencies = []
    files = ['18181']
    hgrepos = []
    issue_num = 9047
    keywords = ['patch']
    message_count = 10.0
    messages = ['108295', '108296', '108356', '108786', '111465', '113163', '119212', '119654', '122061', '131123']
    nosy_count = 5.0
    nosy_names = ['lemburg', 'ronaldoussoren', 'tarek', 'ned.deily', 'eric.araujo']
    pr_nums = []
    priority = 'normal'
    resolution = 'works for me'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue9047'
    versions = ['Python 2.7']

    @malemburg
    Copy link
    Member Author

    A typical build line looks like this:

    gcc-4.0 -c -fno-strict-aliasing -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DPy_BUILD_CORE -o Python/codecs.o Python/codecs.c

    With older Xcode releases, the above is known not to work at all: gcc simply gives up and raises an error. With the latest Xcode available for 10.3 (last release + all patches), gcc accepts the extra options, but it's not clear whether the resulting code will work... mostly due to bpo-9046: Python 2.7rc2 doesn't build on Mac OS X 10.3.

    The two issues could also be connected.

    @malemburg malemburg added the build The build process and cross-build label Jun 21, 2010
    @malemburg
    Copy link
    Member Author

    Note that the duplicate insertion of -isysroot happens because CPPFLAGS was changed to include this extra option.

    Since PY_CFLAGS includes both CFLAGS and CPPFLAGS, you get the duplicate occurrence.

    In Python 2.6, the extra option did appear in CPPFLAGS.

    @ronaldoussoren
    Copy link
    Contributor

    Sigh.

    -isysroot was added to CPPFLAGS because Python wouldn't build as a universal binary anymore due a fix for bpo-1628484. (According to the SVN log for r80187).

    I'll see what can be done to avoid adding -isysroot twice to the compiler flags.

    @ronaldoussoren
    Copy link
    Contributor

    Marc-Andre: is this still relevant or did the fix for SDK support enough to fix the build.

    BTW. Is this for OSX 10.4 instead of 10.3? AFAIK the compiler on 10.3 doesn't support SDKs at all.

    @ronaldoussoren
    Copy link
    Contributor

    The root cause of having the flags twice is that the Makefile explicitly sets LDFLAGS in the environment before when running setup.py, and that distutils appens the value of $(LDFLAGS) to $(LDSHARED) when LDFLAGS is set in the environment.

    Line from the makefile:
    $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;

    And in Lib/distutils/ccompiler.py (in customize_compiler):

            if 'LDFLAGS' in os.environ:
                ldshared = ldshared + ' ' + os.environ['LDFLAGS']

    A quick workaround to remove the duplicate flags is to explictly remove the related values from os.environ before calling main in setup.py:

    # --install-platlib
    if __name__ == '__main__':
        import os
        del os.environ['LDFLAGS']
        main()

    I've attached a patch that implements this behavior. I'm not 100% sure this is the right solution because sysconfig._parse_makefile also looks at the environment and it may be better to remove the code from ccompiler.customize_compiler instead.

    @ronaldoussoren
    Copy link
    Contributor

    The patch is not sufficient to fix this issue. One problem is that the configure script also using CFLAGS and CPPFLAGS, which results in duplicate -isysroot flags when the compiler is used by configure.

    Fixing this properly is annoyingly hard, I'll have to write down a dataflow graph to find a way to set -isysroot and the -arch flags in the minimal amount of locations to get the right behavior and to get rid of duplicate flags.

    @ronaldoussoren
    Copy link
    Contributor

    Marc-Andre: does the current HEAD of the 2.7 and 3.2 branches work for you?

    The build still has duplicate flags, but that doesn't seem to cause problems on my machines. If it also doesn't cause problems on your machines I'd prefer to close this issue as won't fixed because cleaning up the duplicate flags is non-trivial.

    @malemburg
    Copy link
    Member Author

    Ronald Oussoren wrote:

    Ronald Oussoren <ronaldoussoren@mac.com> added the comment:

    Marc-Andre: does the current HEAD of the 2.7 and 3.2 branches work for you?

    The build still has duplicate flags, but that doesn't seem to cause problems on my machines. If it also doesn't cause problems on your machines I'd prefer to close this issue as won't fixed because cleaning up the duplicate flags is non-trivial.

    I'll give this a try tomorrow.

    @ned-deily
    Copy link
    Member

    Can this be closed now?

    @ronaldoussoren
    Copy link
    Contributor

    This is no longer a problem on any machine I have access to, I'm therefore closing this issue.

    Please reopen if you still have problems on your machine, if you do so include detailed information about: OSX release, system architecture (ppc, i386), Xcode release used.

    @ronaldoussoren ronaldoussoren added the build The build process and cross-build label Mar 16, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants