toolchain: handle toolchains with multiple ld*.so.* files
PATCH v3 1/1 toolchain: handle toolchains with multiple ld*.so.* files
Some 3rd party vendor toolchains have multiple files which match these glob patterns. In this case, the shell script failed. Switching to use find and xargs solves the issue.
---
Changes:
v2: add SOB
v3: fix usage of find
I moved away from -wholename, which seemed needlessly complex, and
instead I'm using just the base directory and -name. Tested with previously-failing ARM aarch64 external toolchain build.
toolchain/helpers.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
toolchain/helpers.mk +2 -4
@@ -135,10 +135,8 @@ copy_toolchain_sysroot = \ $(call simplify_symlink,$$i,$(STAGING_DIR)) ; \ done ; \ fi ; \ - if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \ - if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \ - cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \ - fi ; \ + if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \ + find $${ARCH_SYSROOT_DIR}/lib -name 'ld*.so.*' -print0 | xargs -0 -I % cp % $(STAGING_DIR)/lib/; \ fi ; \ if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 21 lines · Jonah Petri
Some 3rd party vendor toolchains have multiple files which match these glob patterns. In this case, the shell script failed. Switching to use find and xargs solves the issue.
Signed-off-by Jonah Petri <[email protected]>---
Changes:
v2: add SOB
v3: fix usage offind
I moved away from -wholename, which seemed needlessly complex, and
instead I'm using just the base directory and -name. Tested with previously-failing ARM aarch64 external toolchain build.toolchain/helpers.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)toolchain/helpers.mk +0
-0
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 138
Quoted 8 lines
toolchain/helpers.mk +1
-4@@ -135,10 +135,8 @@ copy_toolchain_sysroot = \ $(call simplify_symlink,$$i,$(STAGING_DIR)) ; \ done ; \ fi ; \ - if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \ - if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \ - cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \ - fi ; \ + if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \
I was going to say: don't use [[, it's a bashism. However, we already use it in
helpers.mk, so I guess it's OK. It's up to whoever has a problem with it to get rid of it :-)
Therefore, applied to next, thanks.
Regards,
Arnout
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 142
Quoted 5 lines
toolchain/helpers.mk +1
-0+ find $${ARCH_SYSROOT_DIR}/lib -name 'ld*.so.*' -print0 | xargs -0 -I % cp % $(STAGING_DIR)/lib/; \ fi ; \ if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 11 lines · Arnout Vandecappelle
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 138
Quoted 6 lines · Jonah Petri
fi ; \toolchain/helpers.mk +1
-4- if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \ - if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \ - cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \ - fi ; \ + if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \I was going to say: don't use [[, it's a bashism. However, we already use it in
helpers.mk, so I guess it's OK. It's up to whoever has a problem with it to get rid of it :-)
Quoted 1 line
Therefore, applied to next, thanks.
Thanks! I found it surprisingly hard to find a pleasing shell answer to "does this command succeed *and* output anything to stdout?" without invoking bashisms. I too was wary of using [[ before I saw the same usage lower in the file, and noted that bash is a prerequisite for buildroot in general. Hopefully some future dev won't curse me too much ☺ Thanks for applying!
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
Jonah, All,
On 2021-08-29 20:25 -0400, Jonah Petri spake thusly:
Quoted 11 lines · Arnout Vandecappelle
Quoted 10 lines · Jonah Petri
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 138
Quoted 6 lines
toolchain/helpers.mk +1
-4fi ; \ - if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \ - if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \ - cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \ - fi ; \ + if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \I was going to say: don't use [[, it's a bashism. However, we already use it in
helpers.mk, so I guess it's OK. It's up to whoever has a problem with it to get rid of it :-)
He! Don't say such things when I'm around! ;-)
Quoted 5 lines
Quoted 1 line
Therefore, applied to next, thanks.
Thanks! I found it surprisingly hard to find a pleasing shell answer to "does this command succeed *and* output anything to stdout?" without invoking bashisms.
This is a bit less concise (two lines instead of one), but it's still pretty easy, e.g. with a script that does not use 'set -e':
output="$( some-command )"
if [ ${?} -ne 0 -o -z "${output}" ]; then
echo "Failed or output nothing"
fiIf the script is using 'set -e', or one needs to differentiate the reason for failure, then it is a bit more involved, but still pretty easy and common:
output="$( some-command )" || ret="${?}"
if [ ${ret:-0} -ne 0 -o -z "${output}" ]; then
echo "Exited with ${ret:-0}, or output nothing"
fiIn our case, for Buildroot, we'd need to adapt the first solution:
[...] ; \
output="$$( some-command )"; \
if [ $${?} -ne 0 -o -z "$${output}" ]; then \
echo "Failed or output nothing"; \
fi; \
[...]Quoted 2 lines
I too was wary of using [[ before I saw the same usage lower in the file,
You caught me red-handed... I added that back in 4a5f878946c37... ;-]
Quoted 2 lines
and noted that bash is a prerequisite for buildroot in general.
And even then, I like that we avoid bashisms when possible. But in this case, well, it's acceptable and applied, so I won't whine (much). ;-)
Quoted 2 lines
Hopefully some future dev won't curse me too much ☺ Thanks for applying!
Well, TIL that one can do [[ ! $(cmd) ]] to test output and return code in one line, so... Thanks! :-)
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 23 lines · Yann E. MORIN
Jonah, All,
On 2021-08-29 20:25 -0400, Jonah Petri spake thusly:
Quoted 11 lines · Arnout Vandecappelle
Quoted 10 lines · Jonah Petri
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 138
Quoted 6 lines
toolchain/helpers.mk +1
-4fi ; \ - if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \ - if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \ - cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \ - fi ; \ + if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \I was going to say: don't use [[, it's a bashism. However, we already use it in
helpers.mk, so I guess it's OK. It's up to whoever has a problem with it to get rid of it :-)He! Don't say such things when I'm around! ;-)
Quoted 5 lines
Quoted 1 line
Therefore, applied to next, thanks.
Thanks! I found it surprisingly hard to find a pleasing shell answer to "does this command succeed *and* output anything to stdout?" without invoking bashisms.
Quoted 7 lines
This is a bit less concise (two lines instead of one), but it's still pretty easy, e.g. with a script that does not use 'set -e':
output="$( some-command )" if [ ${?} -ne 0 -o -z "${output}" ]; then echo "Failed or output nothing" fi
If you want concise (and covering all set -e cases AFAICS):
if ! output="$(some-command)" || [ -z "$output" ]; then ...
(as always: untested, YMMV)
Regards,
Arnout
Quoted 30 lines
If the script is using 'set -e', or one needs to differentiate the reason for failure, then it is a bit more involved, but still pretty easy and common:
output="$( some-command )" || ret="${?}" if [ ${ret:-0} -ne 0 -o -z "${output}" ]; then echo "Exited with ${ret:-0}, or output nothing" fiIn our case, for Buildroot, we'd need to adapt the first solution:
[...] ; \ output="$$( some-command )"; \ if [ $${?} -ne 0 -o -z "$${output}" ]; then \ echo "Failed or output nothing"; \ fi; \ [...]Quoted 2 lines
I too was wary of using [[ before I saw the same usage lower in the file,
You caught me red-handed... I added that back in
4a5f878946c37... ;-]Quoted 2 lines
and noted that bash is a prerequisite for buildroot in general.
And even then, I like that we avoid bashisms when possible. But in this case, well, it's acceptable and applied, so I won't whine (much). ;-)
Quoted 9 lines
Quoted 2 lines
Hopefully some future dev won't curse me too much ☺ Thanks for applying!
Well, TIL that one can do [[ ! $(cmd) ]] to test output and return code in one line, so... Thanks! :-)
Regards,
Yann E. MORIN.
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot