From patchwork Tue Jun 6 20:50:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Boeckel X-Patchwork-Id: 10381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3662809vqr; Tue, 6 Jun 2023 13:52:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hKf9q9Bj0CfqytEpxVA/QZkk2OKXWYlNOFEI7Qy5botWUzw7/EDp7FNHBnaXYlStWiiIQ X-Received: by 2002:a17:907:94d4:b0:971:2eaf:556 with SMTP id dn20-20020a17090794d400b009712eaf0556mr4040163ejc.18.1686084773522; Tue, 06 Jun 2023 13:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686084773; cv=none; d=google.com; s=arc-20160816; b=SjCWyMjqcJNSOw30V4nkpmbfpD95ruhRkPJsN6oc6+75VHiqm3o9LlfwwVce4WIdiV IXt0FkVqwCp2aG4pRN/r0FWF8aaeAgjOpQhZTdLZ38aSFRzv1XQaA2zCp/YbnKz7vAkP pH+wLjTjlgTszUQz4wgv9PUppe6l0eRi4WOyDjZ8ORKFkClECNZJFnbjK9MRV4S5iAw3 ffapUolOUCZOsFQEBiRb913KKf0F+WuYC6/J22cgRpekdEZ5rtqDdVJZMtB8dk4obOL5 hR3rgPgsDW3L1UpGp8f6JcsMph6O1noC3H++91yCnn+JW/WRF2mBAY+XywWo42BZnbY4 8LNg== 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=MMkHi/8gpnTXiRhm66+XkhUZ/2cQNBd/J0hGcOMB3Nc=; b=wpEyAPellvl4JqPAhdFv2tRgzpx8ToTqVRJB4ooX4Fh/pZ5wUE7A9Mev2rVLqOKtZQ GdzrhSri/IMCQqXORs5gi3mhacf8ItOQqHb8GHcPJOzbrFai5iajx4jdSwIoaQGOmOSO PoxPqgLXHZm2FQWQRQPfmU1OJyukmkrMaddCNLTJGEiMrWdppEUmdvCtPMk4RWAKjp9R H7jx43L8uoxMGMk6L/kILs7t4n7Vkur5q+zCxAOldbjiWK0bSKDQUGIAP5dZbEPyS8Ln FqwyVFMSraMu51Mo2qEBEzdfL8yV+PcO0anClS7avDLH4alnHeykE6TYSDCf57WkDPcE gMpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="l4wf/DaO"; 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 sh33-20020a1709076ea100b00974e764c89bsi8972138ejc.57.2023.06.06.13.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 13:52:53 -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="l4wf/DaO"; 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 17413384D193 for ; Tue, 6 Jun 2023 20:51:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17413384D193 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686084684; bh=MMkHi/8gpnTXiRhm66+XkhUZ/2cQNBd/J0hGcOMB3Nc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=l4wf/DaOrSFst/ueOAxJgPFjkN8e9FvtMmCozeqRnIQXVW8FFxuS79HC66u+0v5qW c1u24uB1ly+mCJbX5Y+te88uQJpTn0eRAVfbzKMMX3Zxgn1ti1DJqVVpKbvq74JIcS 94glDzrqIiEl97G2yL1XWn3n3kaS07yjHfwhnTM0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by sourceware.org (Postfix) with ESMTPS id 79AF03858D38 for ; Tue, 6 Jun 2023 20:50:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79AF03858D38 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-62b671e0a0dso6029526d6.1 for ; Tue, 06 Jun 2023 13:50:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686084634; x=1688676634; 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=MMkHi/8gpnTXiRhm66+XkhUZ/2cQNBd/J0hGcOMB3Nc=; b=fBxijxpwjrQXr3MO+DyPLq+OJ8J5naQ6s23SKu/9fQ0U4y4NRzCGsBPKIq4FYFPWin ui6Hpa0DmYqTizbCGazIBs4snoMJPiDORfPQfEWIl6JcXJPyaUOyQUKM6l6nYxTVlJlR PPd/INsXB64OI1g7fc+4+k7ECfr8eyn9bt1cxvkNrb7kkDyjGibyPgwtAe7DB7y3qbtb DPiVUujG1J/Bc8WnDh+7j6vSLLb4xyV4O35hdlbMLAKjIvBMrD0wSbOdEvqk0NSoUMwl 8N0X5ZlnLLclQtAaOLFKnNRygHCgp5VxfClDLNduI/O3lAOz59JvjfeXimbw9Pp45wT0 W4hg== X-Gm-Message-State: AC+VfDxBkN4uoigTyBdQdQoZCk0sCy0OCoTjouD1nbcrHqLg+0F+tz+K cKcZP/RiYWkh8yq+7XvPKw/0GFPiQWoacFCu31NOrA== X-Received: by 2002:a05:6214:4105:b0:628:6641:50d2 with SMTP id kc5-20020a056214410500b00628664150d2mr629266qvb.52.1686084633746; Tue, 06 Jun 2023 13:50:33 -0700 (PDT) Received: from localhost (cpe-142-105-146-128.nycap.res.rr.com. [142.105.146.128]) by smtp.gmail.com with ESMTPSA id ay38-20020a05622a22a600b003e4ee0f5234sm563773qtb.87.2023.06.06.13.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 13:50:33 -0700 (PDT) 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 v6 0/4] P1689R5 support Date: Tue, 6 Jun 2023 16:50:21 -0400 Message-Id: <20230606205025.3164738-1-ben.boeckel@kitware.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3.2 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, T_SCC_BODY_TEXT_LINE 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?1767988027657339552?= X-GMAIL-MSGID: =?utf-8?q?1767988027657339552?= 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 --- v5 -> v6: - rebase onto `master` (585c660f041 (reload1: Change return type of predicate function from int to bool, 2023-06-06)) - fix crash related to reporting imported CMI files as dependencies - rework utf-8 validity to patch the new `cpp_valid_utf8_p` function instead of the core utf-8 decoding routine to reject invalid codepoints (preserves higher-level error detection of invalid utf-8) - harmonize of `fdeps` spelling in flags, variables, comments, etc. - rename `-fdeps-output=` to `-fdeps-target=` 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 (4): libcpp: reject codepoints above 0x10FFFF 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 | 24 +- 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 | 7 + libcpp/include/cpplib.h | 12 +- libcpp/include/mkdeps.h | 17 +- libcpp/init.cc | 13 +- libcpp/mkdeps.cc | 149 +++++++++++- 39 files changed, 769 insertions(+), 28 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: 585c660f041c57694a61b3e65085af5a54431be4