Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
@ 2017-03-20  5:56 Ilya Kuzmich
  2017-03-21 22:18 ` Thomas Petazzoni
  2017-03-26 19:41 ` Thomas Petazzoni
  0 siblings, 2 replies; 6+ messages in thread
From: Ilya Kuzmich @ 2017-03-20  5:56 UTC (permalink / raw)
  To: buildroot

Test whether musl used or not: compile minimal C program and check if
interpreter contains /lib/ld-musl.

Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>
---
 toolchain/helpers.mk                                   | 13 +++++++++----
 toolchain/toolchain-external/pkg-toolchain-external.mk |  4 +++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 2f73ebb..77303a8 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -197,13 +197,18 @@ check_glibc = \
 #
 # Check that the selected C library really is musl
 #
-# $1: sysroot directory
+# $1: cross-gcc path
+# $2: cross-readelf path
 check_musl = \
-	SYSROOT_DIR="$(strip $1)"; \
-	if test ! -f $${SYSROOT_DIR}/lib/libc.so -o -e $${SYSROOT_DIR}/lib/libm.so ; then \
+	__CROSS_CC=$(strip $1) ; \
+	__CROSS_READELF=$(strip $2) ; \
+	echo 'void main(void) {}' | $${__CROSS_CC} -x c -o $(BUILD_DIR)/.br-toolchain-test.tmp - >/dev/null 2>&1; \
+	if ! $${__CROSS_READELF} -l $(BUILD_DIR)/.br-toolchain-test.tmp 2> /dev/null | grep 'program interpreter: /lib/ld-musl' -q; then \
+		rm -f $(BUILD_DIR)/.br-toolchain-test.tmp*; \
 		echo "Incorrect selection of the C library" ; \
 		exit -1; \
-	fi
+	fi ; \
+	rm -f $(BUILD_DIR)/.br-toolchain-test.tmp*
 
 #
 # Check the conformity of Buildroot configuration with regard to the
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index 77b7bbb..8a774eb 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -565,7 +565,9 @@ define $(2)_CONFIGURE_CMDS
 	if test "$$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$$(call check_uclibc,$$$${SYSROOT_DIR}) ; \
 	elif test "$$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
-		$$(call check_musl,$$$${SYSROOT_DIR}) ; \
+		$$(call check_musl,\
+			"$$(TOOLCHAIN_EXTERNAL_CC) $$(TOOLCHAIN_EXTERNAL_CFLAGS)",\
+			$$(TOOLCHAIN_EXTERNAL_READELF)) ; \
 	else \
 		$$(call check_glibc,$$$${SYSROOT_DIR}) ; \
 	fi
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
  2017-03-20  5:56 [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check Ilya Kuzmich
@ 2017-03-21 22:18 ` Thomas Petazzoni
  2017-03-22  8:06   ` Ilya Kuzmich
  2017-03-26 19:41 ` Thomas Petazzoni
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2017-03-21 22:18 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 20 Mar 2017 08:56:10 +0300, Ilya Kuzmich wrote:
> Test whether musl used or not: compile minimal C program and check if
> interpreter contains /lib/ld-musl.
> 
> Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>

This doesn't look bad, but what is the motivation behind the change? Is
the current check not working for you?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
  2017-03-21 22:18 ` Thomas Petazzoni
@ 2017-03-22  8:06   ` Ilya Kuzmich
  2017-03-22  8:08     ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Ilya Kuzmich @ 2017-03-22  8:06 UTC (permalink / raw)
  To: buildroot

Current check fails on crosstool-ng musl toolchain,
ctng puts libc.so at sysroot/usr/lib/, not sysroot/lib

On 21/03, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 20 Mar 2017 08:56:10 +0300, Ilya Kuzmich wrote:
> > Test whether musl used or not: compile minimal C program and check if
> > interpreter contains /lib/ld-musl.
> > 
> > Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>
> 
> This doesn't look bad, but what is the motivation behind the change? Is
> the current check not working for you?
> 
> Thanks!
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
  2017-03-22  8:06   ` Ilya Kuzmich
@ 2017-03-22  8:08     ` Thomas Petazzoni
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2017-03-22  8:08 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 22 Mar 2017 11:06:51 +0300, Ilya Kuzmich wrote:
> Current check fails on crosstool-ng musl toolchain,
> ctng puts libc.so at sysroot/usr/lib/, not sysroot/lib

OK, thanks, makes sense. I'll update the commit log with this
explanation when applying.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
  2017-03-20  5:56 [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check Ilya Kuzmich
  2017-03-21 22:18 ` Thomas Petazzoni
@ 2017-03-26 19:41 ` Thomas Petazzoni
  2017-04-03 15:25   ` Ilya Kuzmich
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2017-03-26 19:41 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 20 Mar 2017 08:56:10 +0300, Ilya Kuzmich wrote:
> Test whether musl used or not: compile minimal C program and check if
> interpreter contains /lib/ld-musl.
> 
> Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>
> ---
>  toolchain/helpers.mk                                   | 13 +++++++++----
>  toolchain/toolchain-external/pkg-toolchain-external.mk |  4 +++-
>  2 files changed, 12 insertions(+), 5 deletions(-)

Applied to master, thanks. However, I had to make a preliminary fix
because TOOLCHAIN_EXTERNAL_READELF had a wrong value when Buildroot
external toolchains were used.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check
  2017-03-26 19:41 ` Thomas Petazzoni
@ 2017-04-03 15:25   ` Ilya Kuzmich
  0 siblings, 0 replies; 6+ messages in thread
From: Ilya Kuzmich @ 2017-04-03 15:25 UTC (permalink / raw)
  To: buildroot

Turns out this is not an end to the story.

TOOLCHAIN_EXTERNAL_MUSL_LD_LINK @ pkg-toolchain-external.mk assumes that
there is a /lib/libc.so. This is not a case for ct-ng musl toolchain.
Ct-ng does this: sysroot/lib/ld-musl-armhf.so.1 -> ../usr/lib/libc.so

How do i fix this?
I've poked around pkg-toolchain-external.mk, but to no avail.

On 26/03, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 20 Mar 2017 08:56:10 +0300, Ilya Kuzmich wrote:
> > Test whether musl used or not: compile minimal C program and check if
> > interpreter contains /lib/ld-musl.
> > 
> > Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>
> > ---
> >  toolchain/helpers.mk                                   | 13 +++++++++----
> >  toolchain/toolchain-external/pkg-toolchain-external.mk |  4 +++-
> >  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> Applied to master, thanks. However, I had to make a preliminary fix
> because TOOLCHAIN_EXTERNAL_READELF had a wrong value when Buildroot
> external toolchains were used.
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-03 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20  5:56 [Buildroot] [PATCH 1/1] toolchain-external: improve musl external check Ilya Kuzmich
2017-03-21 22:18 ` Thomas Petazzoni
2017-03-22  8:06   ` Ilya Kuzmich
2017-03-22  8:08     ` Thomas Petazzoni
2017-03-26 19:41 ` Thomas Petazzoni
2017-04-03 15:25   ` Ilya Kuzmich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox