mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Bernhard Walle <bernhard@bwalle.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] Fix (host) gcc wrapper on Gentoo Linux
Date: Fri, 22 Mar 2013 12:27:54 +0100	[thread overview]
Message-ID: <1363951674-14651-1-git-send-email-bernhard@bwalle.de> (raw)

On Gentoo, the host compiler can only be executed if basename(argv[0])
is 'gcc' (or 'g++' etc.), not if it's 'gcc.real'. Then it invokes
gcc-config and fails:

 | % ln -s /usr/bin/gcc gcc.real
 | % ./gcc.real --version
 |
 |  * gcc-config: Could not get portage CHOST!
 |  * gcc-config: You should verify that CHOST is set in one of these places:
 |  * gcc-config:  - //etc/portage/make.conf
 |  * gcc-config:  - active environment
 | gcc-config: error: could not get compiler binary path: No such file or directory

I'm not a Gentoo expert (I'm just forced to use it for that purpose ;-)),
so I cannot explain further details.

This patch makes ptxdist working on Gentoo by changing the symbolic link
from <name>.real to real/<name>, i.e. moving the final toolchain symlink
to some other directory, keeping the basename.

It only changes that for the host compiler since a (usually manually
built) cross-compiler doesn't have that problem.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 bin/ptxdist                   | 5 +++--
 scripts/wrapper/libwrapper.sh | 9 ++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/ptxdist b/bin/ptxdist
index 95382e6..a6317bf 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -588,12 +588,13 @@ check_compiler() {
 			;;
 		esac
 
-		ln -sf "${cc_abs}" "${PTX_WRAPPER_DIR}/${cc_default}.real" &&
+		[ -d "${PTX_WRAPPER_DIR}/real" ] || mkdir "${PTX_WRAPPER_DIR}/real"
+		ln -sf "${cc_abs}" "${PTX_WRAPPER_DIR}/real/${cc_default}" &&
 		ln -sf "${SCRIPTSDIR}/wrapper/host-${cc_default}-wrapper" "${PTX_WRAPPER_DIR}/${cc_default}" &&
 
 		if [ -n "${cc_alternate}" ]; then
 		    ln -sf "${cc_default}" "${PTX_WRAPPER_DIR}/${cc_alternate}" &&
-		    ln -sf "${cc_default}.real" "${PTX_WRAPPER_DIR}/${cc_alternate}.real"
+		    ln -sf "${cc_default}" "${PTX_WRAPPER_DIR}/real/${cc_alternate}"
 		fi || \
 		    ptxd_bailout "unable to create compiler wrapper link"
 	done
diff --git a/scripts/wrapper/libwrapper.sh b/scripts/wrapper/libwrapper.sh
index f376f7f..adf2f08 100644
--- a/scripts/wrapper/libwrapper.sh
+++ b/scripts/wrapper/libwrapper.sh
@@ -21,10 +21,17 @@ fi
 . ${PTXDIST_PLATFORMCONFIG}
 
 wrapper_exec() {
+	local compiler_link
 	if [ "${PTXDIST_VERBOSE}" = 1 -a -n "${PTXDIST_FD_LOGFILE}" ]; then
 		echo "wrapper: ${PTXDIST_CCACHE} ${0##*/} ${ARG_LIST} $* ${LATE_ARG_LIST}" >&${PTXDIST_FD_LOGFILE}
 	fi
-	exec ${PTXDIST_CCACHE} $0.real ${ARG_LIST} "$@" ${LATE_ARG_LIST}
+	for c in $0.real "$(dirname $0)/real/$(basename $0)" ; do
+		if [ -x "$c" ] ; then
+			compiler_link="$c"
+			break
+		fi
+	done
+	exec ${PTXDIST_CCACHE} "$compiler_link" ${ARG_LIST} "$@" ${LATE_ARG_LIST}
 }
 
 cc_check_args() {
-- 
1.8.2


-- 
ptxdist mailing list
ptxdist@pengutronix.de

             reply	other threads:[~2013-03-22 11:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22 11:27 Bernhard Walle [this message]
2013-03-22 14:17 ` Marc Kleine-Budde
2013-03-22 14:31   ` Bernhard Walle
2013-03-22 14:33     ` Marc Kleine-Budde
2013-03-22 14:44     ` Michael Olbrich
2013-03-22 15:18       ` Bernhard Walle
2013-03-22 17:12         ` Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363951674-14651-1-git-send-email-bernhard@bwalle.de \
    --to=bernhard@bwalle.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox