This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python 2.7rc2 includes -isysroot twice on each gcc command line
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: eric.araujo, lemburg, ned.deily, ronaldoussoren, tarek
Priority: normal Keywords: patch

Created on 2010-06-21 18:38 by lemburg, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
setup.py.patch ronaldoussoren, 2010-07-24 12:10 review
Messages (10)
msg108295 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-06-21 18:38
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 #9046: Python 2.7rc2 doesn't build on Mac OS X 10.3.

The two issues could also be connected.
msg108296 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-06-21 18:39
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.
msg108356 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-06-22 10:17
Sigh.

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

I'll see what can be done to avoid adding -isysroot twice to the compiler flags.
msg108786 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-06-27 12:54
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.
msg111465 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-07-24 12:10
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.
msg113163 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-08-07 10:16
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.
msg119212 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-10-20 14:59
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.
msg119654 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-10-26 22:06
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.
msg122061 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-22 02:02
Can this be closed now?
msg131123 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-16 14:51
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.
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53293
2011-03-16 14:51:00ronaldoussorensetstatus: open -> closed
nosy: lemburg, ronaldoussoren, tarek, ned.deily, eric.araujo
messages: + msg131123
resolution: works for me

type: compile error
stage: resolved
2010-11-22 02:02:42ned.deilysetnosy: + ned.deily
messages: + msg122061
2010-10-26 22:06:40lemburgsetmessages: + msg119654
2010-10-20 14:59:24ronaldoussorensetmessages: + msg119212
2010-08-21 22:37:44eric.araujosetnosy: + eric.araujo
2010-08-07 10:16:19ronaldoussorensetmessages: + msg113163
2010-07-24 12:10:53ronaldoussorensetfiles: + setup.py.patch

nosy: + tarek
messages: + msg111465

keywords: + patch
2010-06-27 12:54:23ronaldoussorensetmessages: + msg108786
2010-06-22 10:17:51ronaldoussorensetmessages: + msg108356
2010-06-21 18:39:33lemburgsetmessages: + msg108296
2010-06-21 18:38:12lemburgcreate