From patchwork Wed Jan 25 21:06:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Boeckel X-Patchwork-Id: 4531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp486586wrn; Wed, 25 Jan 2023 13:09:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyG1P8UWY3GrSKH3Br2i+ro4PZ+wxomXtQFd1y2JTFQwBhAT6mImE9rXcVChTmkbPr6LSJ X-Received: by 2002:a05:6402:1f05:b0:49e:16fc:b525 with SMTP id b5-20020a0564021f0500b0049e16fcb525mr35932768edb.41.1674680977004; Wed, 25 Jan 2023 13:09:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674680976; cv=none; d=google.com; s=arc-20160816; b=ltvKcUYX6iMDnl6DqQ+Yq4fNdT0nPMBXmzcZ8TPnlDrAZCqQBoq/uaQYxbl4vGXDXi 8hUhz1+JQeIPdDFgpE1LpKVjxGwiu21M1SNGWTQg7gnqQaJQQw0w2GC7iJZmggW47qGC jCMFY0aewyGeqAOBrvaFJSPu24ZtbDfmjWCjnhp8nOHseak3SoZnFIPUDsknRxAgXzcI UMATpOm8trVRx0vIh2uavZ0GY+SuptpGtO/L5sLVnAjBtRNVqm3/mVHAoGhrio/Yotef cA8xGDx73UB6RQHwV+LbYemywA5drSZLVF4B7j10bRPE4/M+pBHH8nTzHpxXXzqRgA6C TSbw== 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=whKQAP51RAQ5Emt4eQkbBbKxfaefs9wMtccP9HZHUo0=; b=TvyMjyow4+ckXwAuKt3s9Wv2SrENdNXwhr9n5o70eSLAy+aFtKnFdpbEdCymNXI6V4 /nKrBT/Sv82yfEcPzUMu4TqDBGET4wU/I+KfOyluI2WZvITW2ixn5S3DjZxWJ5hG32gx P1moIjhrLaniM2jMfIH3tuvTSEh8iveMwwHbnokbdDfpv4J7VUjeC6Y0JL7by84QXF6I PY+O0G9Xl1Uoat1+aoI4vxnKtvlqKHN1efK0lEI/Bpgo6k+yznZSE3/zlB9QV+0oR9hG ZoF1H+bzdb9rAOiK3OC1JA/VdevAaJmoVeMULtDy47cnnWBp/Tw5wVVVT+Bw2gjhRup4 N3+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OeuQ12jG; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g14-20020a056402428e00b004a08d34f51dsi6015891edc.263.2023.01.25.13.09.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:09:36 -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=OeuQ12jG; 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 991543888C4A for ; Wed, 25 Jan 2023 21:07:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 991543888C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674680865; bh=whKQAP51RAQ5Emt4eQkbBbKxfaefs9wMtccP9HZHUo0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OeuQ12jGl2zEBu3p+fLDwUXYhrP+cO8d03D5UxBxUyipnh/BwDOMdZSP8c98Kyhcu 02ZUFjOMeObjzaQo9ZeAl4u072S9WLyvdO5B+JZG2oE16219JPLx5pc+5un9EKrdIN MZt3DO5Gk0+YXYHL9u18gDhr8OA51FcXocQkBFZs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id CDE2F3858D28 for ; Wed, 25 Jan 2023 21:06:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDE2F3858D28 Received: by mail-qv1-xf2f.google.com with SMTP id s4so2776320qvo.3 for ; Wed, 25 Jan 2023 13:06:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=whKQAP51RAQ5Emt4eQkbBbKxfaefs9wMtccP9HZHUo0=; b=16xW7QGobcx6KrJvB3+xX2cUeN1P9sV7lduXmrHFM7OixGbs/8cc4q2wm7M3zojKxC Pno/DavAdNwYBV62aNxm8OAWy5is8kiW0BPtiMtFvGjWGSgVxyQpM3+OvocVcRp3y1hc Yq+ijdLQnnfrkYsd1Bxx/c3OPdEWJ/EsaSZDYVcbnrCRPmeW1Hk8xagdxF5yQDmA1vJB vwZ3zwC5o/ItA3qxjBFI2YQAFNB8xeFBXyYwHB/KAdw38v1wlwVd3belhK50COcgA5pC vZvjP1nis6seGhOaJa+n/dVpfQHZ9TWVMrP8prNdDdzKsBujtXruTuHFXI60dHsVMcun ++BA== X-Gm-Message-State: AFqh2kr5R1Kf+M6EBSSCahhiSXqnwdgszkrVlIEFd3Z3f9ZhQnpmzdn+ A7LqaXKNc54zQAzyLSmYjplWSaoiwFpXaeOKm6k= X-Received: by 2002:a05:6214:57d1:b0:532:1f17:2ce7 with SMTP id lw17-20020a05621457d100b005321f172ce7mr52108170qvb.16.1674680812229; Wed, 25 Jan 2023 13:06:52 -0800 (PST) Received: from localhost (cpe-142-105-146-128.nycap.res.rr.com. [142.105.146.128]) by smtp.gmail.com with ESMTPSA id g22-20020a37e216000000b006fa8299b4d5sm4153273qki.100.2023.01.25.13.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:06:51 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Ben Boeckel , jason@redhat.com, nathan@acm.org, fortran@gcc.gnu.org, gcc@gcc.gnu.org, brad.king@kitware.com Subject: [PATCH v5 0/5] P1689R5 support Date: Wed, 25 Jan 2023 16:06:31 -0500 Message-Id: <20230125210636.2960049-1-ben.boeckel@kitware.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Ben Boeckel via Gcc-patches From: Ben Boeckel Reply-To: Ben Boeckel 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?1756030280167561097?= X-GMAIL-MSGID: =?utf-8?q?1756030280167561097?= Hi, This patch series adds initial support for ISO C++'s [P1689R5][], a format for describing C++ module requirements and provisions based on the source code. This is required because compiling C++ with modules is not embarrassingly parallel and need to be ordered to ensure that `import some_module;` can be satisfied in time by making sure that any TU with `export import some_module;` is compiled first. [P1689R5]: https://isocpp.org/files/papers/P1689R5.html I've also added patches to include imported module CMI files and the module mapper file as dependencies of the compilation. I briefly looked into adding dependencies on response files as well, but that appeared to need some code contortions to have a `class mkdeps` available before parsing the command line or to keep the information around until one was made. I'd like feedback on the approach taken here with respect to the user-visible flags. I'll also note that header units are not supported at this time because the current `-E` behavior with respect to `import ;` is to search for an appropriate `.gcm` file which is not something such a "scan" can support. A new mode will likely need to be created (e.g., replacing `-E` with `-fc++-module-scanning` or something) where headers are looked up "normally" and processed only as much as scanning requires. FWIW, Clang as taken an alternate approach with its `clang-scan-deps` tool rather than using the compiler directly. Thanks, --Ben --- v4 -> v5: - add dependency tracking for imported modules to `-MF` - add dependency tracking for static module mapper files given to `-fmodule-mapper=` v3 -> v4: - add missing spaces between function names and arguments v2 -> v3: - changelog entries moved to commit messages - documentation updated/added in the UTF-8 routine editing v1 -> v2: - removal of the `deps_write(extra)` parameter to option-checking where ndeeded - default parameter of `cpp_finish(fdeps_stream = NULL)` - unification of libcpp UTF-8 validity functions from v1 - test cases for flag parsing states (depflags-*) and p1689 output (p1689-*) Ben Boeckel (5): libcpp: reject codepoints above 0x10FFFF libcpp: add a function to determine UTF-8 validity of a C string p1689r5: initial support c++modules: report imported CMI files as dependencies c++modules: report module mapper files as a dependency gcc/c-family/c-opts.cc | 40 +++- gcc/c-family/c.opt | 12 + gcc/cp/mapper-client.cc | 4 + gcc/cp/mapper-client.h | 1 + gcc/cp/module.cc | 23 +- gcc/doc/invoke.texi | 15 ++ gcc/testsuite/g++.dg/modules/depflags-f-MD.C | 2 + gcc/testsuite/g++.dg/modules/depflags-f.C | 1 + gcc/testsuite/g++.dg/modules/depflags-fi.C | 3 + gcc/testsuite/g++.dg/modules/depflags-fj-MD.C | 3 + gcc/testsuite/g++.dg/modules/depflags-fj.C | 4 + .../g++.dg/modules/depflags-fjo-MD.C | 4 + gcc/testsuite/g++.dg/modules/depflags-fjo.C | 5 + gcc/testsuite/g++.dg/modules/depflags-fo-MD.C | 3 + gcc/testsuite/g++.dg/modules/depflags-fo.C | 4 + gcc/testsuite/g++.dg/modules/depflags-j-MD.C | 2 + gcc/testsuite/g++.dg/modules/depflags-j.C | 3 + gcc/testsuite/g++.dg/modules/depflags-jo-MD.C | 3 + gcc/testsuite/g++.dg/modules/depflags-jo.C | 4 + gcc/testsuite/g++.dg/modules/depflags-o-MD.C | 2 + gcc/testsuite/g++.dg/modules/depflags-o.C | 3 + gcc/testsuite/g++.dg/modules/modules.exp | 1 + gcc/testsuite/g++.dg/modules/p1689-1.C | 18 ++ gcc/testsuite/g++.dg/modules/p1689-1.exp.json | 27 +++ gcc/testsuite/g++.dg/modules/p1689-2.C | 16 ++ gcc/testsuite/g++.dg/modules/p1689-2.exp.json | 16 ++ gcc/testsuite/g++.dg/modules/p1689-3.C | 14 ++ gcc/testsuite/g++.dg/modules/p1689-3.exp.json | 16 ++ gcc/testsuite/g++.dg/modules/p1689-4.C | 14 ++ gcc/testsuite/g++.dg/modules/p1689-4.exp.json | 14 ++ gcc/testsuite/g++.dg/modules/p1689-5.C | 14 ++ gcc/testsuite/g++.dg/modules/p1689-5.exp.json | 14 ++ gcc/testsuite/g++.dg/modules/test-p1689.py | 222 ++++++++++++++++++ gcc/testsuite/lib/modules.exp | 71 ++++++ libcpp/charset.cc | 28 ++- libcpp/include/cpplib.h | 12 +- libcpp/include/mkdeps.h | 17 +- libcpp/init.cc | 13 +- libcpp/internal.h | 2 + libcpp/mkdeps.cc | 149 +++++++++++- 40 files changed, 789 insertions(+), 30 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/depflags-f-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-f.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fi.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fj-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fj.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fjo-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fjo.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fo-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-fo.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-j-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-j.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-jo-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-jo.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-o-MD.C create mode 100644 gcc/testsuite/g++.dg/modules/depflags-o.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-1.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-1.exp.json create mode 100644 gcc/testsuite/g++.dg/modules/p1689-2.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-2.exp.json create mode 100644 gcc/testsuite/g++.dg/modules/p1689-3.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-3.exp.json create mode 100644 gcc/testsuite/g++.dg/modules/p1689-4.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-4.exp.json create mode 100644 gcc/testsuite/g++.dg/modules/p1689-5.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-5.exp.json create mode 100644 gcc/testsuite/g++.dg/modules/test-p1689.py create mode 100644 gcc/testsuite/lib/modules.exp base-commit: 9d4c00cdaccc3decd07740e817387ce844ef3ac9