Patchwork [1/2] gcc-cross-canadian: Adjust $prefix to fix sysroot autodetect

mail settings
Submitter Richard Tollerton
Date July 3, 2014, 10 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/74975/
State New
Headers show


Richard Tollerton - July 3, 2014, 10 p.m.
Currently, using gcc-cross-canadian often requires --sysroot to be
specified at compile time, because the default sysroot is hardcoded to
e.g. /opt/poky/1.6.1/sysroots/core2-64-poky-linux. If you didn't install
the toolchain in precisely that location, the default sysroot won't work.

But that isn't actually necessary -- gcc is actually capable of
discovering the sysroot location itself. If the default
sysroot (--with-sysroot=) is underneath the prefix (--prefix=), then gcc
rewrites the sysroot at runtime based on the actual location of gcc in
the filesystem. (cf gcc/gcc.c:process_command() in the
libiberty/make-relative-prefix.c, in the gcc sources.)

We can effect this by moving prefix up a few directories.
Currently it's effectively set to ${SDKPATH}/sysroots/${SDK_SYS}/usr,
via nativesdk.bbclass. So instead, set it to ${SDKPATH}/sysroots.
This breaks nothing, because autotools.bbclass already sets
exec_prefix, bindir, etc. so that this change should not actually affect
where files get installed.

Natinst-ReviewBoard-ID: 52189
Acked-by: Gratian Crisan <>
Acked-by: David Curtiss <>
Signed-off-by: Richard Tollerton <>
 meta/recipes-devtools/gcc/ | 3 +++
 1 file changed, 3 insertions(+)


diff --git a/meta/recipes-devtools/gcc/ b/meta/recipes-devtools/gcc/
index 63adae8..1a826ec 100644
--- a/meta/recipes-devtools/gcc/
+++ b/meta/recipes-devtools/gcc/
@@ -37,6 +37,9 @@  export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
+# Ensure that the target sysroot is under the prefix
+prefix = "${SDKPATH}/sysroots"
 # We need to override this and make sure the compiler can find staging