toolchain: Add support for Sourcery Codebench Standard
cover toolchain: Add support for Sourcery Codebench Standard
The purpose of this series is to provide support for Sourcery Codebench Standard (licenced) edition in Buildroot.
Since these toolchain can't be downloaded, we need to use the custom toolchain backend to import them into Buildroot.
In Toolchain menu, select:
Toolchain type (External toolchain)
Toolchain (Custom toolchain)
Toolchain origin (Pre-installed toolchain)
Then set all toolchain settings (kernel headers, libc, rpc, c++ etc...)
I'm using the Sourcery Codebench 2014.05 for IA32 GNU/Linux, here is the settings:
(i686-pc-linux-gnu) Toolchain prefix
External toolchain kernel headers series (3.13.x) External toolchain C library (glibc/eglibc)
[*] Toolchain has RPC support
[*] Toolchain has C++ support?
(-pipe -msgxx-glibc) Target Optimizations
The "-msgxx-glibc" flag in "Target Optimizations" is mandatory otherwise the toolchain won't work.
The toolchain-external infra need to be modified to handle a special case where all the libraries and headers are in the arch sysroot (sgxx-glibc).
Romain Naour (3):
toolchain-external: handle a special case where kernel headers check
needs TOOLCHAIN_EXTERNAL_CFLAGS
toolchain-external: handle a special case where glibc check needs
TOOLCHAIN_EXTERNAL_CFLAGS
toolchain-external: fix Sourcery Codebench symlink
toolchain/toolchain-external/toolchain-external.mk | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/3 toolchain-external: handle a special case where kernel headers check needs TOOLCHAIN_EXTERNAL_CFLAGS
With the Sourcery Codebench standard edition, the sysroot returned point to a non existant directory if no CFLAGS are specified.
Here are the results of -print-sysroot gcc option:
$ ./i686-pc-linux-gnu-gcc -print-sysroot Full/path/to/i686-pc-linux-gnu/libc/system32
$ ./i686-pc-linux-gnu-gcc -m64 -print-sysroot Full/path/to/i686-pc-linux-gnu/libc/system64
$ ./i686-pc-linux-gnu-gcc -msgxx-glibc -print-sysroot Full/path/to/i686-pc-linux-gnu/libc/sgxx-glibc
The problem is that in the "libc" directory there is only the sub-directory "sgxx-glibc".
Note: All hearders files and libraries are available in arch specific sysroot.
When using the -print-file-name gcc option, the result is quite buggy and it is not empty.
$ ./i686-pc-linux-gnu-gcc -print-file-name=libc.a libc.a
So the toolchain check fail because $PWD/libc.a is used as SYSROOT_DIR since the toolchain-external backend does not always use CFLAGS.
Add a test to use ARCH_SYSROOT_DIR for kernel headers check if SYSROOT_DIR is not a directory.
--- toolchain/toolchain-external/toolchain-external.mk | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
toolchain/toolchain-external/toolchain-external.mk +10 -3
@@ -454,9 +454,16 @@ define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS @echo "External toolchain doesn't support --sysroot. Cannot use." ; \ exit 1 ; \ fi ; \ - $(call check_kernel_headers_version,\ - $(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC)),\ - $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \ + ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \ + if test -d "$${SYSROOT_DIR}" ; then \ + $(call check_kernel_headers_version,\ + "$${SYSROOT_DIR}",\ + $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \ + else \ + $(call check_kernel_headers_version,\ + "$${ARCH_SYSROOT_DIR}",\ + $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \ + fi ; \ if test "$(BR2_arm)" = "y" ; then \ $(call check_arm_abi,\ "$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)",\
Signature · 1 line
1.9.3
PATCH 2/3 toolchain-external: handle a special case where glibc check needs TOOLCHAIN_EXTERNAL_CFLAGS
In reply to Romain NaourWith the Sourcery Codebench standard edition, the sysroot returned point to a non existant directory if no CFLAGS are specified.
Add a test to use ARCH_SYSROOT_DIR for glibc check if SYSROOT_DIR is not a directory.
--- toolchain/toolchain-external/toolchain-external.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
toolchain/toolchain-external/toolchain-external.mk +5 -1
@@ -477,7 +477,11 @@ define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \ $(call check_musl,$${SYSROOT_DIR}) ; \ else \ - $(call check_glibc,$${SYSROOT_DIR}) ; \ + if test -d "$${SYSROOT_DIR}" ; then \ + $(call check_glibc,$${SYSROOT_DIR}) ; \ + else \ + $(call check_glibc,$${ARCH_SYSROOT_DIR}) ; \ + fi \ fi endef
Signature · 1 line
1.9.3
PATCH 3/3 toolchain-external: fix Sourcery Codebench symlink
In reply to Romain NaourWith the Sourcery Codebench standard edition, the sysroot returned point to a non existant directory if no CFLAGS is specified.
When copying external toolchain sysroot to staging, we need to create the symbolic link that matches the name of the subdirectory for the architecture variant in the original sysroot (ie: sgxx-glibc)
To do that, SYSROOT_DIR must be different than ARCH_SYSROOT_DIR. So, set SYSROOT_DIR deduced from ARCH_SYSROOT_DIR by removing arch specific part at the end of the path.
--- toolchain/toolchain-external/toolchain-external.mk | 3 +++ 1 file changed, 3 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +3 -0
@@ -555,6 +555,9 @@ define TOOLCHAIN_EXTERNAL_INSTALL_CORE exit 1 ; \ fi ; \ ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \ + if test ! -d "$${SYSROOT_DIR}" ; then \ + SYSROOT_DIR=$$(echo -n "$${ARCH_SYSROOT_DIR}" | sed -r 's:(/libc/)([^&]*):\1:') ; \ + fi ; \ ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \ SUPPORT_LIB_DIR="" ; \ if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
Signature · 1 line
1.9.3
cover toolchain: Add support for Sourcery Codebench Standard
In reply to Romain NaourDear Romain Naour,
Quoted 5 lines · Romain Naour
The purpose of this series is to provide support for Sourcery Codebench Standard (licenced) edition in Buildroot.
Since these toolchain can't be downloaded, we need to use the custom toolchain backend to import them into Buildroot.
Thanks for this patch series. As we discussed today during the meeting, the currently proposed implementation is a bit fragile because:
* SYSROOT_DIR is empty/invalid in your situation, while most of the code assumes SYSROOT_DIR exists. While your patches make sure every time SYSROOT_DIR is used, we fallback to ARCH_SYSROOT_DIR if SYSROOT_DIR doesn't exist, this may break in the future, especially as we don't have access to this proprietary Sourcery Codebench toolchain to test and check that future changes will keep this toolchain working.
* the dance with faking a SYSROOT_DIR being different from ARCH_SYSROOT_DIR by one path component is really highly specific to this toolchain, and will not work in other situations.
Consequently, the proposal is to:
* Change the SYSROOT_DIR/ARCH_SYSROOT_DIR detection logic so that if SYSROOT_DIR is empty/bogus, then the same value as ARCH_SYSROOT_DIR is used. This ensures that both SYSROOT_DIR and ARCH_SYSROOT_DIR point to valid directories (which would the same in the case of this toolchain, which brings us back to the non-multilib toolchain case).
* Adjust the symlink logic to handle a new case: when SYSROOT_DIR == ARCH_SYSROOT_DIR, look again at the real sysroot directory, and if it's bogus, then it means we in fact have a multilib toolchain that may need a symbolic link. If that's the case, then using -print-sysroot with no flags, -print-sysroot with flags, and computing the common part of both paths, we get the "base sysroot".
Thinking about it, we might also think of using the strategy described above to find the "base sysroot" and use this value in SYSROOT_DIR, no?
In the mean time, I'll mark the three patches as Changes Requested in patchwork.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com