Patchwork [1/1] python-native: Fix a compiler finding issue

login
register
mail settings
Submitter Mei Lei
Date July 28, 2011, 7:20 a.m.
Message ID <2241650b6cb4e409a5463d38cfa0274eec3a3ee2.1311836896.git.lei.mei@intel.com>
Download mbox | patch
Permalink /patch/8765/
State New, archived
Headers show

Comments

Mei Lei - July 28, 2011, 7:20 a.m.
The CC variable sometimes add option information after compiler name, but python can't get the real compiler name if those information added.
Fix this issue by dropping the option information when finding compiler name.

Signed-off-by: Mei Lei <lei.mei@intel.com>
---
 .../python/python-native/unixccompiler.patch       |   20 ++++++++++++++++++++
 .../recipes-devtools/python/python-native_2.6.6.bb |    3 ++-
 2 files changed, 22 insertions(+), 1 deletions(-)
 create mode 100644 meta/recipes-devtools/python/python-native/unixccompiler.patch
Tom Rini - July 28, 2011, 3:08 p.m.
On 07/28/2011 12:20 AM, Mei Lei wrote:
> The CC variable sometimes add option information after compiler name, but python can't get the real compiler name if those information added.
> Fix this issue by dropping the option information when finding compiler name.
> 
> Signed-off-by: Mei Lei <lei.mei@intel.com>

I think this is going to cause problems when you must pass flags to gcc
to have it work, eg 'gcc -m64'.
Mei Lei - July 29, 2011, 1:15 a.m.
>-----Original Message-----
>From: openembedded-core-bounces@lists.openembedded.org
>[mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>Tom Rini
>Sent: Thursday, July 28, 2011 11:09 PM
>To: openembedded-core@lists.openembedded.org
>Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>
>On 07/28/2011 12:20 AM, Mei Lei wrote:
>> The CC variable sometimes add option information after compiler name, but
>python can't get the real compiler name if those information added.
>> Fix this issue by dropping the option information when finding compiler name.
>>
>> Signed-off-by: Mei Lei <lei.mei@intel.com>
>
>I think this is going to cause problems when you must pass flags to gcc
>to have it work, eg 'gcc -m64'.

This patch fixed your worried issue.
The CC variable, sometimes like:  "x86_64-poky-linux-gcc -m64 --sysroot=/${TMPDIR}/sysroots/qemux86-64", contains flags information. 
This will lead to wrong compiler name "qemux86-64" rather than "x86_64-poky-linux-gcc" when python finding the compiler name, so add this patch to find the real gcc name.

Thanks
Lei 


>
>--
>Tom Rini
>Mentor Graphics Corporation
>
>_______________________________________________
>Openembedded-core mailing list
>Openembedded-core@lists.openembedded.org
>http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Tom Rini - July 29, 2011, 1:43 a.m.
On 07/28/2011 06:15 PM, Mei, Lei wrote:
> 
> 
>> -----Original Message-----
>> From: openembedded-core-bounces@lists.openembedded.org
>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>> Tom Rini
>> Sent: Thursday, July 28, 2011 11:09 PM
>> To: openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>>
>> On 07/28/2011 12:20 AM, Mei Lei wrote:
>>> The CC variable sometimes add option information after compiler name, but
>> python can't get the real compiler name if those information added.
>>> Fix this issue by dropping the option information when finding compiler name.
>>>
>>> Signed-off-by: Mei Lei <lei.mei@intel.com>
>>
>> I think this is going to cause problems when you must pass flags to gcc
>> to have it work, eg 'gcc -m64'.
> 
> This patch fixed your worried issue.
> The CC variable, sometimes like:  "x86_64-poky-linux-gcc -m64 --sysroot=/${TMPDIR}/sysroots/qemux86-64", contains flags information. 
> This will lead to wrong compiler name "qemux86-64" rather than "x86_64-poky-linux-gcc" when python finding the compiler name, so add this patch to find the real gcc name.

No, what I'm saying is I have a compiler that must be invoked as 'gcc
-m64' (which is what BUILD_CC is).  So, I think after saying that, the
right answer is to modify python to read the OE-specific BUILD_CC variable.
Mei Lei - July 29, 2011, 6:58 a.m.
>-----Original Message-----
>From: openembedded-core-bounces@lists.openembedded.org
>[mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>Tom Rini
>Sent: Friday, July 29, 2011 9:44 AM
>To: openembedded-core@lists.openembedded.org
>Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>
>On 07/28/2011 06:15 PM, Mei, Lei wrote:
>>
>>
>>> -----Original Message-----
>>> From: openembedded-core-bounces@lists.openembedded.org
>>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf
>Of
>>> Tom Rini
>>> Sent: Thursday, July 28, 2011 11:09 PM
>>> To: openembedded-core@lists.openembedded.org
>>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding
>issue
>>>
>>> On 07/28/2011 12:20 AM, Mei Lei wrote:
>>>> The CC variable sometimes add option information after compiler name,
>but
>>> python can't get the real compiler name if those information added.
>>>> Fix this issue by dropping the option information when finding compiler
>name.
>>>>
>>>> Signed-off-by: Mei Lei <lei.mei@intel.com>
>>>
>>> I think this is going to cause problems when you must pass flags to gcc
>>> to have it work, eg 'gcc -m64'.
>>
>> This patch fixed your worried issue.
>> The CC variable, sometimes like:  "x86_64-poky-linux-gcc -m64
>--sysroot=/${TMPDIR}/sysroots/qemux86-64", contains flags information.
>> This will lead to wrong compiler name "qemux86-64" rather than
>"x86_64-poky-linux-gcc" when python finding the compiler name, so add this
>patch to find the real gcc name.
>
>No, what I'm saying is I have a compiler that must be invoked as 'gcc
>-m64' (which is what BUILD_CC is).  So, I think after saying that, the
>right answer is to modify python to read the OE-specific BUILD_CC variable.


I think I didn't describe this patch exactly before.

This patch is only for function runtime_library_dir_option, this function is to detect which platform we are running and what compiler we used, then decide what option information should be passed to compiler.

By default, our cross-compiler's name be recognized as "qemux86" rather than " x86_64-poky-linux-gcc" in this function, this is wrong, this will induce a wrong option information passed to x86_64-poky-linux-gcc and block the compile process.

And function runtime_library_dir_option only return the option information, so didn't influence compiler name in global.

By the way, I think BUILD_CC is host compiler name, not for target.

Thanks
Lei
>
>--
>Tom Rini
>Mentor Graphics Corporation
>
>_______________________________________________
>Openembedded-core mailing list
>Openembedded-core@lists.openembedded.org
>http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Tom Rini - July 29, 2011, 3:28 p.m.
On 07/28/2011 11:58 PM, Mei, Lei wrote:
> 
> 
>> -----Original Message-----
>> From: openembedded-core-bounces@lists.openembedded.org
>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>> Tom Rini
>> Sent: Friday, July 29, 2011 9:44 AM
>> To: openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>>
>> On 07/28/2011 06:15 PM, Mei, Lei wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: openembedded-core-bounces@lists.openembedded.org
>>>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf
>> Of
>>>> Tom Rini
>>>> Sent: Thursday, July 28, 2011 11:09 PM
>>>> To: openembedded-core@lists.openembedded.org
>>>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding
>> issue
>>>>
>>>> On 07/28/2011 12:20 AM, Mei Lei wrote:
>>>>> The CC variable sometimes add option information after compiler name,
>> but
>>>> python can't get the real compiler name if those information added.
>>>>> Fix this issue by dropping the option information when finding compiler
>> name.
>>>>>
>>>>> Signed-off-by: Mei Lei <lei.mei@intel.com>
>>>>
>>>> I think this is going to cause problems when you must pass flags to gcc
>>>> to have it work, eg 'gcc -m64'.
>>>
>>> This patch fixed your worried issue.
>>> The CC variable, sometimes like:  "x86_64-poky-linux-gcc -m64
>> --sysroot=/${TMPDIR}/sysroots/qemux86-64", contains flags information.
>>> This will lead to wrong compiler name "qemux86-64" rather than
>> "x86_64-poky-linux-gcc" when python finding the compiler name, so add this
>> patch to find the real gcc name.
>>
>> No, what I'm saying is I have a compiler that must be invoked as 'gcc
>> -m64' (which is what BUILD_CC is).  So, I think after saying that, the
>> right answer is to modify python to read the OE-specific BUILD_CC variable.
> 
> 
> I think I didn't describe this patch exactly before.
> 
> This patch is only for function runtime_library_dir_option, this function is to detect which platform we are running and what compiler we used, then decide what option information should be passed to compiler.
> 
> By default, our cross-compiler's name be recognized as "qemux86" rather than " x86_64-poky-linux-gcc" in this function, this is wrong, this will induce a wrong option information passed to x86_64-poky-linux-gcc and block the compile process.
> 
> And function runtime_library_dir_option only return the option information, so didn't influence compiler name in global.
> 
> By the way, I think BUILD_CC is host compiler name, not for target.

You're patching python-native, not python, which means the host python
and not the target python.
Mei Lei - Aug. 1, 2011, 12:41 p.m.
>-----Original Message-----
>From: openembedded-core-bounces@lists.openembedded.org
>[mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>Tom Rini
>Sent: Friday, July 29, 2011 11:29 PM
>To: openembedded-core@lists.openembedded.org
>Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>
>On 07/28/2011 11:58 PM, Mei, Lei wrote:
>>
>>
>>> -----Original Message-----
>>> From: openembedded-core-bounces@lists.openembedded.org
>>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf
>Of
>>> Tom Rini
>>> Sent: Friday, July 29, 2011 9:44 AM
>>> To: openembedded-core@lists.openembedded.org
>>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding
>issue
>>>
>>> On 07/28/2011 06:15 PM, Mei, Lei wrote:
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: openembedded-core-bounces@lists.openembedded.org
>>>>> [mailto:openembedded-core-bounces@lists.openembedded.org] On
>Behalf
>>> Of
>>>>> Tom Rini
>>>>> Sent: Thursday, July 28, 2011 11:09 PM
>>>>> To: openembedded-core@lists.openembedded.org
>>>>> Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding
>>> issue
>>>>>
>>>>> On 07/28/2011 12:20 AM, Mei Lei wrote:
>>>>>> The CC variable sometimes add option information after compiler name,
>>> but
>>>>> python can't get the real compiler name if those information added.
>>>>>> Fix this issue by dropping the option information when finding compiler
>>> name.
>>>>>>
>>>>>> Signed-off-by: Mei Lei <lei.mei@intel.com>
>>>>>
>>>>> I think this is going to cause problems when you must pass flags to gcc
>>>>> to have it work, eg 'gcc -m64'.
>>>>
>>>> This patch fixed your worried issue.
>>>> The CC variable, sometimes like:  "x86_64-poky-linux-gcc -m64
>>> --sysroot=/${TMPDIR}/sysroots/qemux86-64", contains flags information.
>>>> This will lead to wrong compiler name "qemux86-64" rather than
>>> "x86_64-poky-linux-gcc" when python finding the compiler name, so add this
>>> patch to find the real gcc name.
>>>
>>> No, what I'm saying is I have a compiler that must be invoked as 'gcc
>>> -m64' (which is what BUILD_CC is).  So, I think after saying that, the
>>> right answer is to modify python to read the OE-specific BUILD_CC variable.
>>
>>
>> I think I didn't describe this patch exactly before.
>>
>> This patch is only for function runtime_library_dir_option, this function is to
>detect which platform we are running and what compiler we used, then decide
>what option information should be passed to compiler.
>>
>> By default, our cross-compiler's name be recognized as "qemux86" rather
>than " x86_64-poky-linux-gcc" in this function, this is wrong, this will induce a
>wrong option information passed to x86_64-poky-linux-gcc and block the
>compile process.
>>
>> And function runtime_library_dir_option only return the option information,
>so didn't influence compiler name in global.
>>
>> By the way, I think BUILD_CC is host compiler name, not for target.
>
>You're patching python-native, not python, which means the host python
>and not the target python.

Yes, but I think this function will be called by python-pycairo, which will use cross compiler name in this function, so we should get the compiler name from CC.

Thanks
Lei 

>
>--
>Tom Rini
>Mentor Graphics Corporation
>
>_______________________________________________
>Openembedded-core mailing list
>Openembedded-core@lists.openembedded.org
>http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Khem Raj - Aug. 1, 2011, 5:27 p.m.
On (01/08/11 20:41), Mei, Lei wrote:
> 
> >
> >You're patching python-native, not python, which means the host python
> >and not the target python.
> 
> Yes, but I think this function will be called by python-pycairo, which will use cross compiler name in this function, so we should get the compiler name from CC.

so we inject the cross compiler name hardcoded into python and then
python uses it when it needs to do cross compilation ?
Mei Lei - Aug. 2, 2011, 3:08 a.m.
>-----Original Message-----
>From: openembedded-core-bounces@lists.openembedded.org
>[mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>Khem Raj
>Sent: Tuesday, August 02, 2011 1:27 AM
>To: Patches and discussions about the oe-core layer
>Subject: Re: [OE-core] [PATCH 1/1] python-native: Fix a compiler finding issue
>
>On (01/08/11 20:41), Mei, Lei wrote:
>>
>> >
>> >You're patching python-native, not python, which means the host python
>> >and not the target python.
>>
>> Yes, but I think this function will be called by python-pycairo, which will use
>cross compiler name in this function, so we should get the compiler name from
>CC.
>
>so we inject the cross compiler name hardcoded into python and then
>python uses it when it needs to do cross compilation ?

No hardcode, I think. Python use the cross compiler name from CC, which will be exported to environment when we do cross compilation.
If environment didn't define the CC, the default compiler name will be used, I mean, host compiler name.

Thanks
Lei

>
>_______________________________________________
>Openembedded-core mailing list
>Openembedded-core@lists.openembedded.org
>http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/recipes-devtools/python/python-native/unixccompiler.patch b/meta/recipes-devtools/python/python-native/unixccompiler.patch
new file mode 100644
index 0000000..10a9baf
--- /dev/null
+++ b/meta/recipes-devtools/python/python-native/unixccompiler.patch
@@ -0,0 +1,20 @@ 
+Upstream-Status: Inappropriate [embedded specific]
+
+# The CC variable,sometimes like:"x86_64-poky-linux-gcc   -m64 --sysroot=/${TMPDIR}/sysroots/qemux86-64", contains option information. 
+# This will lead to wrong compiler name "qemux86-64" rather than "x86_64-poky-linux-gcc" when python finding the compiler name.
+
+#Signed-off-by: Mei Lei <lei.mei@intel.com>
+
+diff --git Python-2.6.6/Lib/distutils/unixccompiler.py Python-2.6.6/Lib/distutils/unixccompiler.py
+index 6d0b84d..aaf49cb 100644
+--- Python-2.6.6/Lib/distutils/unixccompiler.py
++++ Python-2.6.6/Lib/distutils/unixccompiler.py
+@@ -282,7 +282,7 @@ class UnixCCompiler(CCompiler):
+         # this time, there's no way to determine this information from
+         # the configuration data stored in the Python installation, so
+         # we use this hack.
+-        compiler = os.path.basename(sysconfig.get_config_var("CC"))
++        compiler = os.path.basename(sysconfig.get_config_var("CC").split()[0])
+         if sys.platform[:6] == "darwin":
+             # MacOSX's linker doesn't understand the -R flag at all
+             return "-L" + dir
diff --git a/meta/recipes-devtools/python/python-native_2.6.6.bb b/meta/recipes-devtools/python/python-native_2.6.6.bb
index 59ed61a..2b00d32 100644
--- a/meta/recipes-devtools/python/python-native_2.6.6.bb
+++ b/meta/recipes-devtools/python/python-native_2.6.6.bb
@@ -1,6 +1,6 @@ 
 require python.inc
 DEPENDS = "openssl-native bzip2-full-native zlib-native readline-native sqlite3-native"
-PR = "${INC_PR}.2"
+PR = "${INC_PR}.3"
 
 LIC_FILES_CHKSUM = "file://LICENSE;md5=38fdd546420fab09ac6bd3d8a1c83eb6"
 
@@ -12,6 +12,7 @@  SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.bz2 \
            file://11-distutils-never-modify-shebang-line.patch \
            file://12-distutils-prefix-is-inside-staging-area.patch \
            file://debug.patch \
+           file://unixccompiler.patch \
            file://nohostlibs.patch"
 S = "${WORKDIR}/Python-${PV}"