* [Buildroot] [PATCH] fs: allow strip binaries when create rootfs
@ 2021-11-10 16:10 Tan Xiaofan
2021-11-10 19:00 ` Yann E. MORIN
0 siblings, 1 reply; 5+ messages in thread
From: Tan Xiaofan @ 2021-11-10 16:10 UTC (permalink / raw)
To: buildroot@buildroot.org
From 2f74b5bedffdf32e71a3786ca740c82257982f80 Mon Sep 17 00:00:00 2001
From: xiaofan <xfan1024@live.com>
Date: Wed, 10 Nov 2021 23:13:25 +0800
Subject: [PATCH] fs: allow strip binaries when create rootfs
Add BR2_STRIP_ROOTFS option, it is useful when using gdbserver on
target board. Host need unstriped binares for debug info and target
need only striped binares for rootfs size.
Signed-off-by: xiaofan <xfan1024@live.com>
---
Config.in | 21 +++++++++++++++++----
fs/common.mk | 4 ++++
package/Makefile.in | 5 +++--
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/Config.in b/Config.in
index 3db2c8d..60a15ae 100644
--- a/Config.in
+++ b/Config.in
@@ -425,10 +425,10 @@ config BR2_ENABLE_RUNTIME_DEBUG
Note: disabling this option is not a guarantee that all
packages effectively removed these runtime debugging elements.
-config BR2_STRIP_strip
- bool "strip target binaries"
- default y
- depends on !BR2_PACKAGE_HOST_ELF2FLT
+choice
+ prompt "strip target binaries"
+ default BR2_STRIP_strip if !BR2_PACKAGE_HOST_ELF2FLT
+ default BR2_STRIP_DISABLE if BR2_PACKAGE_HOST_ELF2FLT
help
Binaries and libraries in the target filesystem will be
stripped using the normal 'strip' command. This allows to save
@@ -436,6 +436,19 @@ config BR2_STRIP_strip
on the target are needed for native debugging, but not when
remote debugging is used.
+config BR2_STRIP_strip
+ bool "enable"
+ depends on !BR2_PACKAGE_HOST_ELF2FLT
+
+config BR2_STRIP_ROOTFS
+ bool "enable: only affects on rootfs image"
+ depends on !BR2_PACKAGE_HOST_ELF2FLT
+
+config BR2_STRIP_DISABLE
+ bool "disable"
+
+endchoice
+
config BR2_STRIP_EXCLUDE_FILES
string "executables that should not be stripped"
default ""
diff --git a/fs/common.mk b/fs/common.mk
index afab7b5..ac261ba 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -171,6 +171,10 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
--exclude=/$$(notdir $$(TARGET_DIR_WARNING_FILE)) \
$$(BASE_TARGET_DIR)/ \
$$(TARGET_DIR)
+ifeq ($$(BR2_STRIP_ROOTFS),y)
+ $$(STRIP_FIND_CMD) | xargs -0 $$(STRIPCMD_ALWAYS) 2>/dev/null || true
+ $$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $$(STRIPCMD_ALWAYS) $$(STRIP_STRIP_DEBUG) 2>/dev/null || true
+endif
echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
echo "set -e" >> $$(FAKEROOT_SCRIPT)
diff --git a/package/Makefile.in b/package/Makefile.in
index dae7a85..d623837 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -224,10 +224,11 @@ TARGET_READELF = $(TARGET_CROSS)readelf
TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
TARGET_OBJDUMP = $(TARGET_CROSS)objdump
-ifeq ($(BR2_STRIP_strip),y)
STRIP_STRIP_DEBUG := --strip-debug
+STRIPCMD_ALWAYS = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
+ifeq ($(BR2_STRIP_strip),y)
TARGET_STRIP = $(TARGET_CROSS)strip
-STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
+STRIPCMD = $(STRIPCMD_ALWAYS)
else
TARGET_STRIP = /bin/true
STRIPCMD = $(TARGET_STRIP)
--
2.17.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] fs: allow strip binaries when create rootfs
2021-11-10 16:10 [Buildroot] [PATCH] fs: allow strip binaries when create rootfs Tan Xiaofan
@ 2021-11-10 19:00 ` Yann E. MORIN
2021-11-11 3:16 ` [Buildroot] 回复: " Tan Xiaofan
2021-11-12 22:36 ` [Buildroot] " Thomas Petazzoni
0 siblings, 2 replies; 5+ messages in thread
From: Yann E. MORIN @ 2021-11-10 19:00 UTC (permalink / raw)
To: Tan Xiaofan; +Cc: Thomas Petazzoni, buildroot@buildroot.org
Xiaofan, All,
+Peter, +Arnout, +Thomas
On 2021-11-10 16:10 +0000, Tan Xiaofan spake thusly:
> From 2f74b5bedffdf32e71a3786ca740c82257982f80 Mon Sep 17 00:00:00 2001
> From: xiaofan <xfan1024@live.com>
> Date: Wed, 10 Nov 2021 23:13:25 +0800
> Subject: [PATCH] fs: allow strip binaries when create rootfs
>
> Add BR2_STRIP_ROOTFS option, it is useful when using gdbserver on
> target board. Host need unstriped binares for debug info and target
> need only striped binares for rootfs size.
>
> Signed-off-by: xiaofan <xfan1024@live.com>
This is a simple approach to the problem, indeed. However, I think the
choice is not needed: just keep the boolean option, and move the whole
stripping out of target-finalize and into the fs creation step.
Thoughts?
Regards,
Yann E. MORIN.
> ---
> Config.in | 21 +++++++++++++++++----
> fs/common.mk | 4 ++++
> package/Makefile.in | 5 +++--
> 3 files changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/Config.in b/Config.in
> index 3db2c8d..60a15ae 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -425,10 +425,10 @@ config BR2_ENABLE_RUNTIME_DEBUG
> Note: disabling this option is not a guarantee that all
> packages effectively removed these runtime debugging elements.
>
> -config BR2_STRIP_strip
> - bool "strip target binaries"
> - default y
> - depends on !BR2_PACKAGE_HOST_ELF2FLT
> +choice
> + prompt "strip target binaries"
> + default BR2_STRIP_strip if !BR2_PACKAGE_HOST_ELF2FLT
> + default BR2_STRIP_DISABLE if BR2_PACKAGE_HOST_ELF2FLT
> help
> Binaries and libraries in the target filesystem will be
> stripped using the normal 'strip' command. This allows to save
> @@ -436,6 +436,19 @@ config BR2_STRIP_strip
> on the target are needed for native debugging, but not when
> remote debugging is used.
>
> +config BR2_STRIP_strip
> + bool "enable"
> + depends on !BR2_PACKAGE_HOST_ELF2FLT
> +
> +config BR2_STRIP_ROOTFS
> + bool "enable: only affects on rootfs image"
> + depends on !BR2_PACKAGE_HOST_ELF2FLT
> +
> +config BR2_STRIP_DISABLE
> + bool "disable"
> +
> +endchoice
> +
> config BR2_STRIP_EXCLUDE_FILES
> string "executables that should not be stripped"
> default ""
> diff --git a/fs/common.mk b/fs/common.mk
> index afab7b5..ac261ba 100644
> --- a/fs/common.mk
> +++ b/fs/common.mk
> @@ -171,6 +171,10 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
> --exclude=/$$(notdir $$(TARGET_DIR_WARNING_FILE)) \
> $$(BASE_TARGET_DIR)/ \
> $$(TARGET_DIR)
> +ifeq ($$(BR2_STRIP_ROOTFS),y)
> + $$(STRIP_FIND_CMD) | xargs -0 $$(STRIPCMD_ALWAYS) 2>/dev/null || true
> + $$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $$(STRIPCMD_ALWAYS) $$(STRIP_STRIP_DEBUG) 2>/dev/null || true
> +endif
>
> echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
> echo "set -e" >> $$(FAKEROOT_SCRIPT)
> diff --git a/package/Makefile.in b/package/Makefile.in
> index dae7a85..d623837 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -224,10 +224,11 @@ TARGET_READELF = $(TARGET_CROSS)readelf
> TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
> TARGET_OBJDUMP = $(TARGET_CROSS)objdump
>
> -ifeq ($(BR2_STRIP_strip),y)
> STRIP_STRIP_DEBUG := --strip-debug
> +STRIPCMD_ALWAYS = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
> +ifeq ($(BR2_STRIP_strip),y)
> TARGET_STRIP = $(TARGET_CROSS)strip
> -STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
> +STRIPCMD = $(STRIPCMD_ALWAYS)
> else
> TARGET_STRIP = /bin/true
> STRIPCMD = $(TARGET_STRIP)
> --
> 2.17.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] 回复: [PATCH] fs: allow strip binaries when create rootfs
2021-11-10 19:00 ` Yann E. MORIN
@ 2021-11-11 3:16 ` Tan Xiaofan
2021-11-12 22:36 ` [Buildroot] " Thomas Petazzoni
1 sibling, 0 replies; 5+ messages in thread
From: Tan Xiaofan @ 2021-11-11 3:16 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Thomas Petazzoni, buildroot@buildroot.org
>> From: xiaofan <xfan1024@live.com>
>> Date: Wed, 10 Nov 2021 23:13:25 +0800
>> Subject: [PATCH] fs: allow strip binaries when create rootfs
>>
>> Add BR2_STRIP_ROOTFS option, it is useful when using gdbserver on
>> target board. Host need unstriped binares for debug info and target
>> need only striped binares for rootfs size.
>>
>> Signed-off-by: xiaofan <xfan1024@live.com>
>
> This is a simple approach to the problem, indeed. However, I think the
> choice is not needed: just keep the boolean option, and move the whole
> stripping out of target-finalize and into the fs creation step.
>
Do you mean to change the behavior of BR2_STRIP_strip without adding other
options? In this case, we need to permanently set TARGET_STRIP to /bin/true
to prevent the binaries from being stripped on building time.
From 2b55431c3d5ccee2aa43f5996cfff65afe3f6537 Mon Sep 17 00:00:00 2001
From: xiaofan <xfan1024@live.com>
Date: Thu, 11 Nov 2021 11:01:13 +0800
Subject: [PATCH] fs: move stripping into fs creation step
It is useful when using gdbserver on target board. Host need unstriped
binares for debug info and target need only striped binares for rootfs
size.
Signed-off-by: xiaofan <xfan1024@live.com>
---
Config.in | 4 +---
Makefile | 2 --
fs/common.mk | 4 ++++
package/Makefile.in | 7 +------
4 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/Config.in b/Config.in
index 3db2c8d..593859c 100644
--- a/Config.in
+++ b/Config.in
@@ -432,9 +432,7 @@ config BR2_STRIP_strip
help
Binaries and libraries in the target filesystem will be
stripped using the normal 'strip' command. This allows to save
- space, mainly by removing debugging symbols. Debugging symbols
- on the target are needed for native debugging, but not when
- remote debugging is used.
+ space, mainly by removing debugging symbols.
config BR2_STRIP_EXCLUDE_FILES
string "executables that should not be stripped"
diff --git a/Makefile b/Makefile
index 4062883..64cc8a0 100644
--- a/Makefile
+++ b/Makefile
@@ -763,8 +763,6 @@ endif
ifneq ($(BR2_ENABLE_DEBUG):$(BR2_STRIP_strip),y:)
rm -rf $(TARGET_DIR)/lib/debug $(TARGET_DIR)/usr/lib/debug
endif
- $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
- $(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true
test -f $(TARGET_DIR)/etc/ld.so.conf && \
{ echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
diff --git a/fs/common.mk b/fs/common.mk
index afab7b5..9675d02 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -171,6 +171,10 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
--exclude=/$$(notdir $$(TARGET_DIR_WARNING_FILE)) \
$$(BASE_TARGET_DIR)/ \
$$(TARGET_DIR)
+ifeq ($$(BR2_STRIP_strip),y)
+ $$(STRIP_FIND_CMD) | xargs -0 $$(STRIPCMD) 2>/dev/null || true
+ $$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $$(STRIPCMD) $$(STRIP_STRIP_DEBUG) 2>/dev/null || true
+endif
echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
echo "set -e" >> $$(FAKEROOT_SCRIPT)
diff --git a/package/Makefile.in b/package/Makefile.in
index dae7a85..a03312d 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -224,14 +224,9 @@ TARGET_READELF = $(TARGET_CROSS)readelf
TARGET_OBJCOPY = $(TARGET_CROSS)objcopy
TARGET_OBJDUMP = $(TARGET_CROSS)objdump
-ifeq ($(BR2_STRIP_strip),y)
STRIP_STRIP_DEBUG := --strip-debug
-TARGET_STRIP = $(TARGET_CROSS)strip
-STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
-else
TARGET_STRIP = /bin/true
-STRIPCMD = $(TARGET_STRIP)
-endif
+STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
INSTALL := $(shell which install || type -p install)
UNZIP := $(shell which unzip || type -p unzip) -q
--
2.17.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] fs: allow strip binaries when create rootfs
2021-11-10 19:00 ` Yann E. MORIN
2021-11-11 3:16 ` [Buildroot] 回复: " Tan Xiaofan
@ 2021-11-12 22:36 ` Thomas Petazzoni
2022-07-25 19:46 ` Arnout Vandecappelle
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2021-11-12 22:36 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Tan Xiaofan, buildroot@buildroot.org
On Wed, 10 Nov 2021 20:00:05 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> This is a simple approach to the problem, indeed. However, I think the
> choice is not needed: just keep the boolean option, and move the whole
> stripping out of target-finalize and into the fs creation step.
>
> Thoughts?
I'm not sure about this change. I understand that's it's an easy way to
have all binaries unstripped on the build machine, while having them
stripped on the target.
However, it makes $(TARGET_DIR) move further away from what will
actually end up on the target. I tend (and I guess a number of users as
well) to look at $(O)/target to see what my root filesystem looks like,
what it contains, etc. So all the post-processing steps that we add in
the root filesystem generation logic kind of "hides" this
post-processing from the eyes of the person looking at $(O)/target.
Furthermore, I believe this change is going to break "make size-stats",
because make size-stats looks at the size of files installed in
$(O)/target.
I think the long term idea instead was to install all packages to
STAGING_DIR, so that we have an unstripped installation of all packages.
Best regards,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] fs: allow strip binaries when create rootfs
2021-11-12 22:36 ` [Buildroot] " Thomas Petazzoni
@ 2022-07-25 19:46 ` Arnout Vandecappelle
0 siblings, 0 replies; 5+ messages in thread
From: Arnout Vandecappelle @ 2022-07-25 19:46 UTC (permalink / raw)
To: Thomas Petazzoni, Yann E. MORIN; +Cc: Tan Xiaofan, buildroot@buildroot.org
On 12/11/2021 23:36, Thomas Petazzoni wrote:
> On Wed, 10 Nov 2021 20:00:05 +0100
> "Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
>
>> This is a simple approach to the problem, indeed. However, I think the
>> choice is not needed: just keep the boolean option, and move the whole
>> stripping out of target-finalize and into the fs creation step.
We all agree that something needs to be done about the fact that you only have
unstripped programs in the build directory...
>>
>> Thoughts?
>
> I'm not sure about this change. I understand that's it's an easy way to
> have all binaries unstripped on the build machine, while having them
> stripped on the target.
>
> However, it makes $(TARGET_DIR) move further away from what will
> actually end up on the target. I tend (and I guess a number of users as
> well) to look at $(O)/target to see what my root filesystem looks like,
> what it contains, etc. So all the post-processing steps that we add in
> the root filesystem generation logic kind of "hides" this
> post-processing from the eyes of the person looking at $(O)/target.
>
> Furthermore, I believe this change is going to break "make size-stats",
> because make size-stats looks at the size of files installed in
> $(O)/target.
... but this is really a showstopper for the approach of this patch.
Therefore, I marked it as Rejected.
> I think the long term idea instead was to install all packages to
> STAGING_DIR, so that we have an unstripped installation of all packages.
That is really the way to go, but someone needs to work on it...
Regards,
Arnout
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-25 19:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-10 16:10 [Buildroot] [PATCH] fs: allow strip binaries when create rootfs Tan Xiaofan
2021-11-10 19:00 ` Yann E. MORIN
2021-11-11 3:16 ` [Buildroot] 回复: " Tan Xiaofan
2021-11-12 22:36 ` [Buildroot] " Thomas Petazzoni
2022-07-25 19:46 ` Arnout Vandecappelle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox