Patchwork python: fix to ensure libpython is stripped

login
register
mail settings
Submitter Przemyslaw Wrzos
Date Jan. 23, 2014, 3:40 a.m.
Message ID <1390448438-13114-1-git-send-email-przemyslaw.wrzos@calyptech.com>
Download mbox | patch
Permalink /patch/313448/
State Superseded
Headers show

Comments

Przemyslaw Wrzos - Jan. 23, 2014, 3:40 a.m.
The python and python3 builds mark libpython as read-only which
prevents it from being stripped out correctly for the target.

Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
---
 package/python/python.mk   | 9 +++++++++
 package/python3/python3.mk | 9 +++++++++
 2 files changed, 18 insertions(+)

 NOTE: Resubmitting as part of patchwork cleanup #6.
Thomas De Schampheleire - Jan. 23, 2014, 2:06 p.m.
On Thu, Jan 23, 2014 at 4:40 AM, Przemyslaw Wrzos
<przemyslaw.wrzos@calyptech.com> wrote:
> The python and python3 builds mark libpython as read-only which
> prevents it from being stripped out correctly for the target.
>
> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
> ---
>  package/python/python.mk   | 9 +++++++++
>  package/python3/python3.mk | 9 +++++++++
>  2 files changed, 18 insertions(+)
>
>  NOTE: Resubmitting as part of patchwork cleanup #6.
>
> diff --git a/package/python/python.mk b/package/python/python.mk
> index 6a6aaac..69662c3 100644
> --- a/package/python/python.mk
> +++ b/package/python/python.mk
> @@ -162,6 +162,15 @@ endef
>
>  PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
>
> +#
> +# Make sure libpython gets stripped out on target
> +#
> +define PYTHON_ENSURE_LIBPYTHON_STRIPPED
> +       chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR)*.so
> +endef
> +
> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_ENSURE_LIBPYTHON_STRIPPED
> +
>  PYTHON_AUTORECONF = YES
>
>  $(eval $(autotools-package))
> diff --git a/package/python3/python3.mk b/package/python3/python3.mk
> index b5e9689..6cbe772 100644
> --- a/package/python3/python3.mk
> +++ b/package/python3/python3.mk
> @@ -149,6 +149,15 @@ endef
>
>  PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
>
> +#
> +# Make sure libpython gets stripped out on target
> +#
> +define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
> +       chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
> +endef
> +
> +PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
> +
>  PYTHON3_AUTORECONF = YES
>
>  define PYTHON3_INSTALL_SYMLINK
> --

Acked-by: Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
Tested-by: Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
(tested with python2 only)

Note: the library will remain writable, but this doesn't look like a
big problem to me...

By the way: nice find! Saves about 4MB on Python 2!
Przemyslaw Wrzos - Jan. 23, 2014, 11:53 p.m.
Hello Thomas,

On Fri, 24 Jan 2014 at 01:06:08, Thomas De Schampheleire wrote:

> On Thu, Jan 23, 2014 at 4:40 AM, Przemyslaw Wrzos
> <przemyslaw.wrzos@calyptech.com> wrote:
>> The python and python3 builds mark libpython as read-only which
>> prevents it from being stripped out correctly for the target.
>> 
>> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
>> ---
>
> Acked-by: Thomas De Schampheleire
> <thomas.de_schampheleire@alcatel-lucent.com> Tested-by: Thomas De
> Schampheleire <thomas.de_schampheleire@alcatel-lucent.com> (tested with
> python2 only)
> 
> Note: the library will remain writable, but this doesn't look like a
> big problem to me...
> 
> By the way: nice find! Saves about 4MB on Python 2!

Yep, that's the only caveat without stuffing some horrible hack into
buildroot elsewhere to get around it. I couldn't think of a downside
though, and I've been running this on my embedded systems for a year now
without issue.

Cheers,
Przemyslaw Wrzos
Thomas De Schampheleire - Jan. 27, 2014, 8:05 p.m.
On Thu, Jan 23, 2014 at 3:06 PM, Thomas De Schampheleire
<patrickdepinguin@gmail.com> wrote:
> On Thu, Jan 23, 2014 at 4:40 AM, Przemyslaw Wrzos
> <przemyslaw.wrzos@calyptech.com> wrote:
>> The python and python3 builds mark libpython as read-only which
>> prevents it from being stripped out correctly for the target.
>>
>> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
>> ---
>>  package/python/python.mk   | 9 +++++++++
>>  package/python3/python3.mk | 9 +++++++++
>>  2 files changed, 18 insertions(+)
>>
>>  NOTE: Resubmitting as part of patchwork cleanup #6.
>>
>> diff --git a/package/python/python.mk b/package/python/python.mk
>> index 6a6aaac..69662c3 100644
>> --- a/package/python/python.mk
>> +++ b/package/python/python.mk
>> @@ -162,6 +162,15 @@ endef
>>
>>  PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
>>
>> +#
>> +# Make sure libpython gets stripped out on target
>> +#
>> +define PYTHON_ENSURE_LIBPYTHON_STRIPPED
>> +       chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR)*.so
>> +endef
>> +
>> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_ENSURE_LIBPYTHON_STRIPPED
>> +
>>  PYTHON_AUTORECONF = YES
>>
>>  $(eval $(autotools-package))
>> diff --git a/package/python3/python3.mk b/package/python3/python3.mk
>> index b5e9689..6cbe772 100644
>> --- a/package/python3/python3.mk
>> +++ b/package/python3/python3.mk
>> @@ -149,6 +149,15 @@ endef
>>
>>  PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
>>
>> +#
>> +# Make sure libpython gets stripped out on target
>> +#
>> +define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
>> +       chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
>> +endef
>> +
>> +PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
>> +
>>  PYTHON3_AUTORECONF = YES
>>
>>  define PYTHON3_INSTALL_SYMLINK
>> --
>
> Acked-by: Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
> Tested-by: Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
> (tested with python2 only)
>
> Note: the library will remain writable, but this doesn't look like a
> big problem to me...
>
> By the way: nice find! Saves about 4MB on Python 2!

ping on this patch?
Thomas Petazzoni - Feb. 13, 2014, 9:08 p.m.
Dear Przemyslaw Wrzos,

On Thu, 23 Jan 2014 14:40:38 +1100, Przemyslaw Wrzos wrote:
> The python and python3 builds mark libpython as read-only which
> prevents it from being stripped out correctly for the target.
> 
> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
> ---
>  package/python/python.mk   | 9 +++++++++
>  package/python3/python3.mk | 9 +++++++++
>  2 files changed, 18 insertions(+)
> 
>  NOTE: Resubmitting as part of patchwork cleanup #6.

I have integrated this patch into the large set of Python patches I've
posted at
http://lists.busybox.net/pipermail/buildroot/2014-February/089309.html.

However, I agree with Thomas De Schampheleire that this specific patch
should be merged for 2014.02, as it fixes a real problem, and gives a
nice size reduction.

Thomas
Przemyslaw Wrzos - Feb. 14, 2014, 12:22 a.m.
Hello Thomas,

On Fri, 14 Feb 2014 at 08:08:54, Thomas Petazzoni wrote:

> Dear Przemyslaw Wrzos,
> 
> On Thu, 23 Jan 2014 14:40:38 +1100, Przemyslaw Wrzos wrote:
>> The python and python3 builds mark libpython as read-only which
>> prevents it from being stripped out correctly for the target.
>> 
>> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
> 
> I have integrated this patch into the large set of Python patches I've
> posted at
> http://lists.busybox.net/pipermail/buildroot/2014-February/089309.html.
> 
> However, I agree with Thomas De Schampheleire that this specific patch
> should be merged for 2014.02, as it fixes a real problem, and gives a
> nice size reduction.
> 
> Thomas

That makes sense. I assume you don't need anything from me at this point.

Cheers,
Przemyslaw Wrzos
Thomas Petazzoni - Feb. 14, 2014, 8:17 a.m.
Dear Przemyslaw Wrzos,

On Fri, 14 Feb 2014 11:22:18 +1100, Przemyslaw Wrzos wrote:

> > On Thu, 23 Jan 2014 14:40:38 +1100, Przemyslaw Wrzos wrote:
> >> The python and python3 builds mark libpython as read-only which
> >> prevents it from being stripped out correctly for the target.
> >> 
> >> Signed-off-by: Przemyslaw Wrzos <przemyslaw.wrzos@calyptech.com>
> > 
> > I have integrated this patch into the large set of Python patches I've
> > posted at
> > http://lists.busybox.net/pipermail/buildroot/2014-February/089309.html.
> > 
> > However, I agree with Thomas De Schampheleire that this specific patch
> > should be merged for 2014.02, as it fixes a real problem, and gives a
> > nice size reduction.
> > 
> > Thomas
> 
> That makes sense. I assume you don't need anything from me at this point.

Nope, at this point your patch is in the queue, it should be handled at
some point :-)

Thanks!

Thomas

Patch

diff --git a/package/python/python.mk b/package/python/python.mk
index 6a6aaac..69662c3 100644
--- a/package/python/python.mk
+++ b/package/python/python.mk
@@ -162,6 +162,15 @@  endef
 
 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
 
+#
+# Make sure libpython gets stripped out on target
+#
+define PYTHON_ENSURE_LIBPYTHON_STRIPPED
+	chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR)*.so
+endef
+
+PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_ENSURE_LIBPYTHON_STRIPPED
+
 PYTHON_AUTORECONF = YES
 
 $(eval $(autotools-package))
diff --git a/package/python3/python3.mk b/package/python3/python3.mk
index b5e9689..6cbe772 100644
--- a/package/python3/python3.mk
+++ b/package/python3/python3.mk
@@ -149,6 +149,15 @@  endef
 
 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
 
+#
+# Make sure libpython gets stripped out on target
+#
+define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
+	chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
+endef
+
+PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
+
 PYTHON3_AUTORECONF = YES
 
 define PYTHON3_INSTALL_SYMLINK