Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] Makefile: respect strip exclusions for special libraries
Date: Mon, 2 Jul 2018 18:40:44 +0200	[thread overview]
Message-ID: <20180702164044.GD2604@scaer> (raw)
In-Reply-To: <20180702160027.28557-1-john@metanate.com>

John, All,

On 2018-07-02 17:00 +0100, John Keeping spake thusly:
> 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.
> 
> Instead of running one-off commands to strip each of these special
> binaries, build a single command for everything that needs
> $(STRIP_STRIP_DEBUG) and include the normal exclusion rules in this
> command.
> 
> Signed-off-by: John Keeping <john@metanate.com>
> ---
>  Makefile | 32 +++++++++++++++++++++-----------
>  1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 8d25c8a239..2deb5fd54a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -606,6 +606,26 @@ STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
>  #   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
>  
> +# This is the command used to handle the special cases above.
> +STRIP_SPECIAL_LIBS_CMD = find $(TARGET_DIR)/lib/
> +ifneq (,$(filter lib/%,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))))
> +STRIP_SPECIAL_LIBS_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(BR2_STRIP_EXCLUDE_DIRS)) \) -prune -o
> +endif
> +# Valgrind needs ld.so with enough information, so only strip
> +# debugging symbols.
> +STRIP_SPECIAL_LIBS_CMD += \( -name 'ld-*.so*'
> +ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
> +# 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"
> +STRIP_SPECIAL_LIBS_CMD += -o -name 'libpthread*.so*'
> +endif
> +STRIP_SPECIAL_LIBS_CMD += \)
> +ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)))
> +STRIP_SPECIAL_LIBS_CMD += -not \( $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)) \)

I guess you forgot to use 'findfileclauses' here, that is:

    STRIP_SPECIAL_LIBS_CMD += -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \)

Otherwise, expansion of the variable would give an invalide find
pattern, like so:

    -not \( some-excluded-file some-other-file a-tird-file \)

Or did I miss something?

Regards,
Yann E. MORIN.

> +endif
> +STRIP_SPECIAL_LIBS_CMD += | xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
> +
>  ifeq ($(BR2_ECLIPSE_REGISTER),y)
>  define TOOLCHAIN_ECLIPSE_REGISTER
>  	./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
> @@ -717,18 +737,8 @@ endif
>  	rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
>  	$(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 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
> +	$(STRIP_SPECIAL_LIBS_CMD) || true
>  
> -# 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 && \
> -- 
> 2.18.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  reply	other threads:[~2018-07-02 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 16:00 [Buildroot] [PATCH] Makefile: respect strip exclusions for special libraries John Keeping
2018-07-02 16:40 ` Yann E. MORIN [this message]
2018-07-02 16:57   ` [Buildroot] [PATCH v2] " John Keeping
2018-07-02 20:25     ` Thomas Petazzoni
2018-07-02 21:04       ` Yann E. MORIN
2018-07-03 10:06       ` [Buildroot] [PATCH v3] " John Keeping
2018-07-10 15:56         ` Matthew Weber
2019-02-04 15:57         ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180702164044.GD2604@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox