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

login
register
mail settings
Submitter Richard Tollerton
Date July 3, 2014, 10 p.m.
Message ID <1404424826-12023-2-git-send-email-rich.tollerton@ni.com>
Download mbox | patch
Permalink /patch/74975/
State New
Headers show

Comments

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
defined(TARGET_SYSTEM_ROOT_RELOCATABLE), and
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 <gratian.crisan@ni.com>
Acked-by: David Curtiss <david.curtiss@ni.com>
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
---
 meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-cross-canadian.inc b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
index 63adae8..1a826ec 100644
--- a/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
@@ -37,6 +37,9 @@  export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
 export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
 export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
 
+# 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
 #