From patchwork Tue Dec 1 18:30:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1408994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sb+iKzF0; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ClrJl0gMFz9sPB for ; Wed, 2 Dec 2020 05:31:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B19D5384241D; Tue, 1 Dec 2020 18:31:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 7CBB13857C66 for ; Tue, 1 Dec 2020 18:30:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7CBB13857C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x729.google.com with SMTP id z188so2253241qke.9 for ; Tue, 01 Dec 2020 10:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=h1Hc/su/7eZc9njwBb1FNkVkakwJ124NZsAeBarJNvI=; b=sb+iKzF0gp8qpnuwOFkTSBL5I2v+88OA3NahQNedP5jpLJ+f/YxpHbMBTBjix2l3Ex Q+obOK6nx3I0FSTHeHqQpzkM53g71veLj+QTKGEFAl5kBYB0ETvBbiKP4OSk4wFLRKDm QgMWNB7UkXzs18tW6n8onqC591zidwvAMoMe/ylP0To/yscJl1O++4gm448WwHX6oGua AIaUxRKBWk0WxkJjfogWcc5iGdizaN0pjYBVY7K/RWl9YQmoCRZnYHz/PHGyr3umVmgU JqGFNf/Cqf/3z0vmIoK5EpHXfCYnjxdKgHrvm3hGahvMaedCMf8Fn3VEg7O3Tz3gXsCi 9g+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=h1Hc/su/7eZc9njwBb1FNkVkakwJ124NZsAeBarJNvI=; b=rfSMYTQ8bES1ortXoSKyLzSAY+zLTFuiZDDGv6BEd8S2EvH4EjO8C+mkeAEsTGH9aU xQjkZ61xmoiAQNn02Nx3PrIhNS9xXSOFK+hakPgdqiV6joHkmnBmUbr9MfOyNGJBjbha EZ6a9a6tCae9KKUPjsDMCsDoxNZzvqq5hNyaEVEYeW+UW7XuhOPeV5LjPrQxj238XrwF oD5y9Nnowl75k1nEDSBqzoPHb2PvR6yQNjkxPrm6kkSSnXMx52GECrySBtzk+hfcK1RE hdWG9JM//nrOZkS7ijS/Tsx2I4D0NG0YnRmxIsHBCfIzZmyy96CoMIjeifKlZRFUrmnu GaIw== X-Gm-Message-State: AOAM533hQ2RiRkKEnd8wLRKjqBQSSQ9KRPx5cM6S9hc3rltSlMJMrYx0 yJkJWzP//CwWPu2ge9CK8u4= X-Google-Smtp-Source: ABdhPJxH3aaYFY4Rr/OjgPQJn7ot82i238w4s5fSz1RUM7Na6z4JM4w0meNleMMXyJkBlUoXNriFyA== X-Received: by 2002:a37:78c:: with SMTP id 134mr4296136qkh.359.1606847456871; Tue, 01 Dec 2020 10:30:56 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:6970:ca91:a99:e1b? ([2620:10d:c091:480::1:7f3a]) by smtp.googlemail.com with ESMTPSA id c128sm402203qkg.66.2020.12.01.10.30.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2020 10:30:55 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: C++ Module options Message-ID: Date: Tue, 1 Dec 2020 13:30:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This adds the C++ module options, and wires them into lang-specs. The options are not connected to any machinery. The options! They do nothing! Since posting the earlier patch, I added -flang-info-include-translate-not, to warn about header files that are being treated textually. gcc/c-family/ * c-opts.c (c_common_init_options): Ask for module dependencies. (c_common_handle_option): Handle -Mmodules -Mno-modules. * c-pch.c (c_common_valid_pch): ... does not play with C++ modules. * c.opt (Mmodules, Mno-modules): New preprocessor dependency options. (fmodules-ts, fmodule-header, fmodule-implicit-inline) (fmodule-only, fmodule-mapper, fmodule-lazy) (fmodule-version-ignore, Winvalid-imported-macros) (flang-info-include-translate, flang-info-include-translate-not): New options gcc/cp/ * lang-spec.h: Add module-related options. pushing to trunk nathan diff --git c/gcc/c-family/c-opts.c w/gcc/c-family/c-opts.c index 77844d7daf1..59cabd12407 100644 --- c/gcc/c-family/c-opts.c +++ w/gcc/c-family/c-opts.c @@ -234,6 +234,7 @@ c_common_init_options (unsigned int decoded_options_count, cpp_opts = cpp_get_options (parse_in); cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; cpp_opts->objc = c_dialect_objc (); + cpp_opts->deps.modules = true; /* Reset to avoid warnings on internal definitions. We set it just before passing on command-line options to cpplib. */ @@ -367,6 +368,18 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, cpp_opts->deps.phony_targets = true; break; + case OPT_Mmodules: + /* Do not set deps_seen, so the user can unconditionally turn + this on or off. */ + cpp_opts->deps.modules = true; + break; + + case OPT_Mno_modules: + /* Do not set deps_seen, so the user can unconditionally turn + this on or off. */ + cpp_opts->deps.modules = false; + break; + case OPT_MQ: case OPT_MT: deps_seen = true; diff --git c/gcc/c-family/c-pch.c w/gcc/c-family/c-pch.c index 9c0bd0b631d..fdeb860c0e6 100644 --- c/gcc/c-family/c-pch.c +++ w/gcc/c-family/c-pch.c @@ -206,6 +206,10 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) /* Perform a quick test of whether this is a valid precompiled header for the current language. */ + /* C++ modules and PCH don't play together. */ + if (flag_modules) + return 2; + sizeread = read (fd, ident, IDENT_LENGTH + 16); if (sizeread == -1) fatal_error (input_location, "cannot read %s: %m", name); diff --git c/gcc/c-family/c.opt w/gcc/c-family/c.opt index 0532cb70ffc..059f6c38a40 100644 --- c/gcc/c-family/c.opt +++ w/gcc/c-family/c.opt @@ -236,6 +236,14 @@ MMD C ObjC C++ ObjC++ NoDriverArg Separate MissingArgError(missing filename after %qs) Like -MD but ignore system header files. +Mmodules +C++ +Generate C++ Module dependency information. + +Mno-modules +C++ +; undocumented + MP C ObjC C++ ObjC++ Generate phony targets for all headers. @@ -1683,6 +1691,57 @@ flax-vector-conversions C ObjC C++ ObjC++ Var(flag_lax_vector_conversions) Allow implicit conversions between vectors with differing numbers of subparts and/or differing element types. +fmodules-ts +C++ ObjC++ Var(flag_modules) Integer Init(0) +Enable C++ modules-ts (experimental). + +fno-modules +C++ ObjC++ Undocumented RejectNegative Var(flag_modules,0) Integer +;; undocumented + +fmodule-header +C++ ObjC RejectNegative Var(flag_header_unit,0) Integer +Enable C++ header module (experimental). + +fmodule-header= +C++ ObjC++ Joined RejectNegative Undocumented + +fmodule-implicit-inline +C++ ObjC++ Var(flag_module_implicit_inline,0) Integer +Member functions defined within their class are inline in module purview. + +fmodule-only +C++ ObjC RejectNegative Var(flag_module_only) Integer +Only emit Compiled Module Interface. + +fmodule-mapper= +C++ ObjC++ Joined RejectNegative MissingArgError(missing mapper) +Mapper for module to CMI files. + +fmodule-lazy +C++ ObjC++ Var(flag_module_lazy) Init(1) +Enable lazy module importing. + +fmodule-version-ignore +C++ ObjC Var(flag_module_version_ignore) Integer +; undocumented, Very dangerous, but occasionally useful + +Winvalid-imported-macros +C++ ObjC++ Var(warn_imported_macros) +Warn about macros that have conflicting header units definitions. + +flang-info-include-translate +C++ Var(note_include_translate_yes) +Note #include directives translated to import declarations. + +flang-info-include-translate-not +C++ Var(note_include_translate_no) +Note #include directives not translated to import declarations, and not known to be textual. + +flang-info-include-translate= +C++ Joined RejectNegative MissingArgError(missing header name) +Note a #include translation of a specific header. + fmax-include-depth= C ObjC C++ ObjC++ Joined RejectNegative UInteger fmax-include-depth= Set the maximum depth of the nested #include. diff --git c/gcc/cp/lang-specs.h w/gcc/cp/lang-specs.h index 0ad4a33b93e..1388aaed198 100644 --- c/gcc/cp/lang-specs.h +++ w/gcc/cp/lang-specs.h @@ -40,17 +40,57 @@ along with GCC; see the file COPYING3. If not see {".tcc", "@c++-header", 0, 0, 0}, {".hh", "@c++-header", 0, 0, 0}, {"@c++-header", - "%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}" + "%{E|M|MM:cc1plus -E %{fmodules-ts:-fdirectives-only -fmodule-header}" + " %(cpp_options) %2 %(cpp_debug_options)}" + "%{!E:%{!M:%{!MM:" + " %{save-temps*|no-integrated-cpp:cc1plus -E" + " %{fmodules-ts:-fdirectives-only -fmodule-header}" + " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" + " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" + " %{fmodules-ts:-fdirectives-only}" + " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" + " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" + " %{fmodules-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}" + " %(cc1_options) %2" + " %{!S:-o %g.s%V}" + " %{!fsyntax-only:%{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" + " %{!o*:--output-pch=%i.gch}%W{o*:--output-pch=%*}}}}}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {"@c++-system-header", + "%{E|M|MM:cc1plus -E" + " %{fmodules-ts:-fdirectives-only -fmodule-header=system}" + " %(cpp_options) %2 %(cpp_debug_options)}" "%{!E:%{!M:%{!MM:" " %{save-temps*|no-integrated-cpp:cc1plus -E" + " %{fmodules-ts:-fdirectives-only -fmodule-header=system}" " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" + " %{fmodules-ts:-fdirectives-only}" " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" + " %{fmodules-ts:-fmodule-header=system %{fpreprocessed:-fdirectives-only}}" " %(cc1_options) %2" - " %{!fsyntax-only:%{!S:-o %g.s}" - " %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}" - " %W{o*:--output-pch=%*}}%V}}}}", + " %{!S:-o %g.s%V}" + " %{!fsyntax-only:%{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" + " %{!o*:--output-pch=%i.gch}%W{o*:--output-pch=%*}}}}}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {"@c++-user-header", + "%{E|M|MM:cc1plus -E" + " %{fmodules-ts:-fdirectives-only -fmodule-header=user}" + " %(cpp_options) %2 %(cpp_debug_options)}" + "%{!E:%{!M:%{!MM:" + " %{save-temps*|no-integrated-cpp:cc1plus -E" + " %{fmodules-ts:-fdirectives-only -fmodule-header=user}" + " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}" + " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" + " %{fmodules-ts:-fdirectives-only}" + " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" + " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" + " %{fmodules-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}" + " %(cc1_options) %2" + " %{!S:-o %g.s%V}" + " %{!fsyntax-only:%{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:" + " %{!o*:--output-pch=%i.gch}%W{o*:--output-pch=%*}}}}}}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++", "%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}" @@ -60,11 +100,14 @@ along with GCC; see the file COPYING3. If not see " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" - " %(cc1_options) %2" - " %{!fsyntax-only:%(invoke_as)}}}}", + " %(cc1_options) %2" + " %{fmodule-only:%{!S:-o %g.s%V}}" + " %{!fsyntax-only:%{!fmodule-only:%(invoke_as)}}}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {".ii", "@c++-cpp-output", 0, 0, 0}, {"@c++-cpp-output", "%{!E:%{!M:%{!MM:" " cc1plus -fpreprocessed %i %(cc1_options) %2" - " %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + " %{fmodule-only:%{!S:-o %g.s%V}}" + " %{!fsyntax-only:%{!fmodule-only:%{!fmodule-header*:" + " %(invoke_as)}}}}}}", 0, 0, 0},