toolchain-external: improve musl external check
PATCH 1/1 toolchain-external: improve musl external check
Test whether musl used or not: compile minimal C program and check if interpreter contains /lib/ld-musl.
--- toolchain/helpers.mk | 13 +++++++++---- toolchain/toolchain-external/pkg-toolchain-external.mk | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-)
toolchain/helpers.mk +9 -4
@@ -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
toolchain/toolchain-external/pkg-toolchain-external.mk +3 -1
@@ -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
Signature · 1 line
2.7.4
PATCH 1/1 toolchain-external: improve musl external check
Hello,
Quoted 4 lines · Ilya Kuzmich
Test whether musl used or not: compile minimal C program and check if interpreter contains
/lib/ld-musl.Signed-off-by Ilya Kuzmich <[email protected]>
This doesn't look bad, but what is the motivation behind the change? Is the current check not working for you?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/1 toolchain-external: improve musl external check
Current check fails on crosstool-ng musl toolchain, ctng puts libc.so at sysroot/usr/lib/, not sysroot/lib
Quoted 18 lines · Thomas Petazzoni
Hello,
Quoted 4 lines · Ilya Kuzmich
Test whether musl used or not: compile minimal C program and check if interpreter contains
/lib/ld-musl.Signed-off-by Ilya Kuzmich <[email protected]>This doesn't look bad, but what is the motivation behind the change? Is the current check not working for you?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/1 toolchain-external: improve musl external check
Hello,
Quoted 2 lines · Ilya Kuzmich
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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Thomas Petazzoni
AppliedPATCH 1/1 toolchain-external: improve musl external check
In reply to Ilya KuzmichHello,
Quoted 8 lines · Ilya Kuzmich
Test whether musl used or not: compile minimal C program and check if interpreter contains
/lib/ld-musl.Signed-off-by Ilya Kuzmich <[email protected]>--- 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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 toolchain-external: improve musl external check
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.
Quoted 21 lines · Thomas Petazzoni
Hello,
Quoted 8 lines · Ilya Kuzmich
Test whether musl used or not: compile minimal C program and check if interpreter contains
/lib/ld-musl.Signed-off-by Ilya Kuzmich <[email protected]>--- 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_READELFhad a wrong value when Buildroot external toolchains were used.Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com