From patchwork Wed Mar 1 11:35:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 62854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3578739wrd; Wed, 1 Mar 2023 03:36:33 -0800 (PST) X-Google-Smtp-Source: AK7set+CusklU2ofwWdrxzqF5yjucw7vMv/f8lzWfwgMnJn6HL/v0dbSVTznQVHf5OyEvgwGqf6u X-Received: by 2002:a17:906:cc58:b0:878:7f6e:38a7 with SMTP id mm24-20020a170906cc5800b008787f6e38a7mr5384065ejb.44.1677670593045; Wed, 01 Mar 2023 03:36:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677670593; cv=none; d=google.com; s=arc-20160816; b=t3xzF4ICkvDgSh8i2TVY9ZR6CONc07zd2sQJv6lG800o76tsIy1QG2SYZKX2hUmgQ9 PBZ5Nc1pUWbqCg/I5tfsRrgKMk9ug7fh1fpq/PNPJc6JU3HniWs3Kv+sx2Vr6quoF/RB NVQsmkx97/DUKk69wlhKe3ikkD9x5Dee1KfYkkJD8O7Ywb1OYavOlGBGMxFr6go/wGU9 2QOhXQQA6SRVjzx849DvnJ3OD5uWwDOuRLn0jV+wSPgH9YACEoFd7pxt9bFPGVf+z15h nA6CW1V2YOcvs2xnRHwxhHGSvXxoLfODBgHzWpB84bMgwdMA7jTxH5cBUqfjSn7hc3QX pmHA== 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=KaocPUP/85hGqVspdoQOJ31DiEYXa9HPIn4jxyEA7ME=; b=IJ7HNETaPstRyJomSvkocAp+zFSiKydeBzbyN2a3OY8N1T6U51vP6WsK3KRT+OXyF7 /W/7xjy8EYQjoqQfbPoqU7BTZvQ/qV1edqTJy7jND/LuFRj8rZNm4MiaEdeEkBZJgeIH eZiZo4OE7k/D+hG1M5YUWOXiph7uLjMJye8h+v1WpkNdW3Vm13VH7q6k+LkLn0MU+tc6 RJdy967ADsIWPlEWl2Bms3gBGjLqzY4IBjmTlE3gErd8V96r8oiP8YQsTVRuWhiXuyYP tVknmEvuAiabM0BuBZeyhM1QXXa1cCIHvjZu1xsOd0OESzg418vY6qN7TAdWsT2B+FiV wmTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FMzvZ1Al; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a13-20020a17090682cd00b008eb33b0bb02si12323391ejy.427.2023.03.01.03.36.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 03:36:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FMzvZ1Al; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 21D8F3858404 for ; Wed, 1 Mar 2023 11:36:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21D8F3858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677670592; bh=KaocPUP/85hGqVspdoQOJ31DiEYXa9HPIn4jxyEA7ME=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=FMzvZ1AlRRpjsVZtz8zG72RHw1ndOHPUXuu1hRGhuaQ9k0YWQRJV9F2NcWH5JWmtL HUvroYpmjq2U7D8hqn24/Z3QH7DuikcdD7rzVNXXKtEyPTQDD8P4Hql2CjEneoDIud u9tpeqEv4POQM93nCjaknA72XGLraEeLEHsSjPzQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by sourceware.org (Postfix) with ESMTPS id 78B533858D33 for ; Wed, 1 Mar 2023 11:35:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78B533858D33 Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 321BDFHY007588; Wed, 1 Mar 2023 11:35:45 GMT Received: from ala-exchng02.corp.ad.wrs.com (unknown-82-254.windriver.com [147.11.82.254]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3nybmkc44u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 01 Mar 2023 11:35:45 +0000 Received: from ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.18; Wed, 1 Mar 2023 03:35:44 -0800 Received: from ala-lpggp3.wrs.com (147.11.136.210) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server id 15.1.2507.18 via Frontend Transport; Wed, 1 Mar 2023 03:35:44 -0800 Received: by ala-lpggp3.wrs.com (Postfix, from userid 23306) id 7AC3D902B8A; Wed, 1 Mar 2023 03:35:44 -0800 (PST) To: CC: , Subject: [PATCH] Cpp: honor sysroot location Date: Wed, 1 Mar 2023 03:35:12 -0800 Message-ID: <20230301113512.1544598-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Proofpoint-GUID: crMx7NZcSNAG6fbd2c-xW4qx8w86olng X-Proofpoint-ORIG-GUID: crMx7NZcSNAG6fbd2c-xW4qx8w86olng X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-01_04,2023-03-01_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 clxscore=1034 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303010096 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NML_ADSP_CUSTOM_MED, NO_DNS_FOR_FROM, SPF_HELO_NONE, SPF_NONE, SPOOFED_FREEMAIL, SPOOF_GMAIL_MID, 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: Khem Raj via Gcc-patches From: Khem Raj Reply-To: Khem Raj 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?1759165119316568982?= X-GMAIL-MSGID: =?utf-8?q?1759165119316568982?= Currently, if the gcc toolchain is relocated and installed from shared state cache, then you try and compile preprocessed source (.i or .ii files), the compiler will try and access the builtin sysroot location rather than the --sysroot option specified on the commandline. If access to that directory is permission denied (unreadable), gcc will error. This happens when ccache is in use due to the fact it uses preprocessed source files. The fix below adds %I to the cpp-output spec macro so the default substitutions for -iprefix, -isystem, -isysroot happen and the correct sysroot is used. --- gcc/cp/lang-specs.h | 2 +- gcc/gcc.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Khem Raj Signed-off-by: Yash Shinde > --- gcc/cp/lang-specs.h | 2 +- gcc/gcc.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index c591d155cc1..61927869fe1 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -116,7 +116,7 @@ along with GCC; see the file COPYING3. If not see {".ii", "@c++-cpp-output", 0, 0, 0}, {"@c++-cpp-output", "%{!E:%{!M:%{!MM:" - " cc1plus -fpreprocessed %i %(cc1_options) %2" + " cc1plus -fpreprocessed %i %I %(cc1_options) %2" " %{!fsyntax-only:" " %{fmodule-only:%{!S:-o %g.s%V}}" " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}" diff --git a/gcc/gcc.cc b/gcc/gcc.cc index becc56051a8..3bc98b67b50 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -1463,7 +1463,7 @@ static const struct compiler default_compilers[] = %W{o*:--output-pch %*}}%V}}}}}}}", 0, 0, 0}, {".i", "@cpp-output", 0, 0, 0}, {"@cpp-output", - "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %I %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, {".s", "@assembler", 0, 0, 0}, {"@assembler", "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},