/usr/lib64/python2.7/_sysconfigdata.py: 'CC': 'x86_64-pc-linux-gnu-gcc-4.8.2 -pthread', and so on. Now that I've upgraded to gcc-4.8.3, no Python extension builds :)
Actually Distutils respecteth CC and CXX, but they are not exported by distutils*.eclass. For linking, LDSHARED and LDCXXSHARED are used. Apparently there is a regression with value of LDSHARED in 2.7 branch... $ (for x in 2.6 2.7 3.1 3.2 3.3 3.4 3.5; do echo -e "=== ${x} ==="; python${x} -c 'from distutils.sysconfig import get_config_var; print("CC=%r" % get_config_var("CC")); print("CXX=%r" % get_config_var("CXX")); print("LDSHARED=%r" % get_config_var("LDSHARED")); print("LDCXXSHARED=%r" % get_config_var("LDCXXSHARED"))'; done) === 2.6 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 2.7 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,--hash-style=gnu -Wl,--sort-common' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 3.1 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 3.2 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 3.3 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 3.4 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared' === 3.5 === CC='x86_64-pc-linux-gnu-gcc -pthread' CXX='x86_64-pc-linux-gnu-g++ -pthread' LDSHARED='x86_64-pc-linux-gnu-gcc -pthread -shared' LDCXXSHARED='x86_64-pc-linux-gnu-g++ -pthread -shared'
Arfrever, thanks. + 19 Jun 2014; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass: + Always set up CC, CXX and friends for distutils builds, bug #513664. Thanks + to Arfrever for the explanation.
*** Bug 457716 has been marked as a duplicate of this bug. ***
Grobian: Re http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/distutils-r1.eclass?r1=1.97&r2=1.98&view=patch : Please show stored value of LDSHARED for different versions of Python.
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #4) > Grobian: > > Re > http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/distutils-r1. > eclass?r1=1.97&r2=1.98&view=patch : > > Please show stored value of LDSHARED for different versions of Python. -shared is invalid on Darwin, we need -bundle and more flags.
(In reply to Fabian Groffen from comment #5) > (In reply to Arfrever Frehtes Taifersar Arahesis from comment #4) > > Grobian: > > > > Re > > http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/distutils-r1. > > eclass?r1=1.97&r2=1.98&view=patch : > > > > Please show stored value of LDSHARED for different versions of Python. > > -shared is invalid on Darwin, we need -bundle and more flags. Are those flags 'generic' or specific to linking of Python extensions? I'm wondering if it'd make sense to create some toolchain-funcs function to obtain the necessary flags. It is important that we already override LDSHARED and LDCXXSHARED since otherwise distutils may not respect CC/CXX during linking and use another compiler.
$ (for x in 2.6 2.7 3.1 3.2 3.3 3.4 3.5; do echo -e "=== ${x} ==="; python${x} -c 'from distutils.sysconfig import get_config_var; print("CC=%r" % get_config_var("CC")); print("CXX=%r" % get_config_var("CXX")); print("LDSHARED=%r" % get_config_var("LDSHARED")); print("LDCXXSHARED=%r" % get_config_var("LDCXXSHARED"))'; done) === 2.6 === CC='cc' CXX='c++' LDSHARED='cc -Wl,-F. -bundle -undefined dynamic_lookup -arch x86_64 -arch i386' LDCXXSHARED=None === 2.7 === CC='x86_64-apple-darwin13-gcc' CXX='x86_64-apple-darwin13-g++' LDSHARED='x86_64-apple-darwin13-gcc -bundle -undefined dynamic_lookup -Wl,-dead_strip_dylibs -L/Library/Gentoo/lib -L/Library/Gentoo/usr/lib -L/usr/lib -L.' LDCXXSHARED='x86_64-apple-darwin13-g++ -bundle -undefined dynamic_lookup' === 3.1 === bash: python3.1: command not found === 3.2 === bash: python3.2: command not found === 3.3 === CC='x86_64-apple-darwin13-gcc' CXX='x86_64-apple-darwin13-g++' LDSHARED='x86_64-apple-darwin13-gcc -bundle -undefined dynamic_lookup' LDCXXSHARED='x86_64-apple-darwin13-g++ -bundle -undefined dynamic_lookup' === 3.4 === bash: python3.4: command not found === 3.5 === bash: python3.5: command not found I need: "$(tc-getCC) -bundle -undefined dynamic_lookup", this is because python builds modules, not shared modules here. A case statement in the eclass to trap darwin hosts and use the flags I need would probably be best.
+ 22 Jun 2014; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass: + Set LD{,CXX}SHARED properly for Darwin, reported by Fabian Groffen on bug + #513664.
Headsup for the related upstream issue: http://bugs.python.org/issue15590