From patchwork Fri Sep 1 13:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Boeckel X-Patchwork-Id: 13776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp877484vqu; Fri, 1 Sep 2023 06:13:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgQ5uHiBGreL2TVz0COSkLtV57eutbZSVt7R85uB31KEiLYW2wJim8pqTDjaO5aECkCJ5i X-Received: by 2002:a17:906:15b:b0:9a1:d29c:6a9d with SMTP id 27-20020a170906015b00b009a1d29c6a9dmr1783844ejh.46.1693574029287; Fri, 01 Sep 2023 06:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693574029; cv=none; d=google.com; s=arc-20160816; b=jQ46XdaaNuVSqLWY6ATwiYOGv6EotT8BJAtDEPk/FWhW+G5cOfXK7s3NM0o6A43eRV Dj4WBTSQm3cEp0QAMbAlcgLuZa/Y2imME/RyPo5XtUEq6sbwfIXlVlk8gq2WZ2kVbQKX IyJPHdA4QBYil/enoq5e2cLnqm+qYZFmDrWVb7I3jW7amWowbxnqeW/rv//ZrviibY9v 7/ox1o1PauEnEtbFqleH+uRYXA7iYmEHu7+My70+w4p1a1G5KlDh7wNqt3MAf6IuD4un 7OsGd1Q0iTfJUGXx3Roc1FHDW/W+zMBBtM+2Z4lqKuujllaJpUzkGPYXOmunBu6VIIP/ 3Srw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=AyJqb2kicJt/wPomVZDZNUkdfSggMJlG13GXGqSPkWE=; fh=k/Ceyxcdi7bE5nnOFo1POLZehPadJc8HBydZ6eliaUc=; b=DwFkXw6M6XnsvGONiOFAGL+OTz0Nct69g3cp1E1Eg5jZDOG566rZNnY9VYWOxdBhnZ Pbft0iLh06wpsGVYdxRMWk5VBln017Dlo8whPOS6ES28VMXLfr09kJ8d4vFjFbWJxMZg XGH2VadCPnOrl5vhVvx2gTo4g2FwvrnMzizBk6Jn3rcaRxe1bsmMX8iqIhUy++fy3bQg fxEyc3ShZIcES12niGF05j9XstWuUhaQ83GrkFoSJh7dBlmxvl6Giy3Ev/dq/zhO/9g8 QEPRKh1vaCe0LscEe6PYIiEhu5gnX7WOPDVZYBSUqkfw6yDPg3N9irTwy/CT8zrx7IFB mIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nav5fhRa; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id re20-20020a170906d8d400b0099caf50c27fsi2610178ejb.1046.2023.09.01.06.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 06:13:49 -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=nav5fhRa; 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 82E2E395B81B for ; Fri, 1 Sep 2023 13:05:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82E2E395B81B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693573526; bh=AyJqb2kicJt/wPomVZDZNUkdfSggMJlG13GXGqSPkWE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=nav5fhRavPbgdGfrZn0uvkksZHJ4c/P4RhLdvjtxE+9HO6FKPzVPo/elTgiNxcZ1V 4sOOKfw9RHthgAZLlrDIOfjets18dR/QzdcFh/7w2QKLXu0DNx37tqNhwRaP29Mptn ZgEjcJowEvdTxg5RDKWw3Qw78l/UsNNW7KQAXpww= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id 4DCD9385354A for ; Fri, 1 Sep 2023 13:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DCD9385354A Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-41369b80875so8313651cf.1 for ; Fri, 01 Sep 2023 06:04:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693573453; x=1694178253; 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=AyJqb2kicJt/wPomVZDZNUkdfSggMJlG13GXGqSPkWE=; b=QFRmIArg2vDYI+N+Ku2DbAfqm3JqD03hI66qyItbwQi0pjgM88H8uKNFWMPCMMT/JE pxt6k/K8sgbPtzQ4EwOzxAAlIPe444aA81jU176iX6bV3/Lj3ebhuekASZBSbD7uj3bM f5y/S1OnkqhNzjYyu4W8iK12PuzsMXZ8EEFq0XJEBgzYY2VJZ/fEpl5sB+pusGvmZUtL 9qDJUDqy/9nh0ePHUUIS5gWWDlnV7gyFuV1g5yque4msWCw+U9iYeqiguXkrIvMEXwgS L5cndzQ02LzDCuMXS7XPUiRvXWrDIlXhR7xrdaBgJqNyh+jOTfmhsQ1ru5e2H6zZbk3w rm2w== X-Gm-Message-State: AOJu0YzHBrJtoYcoFOB7/Q3No9g7/isSAyT1o/JQJJzTgR9wBuD+N8O+ J1IW46H9/CAY7h5BisLsack+evF2ZbIMd1GrYVIt2A== X-Received: by 2002:a05:622a:18a1:b0:410:9668:530a with SMTP id v33-20020a05622a18a100b004109668530amr3793608qtc.21.1693573453471; Fri, 01 Sep 2023 06:04:13 -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 r11-20020ac87eeb000000b00403c82c609asm1425786qtc.14.2023.09.01.06.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 06:04:13 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH v8 0/4] P1689R5 support Date: Fri, 1 Sep 2023 09:04:00 -0400 Message-ID: <20230901130407.259768-1-ben.boeckel@kitware.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-4.8 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.30 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 Cc: gcc@gcc.gnu.org, brad.king@kitware.com, fortran@gcc.gnu.org, Ben Boeckel , nathan@acm.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775841081219377480 X-GMAIL-MSGID: 1775841081219377480 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 --- v7 -> v8: - rename `DEPS_FMT_` enum variants to `FDEPS_FMT_` to match the associated flag - memory leak fix in the `join` specfunc implementation (also better comments), both from Jason - formatting fix in `mkdeps.cc` for `write_make_modules_deps` assignment - comments on new functions for P1689R5 implementation v6 -> v7: - rebase onto `master` (80ae426a195 (d: Fix core.volatile.volatileLoad discarded if result is unused, 2023-07-02)) - add test cases for patches 3 and 4 (new dependency reporting in `-MF`) - add a Python script to test aspects of generated dependency files - a new `join` spec function to support `-fdeps-*` defaults based on the `-o` flag (needed to strip the leading space that appears otherwise) - note that JSON writing support should be factored out for use by `libcpp` and `gcc` (libiberty?) - use `.ddi` for the extension of `-fdeps-*` output files by default - support defaults for `-fdeps-file=` and `-fdeps-target=` when only `-fdeps-format=` is provided (with tests) - error if `-MF` and `-fdeps-file=` are both the same (non-`stdout`) file as their formats are incompatible - expand the documentation on how the `-fdeps-*` flags should be used 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): spec: add a spec function to join arguments 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 | 44 +++- gcc/c-family/c.opt | 12 + gcc/cp/mapper-client.cc | 5 + gcc/cp/mapper-client.h | 1 + gcc/cp/module.cc | 24 +- gcc/doc/invoke.texi | 27 +++ gcc/gcc.cc | 27 ++- gcc/json.h | 3 + gcc/testsuite/g++.dg/modules/depflags-f-MD.C | 2 + gcc/testsuite/g++.dg/modules/depflags-f.C | 3 + gcc/testsuite/g++.dg/modules/depflags-fi.C | 4 + gcc/testsuite/g++.dg/modules/depflags-fj-MD.C | 3 + .../g++.dg/modules/depflags-fj-MF-share.C | 6 + 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/depreport-1_a.C | 10 + gcc/testsuite/g++.dg/modules/depreport-1_b.C | 12 + .../g++.dg/modules/depreport-2.modmap | 2 + gcc/testsuite/g++.dg/modules/depreport-2_a.C | 15 ++ gcc/testsuite/g++.dg/modules/depreport-2_b.C | 14 ++ gcc/testsuite/g++.dg/modules/modules.exp | 1 + gcc/testsuite/g++.dg/modules/p1689-1.C | 17 ++ gcc/testsuite/g++.dg/modules/p1689-1.exp.ddi | 27 +++ gcc/testsuite/g++.dg/modules/p1689-2.C | 15 ++ gcc/testsuite/g++.dg/modules/p1689-2.exp.ddi | 16 ++ gcc/testsuite/g++.dg/modules/p1689-3.C | 13 + gcc/testsuite/g++.dg/modules/p1689-3.exp.ddi | 16 ++ gcc/testsuite/g++.dg/modules/p1689-4.C | 13 + gcc/testsuite/g++.dg/modules/p1689-4.exp.ddi | 14 ++ gcc/testsuite/g++.dg/modules/p1689-5.C | 13 + gcc/testsuite/g++.dg/modules/p1689-5.exp.ddi | 14 ++ .../g++.dg/modules/p1689-file-default.C | 16 ++ .../g++.dg/modules/p1689-file-default.exp.ddi | 27 +++ .../g++.dg/modules/p1689-target-default.C | 16 ++ .../modules/p1689-target-default.exp.ddi | 27 +++ gcc/testsuite/g++.dg/modules/test-depfile.py | 207 ++++++++++++++++ gcc/testsuite/g++.dg/modules/test-p1689.py | 222 ++++++++++++++++++ gcc/testsuite/lib/modules.exp | 100 ++++++++ libcpp/include/cpplib.h | 12 +- libcpp/include/mkdeps.h | 9 +- libcpp/init.cc | 13 +- libcpp/mkdeps.cc | 163 ++++++++++++- 51 files changed, 1199 insertions(+), 23 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-MF-share.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/depreport-1_a.C create mode 100644 gcc/testsuite/g++.dg/modules/depreport-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/depreport-2.modmap create mode 100644 gcc/testsuite/g++.dg/modules/depreport-2_a.C create mode 100644 gcc/testsuite/g++.dg/modules/depreport-2_b.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-1.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-1.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-2.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-2.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-3.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-3.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-4.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-4.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-5.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-5.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-file-default.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-file-default.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/p1689-target-default.C create mode 100644 gcc/testsuite/g++.dg/modules/p1689-target-default.exp.ddi create mode 100644 gcc/testsuite/g++.dg/modules/test-depfile.py create mode 100644 gcc/testsuite/g++.dg/modules/test-p1689.py create mode 100644 gcc/testsuite/lib/modules.exp base-commit: ed6603fd103dc2b15943b391ac061e0172d22956