From patchwork Thu Apr 6 11:49:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yash Shinde X-Patchwork-Id: 80214 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp959569vqo; Thu, 6 Apr 2023 04:50:16 -0700 (PDT) X-Google-Smtp-Source: AKy350ald8UXeunGbVCRq7CdeI6MauLbrdSjzAyNM9whsD9BI52GzRprUXyU91c82U3i4Vc3OjYS X-Received: by 2002:a17:906:786:b0:932:c315:b0d with SMTP id l6-20020a170906078600b00932c3150b0dmr6191447ejc.34.1680781816475; Thu, 06 Apr 2023 04:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680781816; cv=none; d=google.com; s=arc-20160816; b=Bpp4JOJhwoamwkM2u9wPfI/WMgr40sy3bKTHZla4f1RzS0hnZilltQxCHmtDXjKjNS n/hXgg+zl/JhFlzTluk/Ts9fdUBCxhR0xwbLsRT/YetgAwh/8yksIjj3rrqLNiVpZjCh pMzfsmOM9r/wC1kD4lpNIs7s1Zr1VpEFvvvay23D3d9pl7yvhbcYsKbIpmL9DsTsByBD Rp0cnKhDRJu5NqMSeJMxoiimLsyVC6dBlTg0Bv9L4m4F+5W0y1QfBcO28hv6gqsuYYxd ZveO08xUnxKCrKlmTfscG2boclnJQfoA3LhB8NKSyXffYaCOe9+6pREWe9tY2Na2bUbv Fa6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Z8FKpJpid/lO7xgUxPYIjObYk0cH9fLtnpfVRCCJLPg=; b=CsTqortTNM4vSgO7ihYrpp2plS3s0ZoGQ12XkvBS/OwysS33M3tqy/G7NDIi9orrqr bE7MgWFwwL0b631+DQ0Ghu6PPhhOZZyjajpiUS9bsrX9tzMVxCmfMO3MaiNfoNVPfKtd b48MewVzasimx7gzt7XSIDGOtK6mNYIp8IG2sD0QBNLOPNw9U1ttjm+aWFZEM6ds2efv ok+ddP7JichUlPRAI8MfUzI4wGwFzApVhf8pjFItr0GZwnLgbPCWtb1ypTs/N6Gh+8HC iTBN2CByIKy+YzYfih8PfosuGf8phNalznPTHt3aGVxhUw1BPxavAAQe4dQRkaSNtEFM MuAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hgQ8GCx6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id un8-20020a170907cb8800b008da1e19114fsi1110664ejc.322.2023.04.06.04.50.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 04:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hgQ8GCx6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 205A83858433 for ; Thu, 6 Apr 2023 11:50:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 205A83858433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680781815; bh=Z8FKpJpid/lO7xgUxPYIjObYk0cH9fLtnpfVRCCJLPg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=hgQ8GCx6zdn/sMXVszPUPhgTaLQqxK8FEr61EBOswd55OeghuNwiaBVFsTbvdDBkf 7Jskb3E2Q2zdfzxD/wzHvc1Sh7/WX5XLsBN1ml7EPHHE1SuUx9A+VlXTUQ3zvSv3qL ZWc9c+rq55xQ2iiYZjwEkHn0b5LcDczV5NT9j/co= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 5105A3858D33 for ; Thu, 6 Apr 2023 11:49:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5105A3858D33 Received: by mail-pj1-x102a.google.com with SMTP id l7so36994244pjg.5 for ; Thu, 06 Apr 2023 04:49:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680781769; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z8FKpJpid/lO7xgUxPYIjObYk0cH9fLtnpfVRCCJLPg=; b=O5I/qUlgeXh7iIODoTyKqntvwGY/9TZaXIsD/8gpg0gY0bWJU0HZ/6xAJW0hN4wZmL D/Aa2Wd0fCfApXSYs7InelcA2NGXeUiCZGp3nQb+9fwbHsuhlDU4WgcFqHNcVgHQ5fCG ZtgusBezTypWl6styvGQ4yWHOlDDIDbMFyGjYAFwsHvzq4KLtmAGkKIkuo/B3y8qumyw mdY+zWFfb6sHxf/LKZZ1lclNroHZMeaQ94o6VQeFZn60+7+4hzzOtjvdrBXz14wfZrcY z4384AkzHWC8dQJMezhPUubbily1OaPp1zUiDXZlBB2kNwoIZhpzTBxx/XPlj5bF1DSH fhjg== X-Gm-Message-State: AAQBX9cbIL2tZ1o58yCXzBywryN1K97EfqIZ+a+fQVPjPHS97zdjoy+q vJfYibsFx6J5KMtIFIi4faSV+CpliFozDQ== X-Received: by 2002:a17:90b:3842:b0:23b:32e5:9036 with SMTP id nl2-20020a17090b384200b0023b32e59036mr10288531pjb.17.1680781768965; Thu, 06 Apr 2023 04:49:28 -0700 (PDT) Received: from bft-2.. ([49.204.85.206]) by smtp.gmail.com with ESMTPSA id v11-20020a170902b7cb00b0019a7d58e595sm1217024plz.143.2023.04.06.04.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 04:49:28 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: raj.khem@gmail.com, Yash.Shinde@windriver.com Subject: [PATCH] Search target sysroot gcc version specific dirs with multilib. Date: Thu, 6 Apr 2023 17:19:06 +0530 Message-Id: <20230406114906.3182600-1-yashinde145@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yash Shinde via Gcc-patches From: Yash Shinde Reply-To: Yash Shinde Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762427473997470292?= X-GMAIL-MSGID: =?utf-8?q?1762427473997470292?= From: Khem Raj We install the gcc libraries (such as crtbegin.p) into //5.2.0/ which is a default search path for GCC (aka multi_suffix in the code below). is 'machine' in gcc's terminology. We use these directories so that multiple gcc versions could in theory co-exist on target. We only want to build one gcc-cross-canadian per arch and have this work for all multilibs. can be handled by mapping the multilib to the one used by gcc-cross-canadian, e.g. mips64-polkmllib32-linux is symlinked to by mips64-poky-linux. The default gcc search path in the target sysroot for a "lib64" mutlilib is: /lib32/mips64-poky-linux/5.2.0/ /lib32/../lib64/ /usr/lib32/mips64-poky-linux/5.2.0/ /usr/lib32/../lib64/ /lib32/ /usr/lib32/ which means that the lib32 crtbegin.o will be found and the lib64 ones will not which leads to compiler failures. This patch injects a multilib version of that path first so the lib64 binaries can be found first. With this change the search path becomes: /lib32/../lib64/mips64-poky-linux/5.2.0/ /lib32/mips64-poky-linux/5.2.0/ /lib32/../lib64/ /usr/lib32/../lib64/mips64-poky-linux/5.2.0/ /usr/lib32/mips64-poky-linux/5.2.0/ /usr/lib32/../lib64/ /lib32/ /usr/lib32/ Signed-off-by: Khem Raj Signed-off-by: Yash Shinde --- gcc/gcc.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 16bb07f2cdc..4e5e3079804 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -2801,7 +2801,7 @@ for_each_path (const struct path_prefix *paths, if (path == NULL) { len = paths->max_len + extra_space + 1; - len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); + len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); path = XNEWVEC (char, len); } @@ -2813,6 +2813,33 @@ for_each_path (const struct path_prefix *paths, /* Look first in MACHINE/VERSION subdirectory. */ if (!skip_multi_dir) { + if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) + { + const char *this_multi; + size_t this_multi_len; + + if (pl->os_multilib) + { + this_multi = multi_os_dir; + this_multi_len = multi_os_dir_len; + } + else + { + this_multi = multi_dir; + this_multi_len = multi_dir_len; + } + + /* Look in multilib MACHINE/VERSION subdirectory first */ + if (this_multi_len) + { + memcpy (path + len, this_multi, this_multi_len + 1); + memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); + ret = callback (path, callback_info); + if (ret) + break; + } + } + memcpy (path + len, multi_suffix, suffix_len + 1); ret = callback (path, callback_info); if (ret)