{"id":2225963,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225963/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260421211518.2333345-1-jason@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421211518.2333345-1-jason@redhat.com>","list_archive_url":null,"date":"2026-04-21T21:14:40","name":"[pushed] c++: #include rewrite and installed compiler [PR123879]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"05c3f0a21728a71efab799697e792ae4bf3657ab","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/1.2/people/4337/?format=json","name":"Jason Merrill","email":"jason@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260421211518.2333345-1-jason@redhat.com/mbox/","series":[{"id":500897,"url":"http://patchwork.ozlabs.org/api/1.2/series/500897/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500897","date":"2026-04-21T21:14:40","name":"[pushed] c++: #include rewrite and installed compiler [PR123879]","version":1,"mbox":"http://patchwork.ozlabs.org/series/500897/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225963/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225963/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=JrQMhNzE;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=JrQMhNzE","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0ZsD28xFz1yHF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 07:15:58 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 98D144BA902E\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 21:15:54 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 373B64BA23FC\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 21:15:25 +0000 (GMT)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-Bj7DEWlbNYuiYknYyJZSiQ-1; Tue,\n 21 Apr 2026 17:15:21 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 67E01195605E\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 21:15:20 +0000 (UTC)","from jason-thinkpadp1gen4i.rmtusma.csb (unknown [10.22.65.102])\n by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 0C6351956095\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 21:15:19 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 98D144BA902E","OpenDKIM Filter v2.11.0 sourceware.org 373B64BA23FC"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 373B64BA23FC","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 373B64BA23FC","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776806125; cv=none;\n b=O9KtnnnmcFLISFpC3KE1XE3anZb/+pu2JQOGGBtsPnSAfW4i1BgiaqRH52uCf/BDj5XmldkE28niSZroDnFxZDQ956xqUXpauh7iP1vaVD/HRGcDMbxF0T9azX7oZ5UhUBVjTedwP9qBzag0ph4exYwkBMlOHUrwyieXukL8n9Q=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776806125; c=relaxed/simple;\n bh=+dBG44/xgMlnYW5yYLUlHZ8XDxSRm4wnLfeSRKQp9Co=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=pyBEJRVSmsxsZpWXCSCi0hHugyrNRtWesOSRNcuxznhgxIBCTNt3GJ4gCw30l8XPzohIznjzOZEgW3km6/UVlGPYxt1OYI/ydengMdHQH5CV2qhKYb3RTqZURhSYwvYZZ9d8QSZs+Url/0vlnxtDpYUhnRxbqQpJNCpclbikozU=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776806124;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=xljJHqo+gkIsuJj4mwfVlldNQpiNESG4DaInGpSQdTo=;\n b=JrQMhNzEE2hQQbAC9dSfYvQRjM62ab8FfeX9SzMy9zJNgI/+9Bxu6PnMWJPIqyk8Gga6wf\n BtUcAJ+py2z6EWoOa3XwNYpeO7sFHQaWbcd4JR+VJzpfIQwzVbZrUuNcCHvUvmEtfCI8VR\n ahXgMjD2XNXMQIZoqNAbCnLCUNA51/4=","X-MC-Unique":"Bj7DEWlbNYuiYknYyJZSiQ-1","X-Mimecast-MFC-AGG-ID":"Bj7DEWlbNYuiYknYyJZSiQ_1776806120","From":"Jason Merrill <jason@redhat.com>","To":"gcc-patches@gcc.gnu.org","Subject":"[pushed] c++: #include rewrite and installed compiler [PR123879]","Date":"Tue, 21 Apr 2026 17:14:40 -0400","Message-ID":"<20260421211518.2333345-1-jason@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"_Hl1_tbVlub7mrXbwN7sZnQ2NTWFHsHSbmlk44dO5m0_1776806120","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Tested x86_64-pc-linux-gnu, applying to trunk.\n\n-- 8< --\n\nIn an installed compiler, the pathname in the expanded_location might be\ncanonicalized while the pathname in the cpp_dir is not, e.g. eloc.file is\n\".../include/c++/16.0.1/stdbit.h\" while dir->name is\n\".../lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1\".  So\nlet's use lrealpath to compare canonical paths for both.  And filename_ncmp,\nwhile we're at it.\n\n\tPR c++/123879\n\ngcc/cp/ChangeLog:\n\n\t* module.cc (maybe_translate_include): Use lrealpath in check\n\twhether we're including something in the same directory.\n---\n gcc/cp/module.cc | 11 ++++++++++-\n 1 file changed, 10 insertions(+), 1 deletion(-)\n\n\nbase-commit: 83e758acdb8fc24acfbbcc5696d052ac0a565d72","diff":"diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc\nindex e5547f7d029..a7245aae46a 100644\n--- a/gcc/cp/module.cc\n+++ b/gcc/cp/module.cc\n@@ -23131,13 +23131,22 @@ maybe_translate_include (cpp_reader *reader, line_maps *lmaps, location_t loc,\n       /* Redirect importable <name> to <bits/stdc++.h>.  */\n       /* ??? Generalize to use a .json.  */\n       expanded_location eloc = expand_location (loc);\n+      auto indir = [](const char *f, const char *d)\n+      {\n+\tif (!filename_ncmp (f, d, strlen (d))) return true;\n+\t/* Also check canonical paths (c++/123879).  */\n+\tauto cf = lrealpath (f); auto cd = lrealpath (d);\n+\tbool r = cf && cd && !filename_ncmp (cf, cd, strlen (cd));\n+\tfree (cf); free (cd);\n+\treturn r;\n+      };\n       if (angle && is_importable_header (fname)\n \t  /* Exclude <version> which often goes with import std.  */\n \t  && strcmp (fname, \"version\") != 0\n \t  /* Don't redirect #includes between headers under the same include\n \t     path directory (i.e. between library headers); if the import\n \t     brings in the current file we then get redefinition errors.  */\n-\t  && !strstr (eloc.file, _cpp_get_file_dir (file)->name)\n+\t  && !indir (eloc.file, _cpp_get_file_dir (file)->name)\n \t  /* ??? These are needed when running a toolchain from the build\n \t     directory, because libsupc++ headers aren't linked into\n \t     libstdc++-v3/include with the other headers.  */\n","prefixes":["pushed"]}