Message ID | 1489989370-22377-1-git-send-email-ilya.kuzmich@gmail.com |
---|---|
State | Accepted |
Headers | show |
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
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
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
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
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
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
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(-)