From patchwork Wed Nov 9 02:10:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Boeckel X-Patchwork-Id: 1362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp91674wru; Tue, 8 Nov 2022 18:12:41 -0800 (PST) X-Google-Smtp-Source: AMsMyM43CwlHnSxUq0OdfURPQLTsc8jWwGBRR5SNEGa+bqM4yVNYkW1AjXFzIVZMFx6aFjyG8OH2 X-Received: by 2002:a05:6402:2712:b0:462:3758:beca with SMTP id y18-20020a056402271200b004623758becamr57169651edd.157.1667959961676; Tue, 08 Nov 2022 18:12:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667959961; cv=none; d=google.com; s=arc-20160816; b=pkAAJojZGZi+/CkI64JUnJ8XdyMDh9+dvfcRbh8OPCT2j4SSq338aQq2IWHffTCJ4D 0Lzm80rbtr9r/MApMpYt286n/JWJgGrr2IVrZUd2JAv3NabgIY2I/722YOFGYYMN8yP5 AMMq0bjrD5ZxINKv5jgaQbAGhV9SquC4fVlmdVq0w7HaT/agUO72W/df4utBLvZrCCqP N9yPLwstenIQTjWTqgHW9yuUFzU7HNDainIIefCKIkLUNAPjbers9Az+yTDD0r3XmYVG 1t6S3RYcpApfcrGC7kF8wAQrok+48b+QShZDHEnBJNcBOnElPRmxW7A8VgiBWRdutJJQ LuHQ== 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=XJj15zDkhpUbI+GLeiSvFc/g53OWuPM1ucS9swLIDDE=; b=VuHhd/2rcLCfGLMeO+oKGAFc5WZt6JSjCfiKht6fWWvjXW01TS+vscSOglopJ4aTZ7 rIlAzPImmdPq4Bxzi73hEYZu+H6JNKZcq+/+OcL06XwMqQsONPblrwAxVc3b3zajeQtg +7lbbpO7EppGJj0K96+fl7CCuRYMkOaO2YIJfDoamvl1SSlUi+fFVl8Xe7+EFRY+uI63 K93LVxjSzeK3CcJOsRXAnHH9/KDJazaV4Y2bZ1uWP7Q1xyVqGo6FJgT1iui5YtwTZRA7 zXJjOLM6OjQZY9dGKY+IJh/HSB++tdgLO5PF72HVXk5lRidtLQqPF9255mpFWT7cEXJm tIaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=N74FEvmi; 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 h2-20020a17090619c200b0078e27f2ef52si10335120ejd.603.2022.11.08.18.12.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 18:12:41 -0800 (PST) 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=N74FEvmi; 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 A73CA3857430 for ; Wed, 9 Nov 2022 02:11:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A73CA3857430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667959916; bh=XJj15zDkhpUbI+GLeiSvFc/g53OWuPM1ucS9swLIDDE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=N74FEvmiFDUYQfqs5CeNoKTBFNcjP23sroSzzPr6I1A4q5Zom6e6jGN+jSXL0UjQ/ dVJOdbfFILMyARtyn1XxlhlIxFSbKD2P8HUadyrAkHNSHLGdH3jZnRu7Ygtw4bsTmD l8qMbgmNIok/BZLbx6lQryoQ8y16uHcb+a1+y5FY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by sourceware.org (Postfix) with ESMTPS id E9CF93858C00 for ; Wed, 9 Nov 2022 02:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E9CF93858C00 Received: by mail-qt1-x830.google.com with SMTP id fz10so9732844qtb.3 for ; Tue, 08 Nov 2022 18:10:59 -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=XJj15zDkhpUbI+GLeiSvFc/g53OWuPM1ucS9swLIDDE=; b=UZZLnCQ3B6vDArWYzNT0AohiATvjqiBtVj6WSPy4WrezIqnf5J7hAZZupAwaOJefXM +5UwprCSUxD5VJHakspf80LdawggAdBcs/SOepO1BU4vx/cAHrqABV916J5hxsJZsfzY 8Sw8TyArngnWZJAHjqg69vWCpC/PlWwwJYwGXgA/kQHXpMV4SHNC+nIVCXIcYzZLVJeN fL+uQvSegSikL/5S3l5RI5W2EAqUA+C3VKInmQwL4NOlQGUFxDDYx3eKsryzAl5pXJEx klAroHr+gFtlwJ5J+xRQyaL3eevlz2OwD8N7o12MAWRrGGjNtW/mS97d/w4OsqMRVhTL eqkQ== X-Gm-Message-State: ACrzQf1vHxGEFm6nUhP8F/MBFGdRB22qDqSfO7AidwgWFlZorhkWaTEn u7+Ep0HxTbzwIDHssNq3AeLMQ4LE0OQLSg== X-Received: by 2002:a05:622a:1f93:b0:3a5:2d42:c407 with SMTP id cb19-20020a05622a1f9300b003a52d42c407mr37802362qtb.493.1667959858979; Tue, 08 Nov 2022 18:10:58 -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 bk4-20020a05620a1a0400b006eea461177csm10466345qkb.29.2022.11.08.18.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 18:10:58 -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, dmalcolm@redhat.com, mliska@suse.cz, anlauf@gmx.de Subject: [PATCH v3 0/3] RFC: P1689R5 support Date: Tue, 8 Nov 2022 21:10:45 -0500 Message-Id: <20221109021048.2123704-1-ben.boeckel@kitware.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3.1 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?1748982784929134043?= X-GMAIL-MSGID: =?utf-8?q?1748982784929134043?= Hi, This patch 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 the TU with `export import some_module;` is compiled first. [P1689R5]: https://isocpp.org/files/papers/P1689R5.html 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. For the record, Clang has patches with similar flags and behavior by Chuanqi Xu here: https://reviews.llvm.org/D134269 with the same flags. Thanks, --Ben --- 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 (3): libcpp: reject codepoints above 0x10FFFF libcpp: add a function to determine UTF-8 validity of a C string p1689r5: initial support gcc/c-family/c-opts.cc | 40 +++- gcc/c-family/c.opt | 12 + gcc/cp/module.cc | 3 +- 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 +++++++++++- 38 files changed, 773 insertions(+), 21 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: f95d3d5de72a1c43e8d529bad3ef59afc3214705