From 6f376106809ac1b58d8dca8d718a0d835b86edf1 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Fri, 18 Jul 2014 16:03:21 -0700 Subject: [PATCH 1/2] Revert "Merge pull request #36 from MentorEmbedded/sb-1905" This reverts commit f901bfd0980267f8a2a8c6c164b8ffbcbe0a1a7d, reversing changes made to 69d2f98edaf42fa48641ef32794faca7636b9132. cs-license & friends don't obey TMPDIR, so this workaround had no useful effect for our builds. --- .../include/tcmode-external-sourcery.inc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/conf/distro/include/tcmode-external-sourcery.inc b/conf/distro/include/tcmode-external-sourcery.inc index 9f51654..e761251 100644 --- a/conf/distro/include/tcmode-external-sourcery.inc +++ b/conf/distro/include/tcmode-external-sourcery.inc @@ -156,23 +156,17 @@ def populate_toolchain_links(d): if not files: bb.fatal("Unable to populate toolchain binary symlinks in %s" % pattern) - - origenv = d.getVar('BB_ORIGENV', False) - logname = origenv.get('LOGNAME', 'unknown') - tmpdir = os.path.join(origenv.get('TMPDIR', '/tmp'), 'sourcery-%s' % logname) - bb.utils.mkdirhier(tmpdir) - bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) bb.utils.mkdirhier(bindir) for f in files: base = os.path.basename(f) newpath = os.path.join(bindir, base) - if not os.path.exists(newpath): - with open(newpath, 'w') as new: - new.write('#!/bin/sh\n') - new.write('export TMPDIR="{0}"\n'.format(tmpdir)) - new.write('exec "{0}" "$@"\n'.format(f)) - os.fchmod(new.fileno(), 0755) + try: + os.symlink(f, newpath) + except OSError as exc: + if exc.errno == errno.EEXIST: + break + bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) # Ensure that we have a ld.bfd available, now that KERNEL_LD uses it ld = d.expand('${TARGET_PREFIX}ld') From e7c5f947bf1d313f669d924909a232b86b696be1 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Thu, 10 Apr 2014 08:15:22 -0700 Subject: [PATCH 2/2] tcmode: disable pseudo for gcc/g++/cpp The sourcery toolchain writes temporary files to /tmp, and includes the username. If multiple users are doing builds with pseudo enabled, it'll try to write to the other user's file, since both will use 'root', and the build will fail as a result. We don't want to wrap all the toolcahin binaries, as they don't all call the tools which write these lockfiles, and objcopy has to be excluded, as it modifies installed binaries when the packaging process splits out the debug info. If that operation occurs outside of pseudo's knowledge, Bad Things will happen. JIRA: MEIP-393, SB-1905 Signed-off-by: Christopher Larson --- .../include/tcmode-external-sourcery.inc | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/conf/distro/include/tcmode-external-sourcery.inc b/conf/distro/include/tcmode-external-sourcery.inc index e761251..5102366 100644 --- a/conf/distro/include/tcmode-external-sourcery.inc +++ b/conf/distro/include/tcmode-external-sourcery.inc @@ -158,15 +158,24 @@ def populate_toolchain_links(d): bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) bb.utils.mkdirhier(bindir) + wrapped = ['gcc', 'g++', 'cpp'] for f in files: base = os.path.basename(f) newpath = os.path.join(bindir, base) - try: - os.symlink(f, newpath) - except OSError as exc: - if exc.errno == errno.EEXIST: - break - bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) + if not os.path.exists(newpath): + if any(base.endswith(w) for w in wrapped): + with open(newpath, 'w') as new: + new.write('#!/bin/sh\n') + new.write('export PSEUDO_UNLOAD=1\n') + new.write('exec {0} "$@"\n'.format(f)) + os.chmod(newpath, 0755) + else: + try: + os.symlink(f, newpath) + except OSError as exc: + if exc.errno == errno.EEXIST: + break + bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) # Ensure that we have a ld.bfd available, now that KERNEL_LD uses it ld = d.expand('${TARGET_PREFIX}ld')