* [Buildroot] [git commit] Makefile: respect strip exclusions for special libraries
@ 2019-02-04 15:56 Thomas Petazzoni
2019-02-04 18:58 ` Matthew Weber
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2019-02-04 15:56 UTC (permalink / raw)
To: buildroot
commit: https://git.buildroot.net/buildroot/commit/?id=e5e0f637aba9e926c0420ce6e343b734b968d883
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
ld-*.so and libpthread*.so* are not stripped in the same way as other
binaries because some applications need symbols in these libraries in
order to operate correctly.
However, the special handling for these binaries ignores the usual
BR2_STRIP_EXCLUDE_* rules so it is not possible to build an image which
has debugging symbols in these binaries.
Pull out the common find functionality so that we can build two find
commands that re-use the common exclusion rules.
Fix-suggested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: John Keeping <john@metanate.com>
Tested-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
Makefile | 46 ++++++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
index 74240ab895..355a404e04 100644
--- a/Makefile
+++ b/Makefile
@@ -613,20 +613,37 @@ RSYNC_VCS_EXCLUSIONS = \
--exclude .svn --exclude .git --exclude .hg --exclude .bzr \
--exclude CVS
-STRIP_FIND_CMD = find $(TARGET_DIR)
-ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
-STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
-endif
-STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
-# file exclusions:
+# When stripping, obey to BR2_STRIP_EXCLUDE_DIRS and
+# BR2_STRIP_EXCLUDE_FILES
+STRIP_FIND_COMMON_CMD = \
+ find $(TARGET_DIR) \
+ $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)), \
+ \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) \
+ -prune -o \
+ ) \
+ $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
+ -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) )
+
+# Regular stripping for everything, except libpthread, ld-*.so and
+# kernel modules:
# - libpthread.so: a non-stripped libpthread shared library is needed for
# proper debugging of pthread programs using gdb.
# - ld.so: a non-stripped dynamic linker library is needed for valgrind
# - kernel modules (*.ko): do not function properly when stripped like normal
# applications and libraries. Normally kernel modules are already excluded
-# by the executable permission check above, so the explicit exclusion is only
+# by the executable permission check, so the explicit exclusion is only
# done for kernel modules with incorrect permissions.
-STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
+STRIP_FIND_CMD = \
+ $(STRIP_FIND_COMMON_CMD) \
+ -type f \( -perm /111 -o -name '*.so*' \) \
+ -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko) \) \
+ -print0
+
+# Special stripping (only debugging symbols) for libpthread and ld-*.so.
+STRIP_FIND_SPECIAL_LIBS_CMD = \
+ $(STRIP_FIND_COMMON_CMD) \
+ \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \
+ -print0
ifeq ($(BR2_ECLIPSE_REGISTER),y)
define TOOLCHAIN_ECLIPSE_REGISTER
@@ -744,19 +761,8 @@ endif
rm -rf $(TARGET_DIR)/usr/share/gtk-doc
rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
$(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
-# See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
-# besides the one in which crash occurred; or SIGTRAP kills my program when
-# I set a breakpoint"
-ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
- find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
- xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
-endif
-
-# Valgrind needs ld.so with enough information, so only strip
-# debugging symbols.
- find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
- xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
test -f $(TARGET_DIR)/etc/ld.so.conf && \
{ echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
^ permalink raw reply related [flat|nested] 3+ messages in thread* [Buildroot] [git commit] Makefile: respect strip exclusions for special libraries
2019-02-04 15:56 [Buildroot] [git commit] Makefile: respect strip exclusions for special libraries Thomas Petazzoni
@ 2019-02-04 18:58 ` Matthew Weber
2019-02-04 20:06 ` Thomas Petazzoni
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Weber @ 2019-02-04 18:58 UTC (permalink / raw)
To: buildroot
Thomas,
On Mon, Feb 4, 2019 at 9:57 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> commit: https://git.buildroot.net/buildroot/commit/?id=e5e0f637aba9e926c0420ce6e343b734b968d883
> branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
>
> ld-*.so and libpthread*.so* are not stripped in the same way as other
> binaries because some applications need symbols in these libraries in
> order to operate correctly.
>
> However, the special handling for these binaries ignores the usual
> BR2_STRIP_EXCLUDE_* rules so it is not possible to build an image which
> has debugging symbols in these binaries.
>
> Pull out the common find functionality so that we can build two find
> commands that re-use the common exclusion rules.
>
> Fix-suggested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: John Keeping <john@metanate.com>
> Tested-by: Matt Weber <matthew.weber@rockwellcollins.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> ---
> Makefile | 46 ++++++++++++++++++++++++++--------------------
> 1 file changed, 26 insertions(+), 20 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 74240ab895..355a404e04 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -613,20 +613,37 @@ RSYNC_VCS_EXCLUSIONS = \
> --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
> --exclude CVS
>
> -STRIP_FIND_CMD = find $(TARGET_DIR)
> -ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
> -STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
> -endif
> -STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
> -# file exclusions:
> +# When stripping, obey to BR2_STRIP_EXCLUDE_DIRS and
> +# BR2_STRIP_EXCLUDE_FILES
> +STRIP_FIND_COMMON_CMD = \
> + find $(TARGET_DIR) \
> + $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)), \
> + \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) \
> + -prune -o \
> + ) \
> + $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
> + -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) )
> +
> +# Regular stripping for everything, except libpthread, ld-*.so and
> +# kernel modules:
> # - libpthread.so: a non-stripped libpthread shared library is needed for
> # proper debugging of pthread programs using gdb.
> # - ld.so: a non-stripped dynamic linker library is needed for valgrind
> # - kernel modules (*.ko): do not function properly when stripped like normal
> # applications and libraries. Normally kernel modules are already excluded
> -# by the executable permission check above, so the explicit exclusion is only
> +# by the executable permission check, so the explicit exclusion is only
> # done for kernel modules with incorrect permissions.
> -STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
> +STRIP_FIND_CMD = \
> + $(STRIP_FIND_COMMON_CMD) \
> + -type f \( -perm /111 -o -name '*.so*' \) \
> + -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko) \) \
> + -print0
> +
> +# Special stripping (only debugging symbols) for libpthread and ld-*.so.
> +STRIP_FIND_SPECIAL_LIBS_CMD = \
> + $(STRIP_FIND_COMMON_CMD) \
> + \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \
The answer to you question about needing to strip libpthread for only
glibc is true. I did poke around a bit and checked if libthread_db
needed symbols and verified it can be stripped. Do you think a noted
should be added to state the libpthread stripping detail?
Matt
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [git commit] Makefile: respect strip exclusions for special libraries
2019-02-04 18:58 ` Matthew Weber
@ 2019-02-04 20:06 ` Thomas Petazzoni
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2019-02-04 20:06 UTC (permalink / raw)
To: buildroot
On Mon, 4 Feb 2019 12:58:08 -0600
Matthew Weber <matthew.weber@collins.com> wrote:
> > +# Special stripping (only debugging symbols) for libpthread and ld-*.so.
> > +STRIP_FIND_SPECIAL_LIBS_CMD = \
> > + $(STRIP_FIND_COMMON_CMD) \
> > + \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \
>
> The answer to you question about needing to strip libpthread for only
> glibc is true. I did poke around a bit and checked if libthread_db
> needed symbols and verified it can be stripped. Do you think a noted
> should be added to state the libpthread stripping detail?
So basically thread debugging on musl/uclibc works even if libc.so is
stripped ?
In any case, thanks for you investigation on this. I'm not sure adding
a note here is really useful: uclibc/musl simply don't have any
libpthread, and it's OK to not do anything special for uclibc/musl here.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-04 20:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-04 15:56 [Buildroot] [git commit] Makefile: respect strip exclusions for special libraries Thomas Petazzoni
2019-02-04 18:58 ` Matthew Weber
2019-02-04 20:06 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox