From patchwork Fri Jan 22 15:05:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vicente Olivert Riera X-Patchwork-Id: 571708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id AA838140662 for ; Sat, 23 Jan 2016 02:06:11 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DC1118C172; Fri, 22 Jan 2016 15:06:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7D8f8pXDUsJ9; Fri, 22 Jan 2016 15:06:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 571CE8BF0E; Fri, 22 Jan 2016 15:06:06 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id C3EE61C11B8 for ; Fri, 22 Jan 2016 15:06:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B2D619491B for ; Fri, 22 Jan 2016 15:06:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NJfG7AijkK4s for ; Fri, 22 Jan 2016 15:06:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by hemlock.osuosl.org (Postfix) with ESMTP id 45C6C941DB for ; Fri, 22 Jan 2016 15:06:03 +0000 (UTC) Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Websense Email Security Gateway with ESMTPS id F34C15BC6246A; Fri, 22 Jan 2016 15:05:58 +0000 (GMT) Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 22 Jan 2016 15:06:01 +0000 Received: from vriera-linux.le.imgtec.org (192.168.154.36) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.210.2; Fri, 22 Jan 2016 15:06:00 +0000 From: Vicente Olivert Riera To: Date: Fri, 22 Jan 2016 15:05:55 +0000 Message-ID: <1453475155-49586-1-git-send-email-Vincent.Riera@imgtec.com> X-Mailer: git-send-email 2.4.10 MIME-Version: 1.0 X-Originating-IP: [192.168.154.36] Cc: thomas.petazzoni@free-electrons.com Subject: [Buildroot] [PATCH v2] toolchain: add a harmless link when sysroot detection is not accurate X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples: === Mentor Sourcery CodeBench toolchain $ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::' /toolchains/mips-2015.11/mips-linux-gnu/libc/ $ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::' /toolchains/mips-2015.11/mips-linux-gnu/libc/ === Codescape toolchain $ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::' /toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/ $ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB -print-file-name=libc.a) | sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::' /toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/ For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless. Signed-off-by: Vicente Olivert Riera --- Changes v1 -> v2: - Update the comment above the copy_toolchain_sysroot function. - Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni) toolchain/helpers.mk | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 70695ee..c8245f7 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -130,6 +130,12 @@ copy_toolchain_lib_root = \ # # * Create a symbolic link # +# If we are in the situation where we don't know if the sysroot layout +# is nested of side by side, we: +# +# * Create a symbolic link because it's harmless and is necessary for +# certain toolchains like Codescape for MIPS. +# # Finally, some toolchains (i.e Linaro binary toolchains) store # support libraries (libstdc++, libgcc_s) outside of the sysroot, so # we simply copy all the libraries from the "support lib directory" @@ -160,9 +166,12 @@ copy_toolchain_sysroot = \ done ; \ SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \ ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \ + echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \ + echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \ if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \ relpath="./" ; \ if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} == $${SYSROOT_DIR_CANON} ] ; then \ + echo "Nested sysroots detected." ; \ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \ cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \ fi ; \ @@ -174,9 +183,16 @@ copy_toolchain_sysroot = \ ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \ echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \ elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname $${SYSROOT_DIR_CANON}` ] ; then \ + echo "Side by side sysroots detected." ; \ ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \ echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \ fi ; \ + else \ + relpath="./" ; \ + echo "Unable to detect if sysroots are nested or side by side." ; \ + echo "Creating a harmless symlink necessary for certain toolchains." ; \ + ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \ + echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \ fi ; \ if test -n "$${SUPPORT_LIB_DIR}" ; then \ cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \