toolchain-external.mk: fix ARCH_SUBDIR for side-by-side sysroot toolchains
PATCH 1/1 toolchain-external.mk: fix ARCH_SUBDIR for side-by-side sysroot toolchains
ARCH_SUBDIR is computed based on the value of ARCH_SYSROOT_DIR and SYSROOT_DIR. For nested toolchains ARCH_SYSROOT_DIR is a subdir of SYSROOT_DIR, so a sed command like this one...
sed -r -e "s:^${SYSROOT_DIR}(.*)/$:\1:"...basically removes the leading SYSROOT_DIR part from ARCH_SYSROOT_DIR.
But, for side-by-side sysroot toolchains ARCH_SYSROOT_DIR and SYSROOT_DIR are at the same level, so the above sed command doesn't make any effect. This patch detects that situation and uses an appropriate sed command for it.
--- toolchain/toolchain-external/toolchain-external.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
toolchain/toolchain-external/toolchain-external.mk +6 -1
@@ -665,7 +665,12 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \ fi ; \ fi ; \ - ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + if [ "`dirname $${ARCH_SYSROOT_DIR}`" = "`dirname $${SYSROOT_DIR}`" ] ; then \ + SYSROOT_DIR_DIRNAME=`dirname $${SYSROOT_DIR}`/ ; \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR_DIRNAME}(.*)/$$:\1:"` ; \ + else \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + fi ; \ $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \ $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) endef
Signature · 1 line
2.10.1
PATCH 1/1 toolchain-external.mk: fix ARCH_SUBDIR for side-by-side sysroot toolchains
Vicente, All,
On 2016-10-27 16:33 +0100, Vicente Olivert Riera spake thusly:
Quoted 4 lines
ARCH_SUBDIRis computed based on the value ofARCH_SYSROOT_DIRandSYSROOT_DIR. For nested toolchainsARCH_SYSROOT_DIRis a subdir ofSYSROOT_DIR, so a sed command like this one...
Quoted 8 lines
sed -r -e "s:^${SYSROOT_DIR}(.*)/$:\1:"...basically removes the leading
SYSROOT_DIRpart fromARCH_SYSROOT_DIR.But, for side-by-side sysroot toolchains
ARCH_SYSROOT_DIRandSYSROOT_DIRare at the same level, so the above sed command doesn't make any effect. This patch detects that situation and uses an appropriate sed command for it.
As discussed on IRC, there was a previous patch of mine on the topic:
https://patchwork.ozlabs.org/patch/627505/
I did not yet send v2 of that patch:
https://git.buildroot.org/~ymorin/git/buildroot/commit/?h=yem/ext-toolchain-fixes&id=30ab28ce467b7d7dea5e181cae69ae882f936e98
I'll send it shortly so we can compare the two and decide which is best.
Regards,
Yann E. MORIN.
Quoted 30 lines
Signed-off-by Vicente Olivert Riera <[email protected]>--- toolchain/toolchain-external/toolchain-external.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)toolchain/toolchain-external/toolchain-external.mk +6
-1@@ -665,7 +665,12 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \ fi ; \ fi ; \ - ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + if [ "`dirname $${ARCH_SYSROOT_DIR}`" = "`dirname $${SYSROOT_DIR}`" ] ; then \ + SYSROOT_DIR_DIRNAME=`dirname $${SYSROOT_DIR}`/ ; \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR_DIRNAME}(.*)/$$:\1:"` ; \ + else \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + fi ; \ $(call MESSAGE,"Copying external toolchain sysroot to staging...") ; \ $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) endefSignature · 6 lines
2.10.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 toolchain-external.mk: fix ARCH_SUBDIR for side-by-side sysroot toolchains
In reply to Vicente Olivert RieraHello,
Quoted 5 lines · Vicente Olivert Riera
toolchain/toolchain-external/toolchain-external.mk +0
-0
toolchain/toolchain-external/toolchain-external.mk define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS · line 673
Quoted 10 lines
toolchain/toolchain-external/toolchain-external.mk +6
-1@@ -665,7 +665,12 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS SUPPORT_LIB_DIR=`readlink -f $${LIBSTDCPP_A_LOCATION} | sed -r -e 's:libstdc\+\+\.a::'` ; \ fi ; \ fi ; \ - ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + if [ "`dirname $${ARCH_SYSROOT_DIR}`" = "`dirname $${SYSROOT_DIR}`" ] ; then \ + SYSROOT_DIR_DIRNAME=`dirname $${SYSROOT_DIR}`/ ; \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR_DIRNAME}(.*)/$$:\1:"` ; \ + else \ + ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \ + fi ; \
I've applied your patch, which I have slightly improved to handle the SYSROOT_DIR == ARCH_SYSROOT_DIR case, where ARCH_SUBDIR should be empty. This way, I believe we handle all three cases:
1. SYSROOT_DIR == ARCH_SYSROOT_DIR
2. SYSROOT_DIR and ARCH_SYSROOT_DIR are side-by-side
3. ARCH_SYSROOT_DIR is nested in SYSROOT_DIR
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com