From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id AECB93987427 for ; Tue, 3 Nov 2020 21:15:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AECB93987427 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-x72f.google.com with SMTP id b18so16604005qkc.9 for ; Tue, 03 Nov 2020 13:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:subject:to:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=PutGAIITTAYprHwjVE1AhzN37XdPor/dcHmrEB46pEM=; b=VPO4qd/YTmsDyN6Dig+qJJPKGPi5Id5CIf9/pIiTOr2Cc+r3mPBEo6OLMq+E5MvQSi rWGtmw68Flhrbw7voJ9p0fL8/TJ1Tw8y7n1i+fGmNysqbVS5JH02veGm1XqIWHryID05 U2NvJm4IAy3WE7RmQQA+dq+MMLXEBsb9K5iWpJchF6+lVUtt/86PBBB7gy2kSXDkJ537 0ARBbNJS+dSV/wBk0PpiW+V/2SJ0IC9UXe8b8yVhZOWK2mII8PNhEAjyhBX+gh6cMQ38 FmixjG6OVlZEMQg0ctOVdt8HW7D9rSqwAyFQaRiUMBwAvgRzbtuhze1/7Z12Vhf8LO2w Nhcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:subject:to:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=PutGAIITTAYprHwjVE1AhzN37XdPor/dcHmrEB46pEM=; b=Avp/Zo41oD8jNeMGGc2c4auHlO0VfQA3qgYshHQwsDXth+MZEzswvKprT/1veAlXHt T6909hK/RKgdiKQVTHGFb66j9gorNhVAUz2JRVmId2ADudKNnkncpRigsd4eFueGRGhq 8B1m0dJuS+/15zzATz5DYkOdmxRarPuNE9KbranrEURRgUJpb72dYyz/mY5UxZ4YByBO VP4icapsSuxXWU8jAknErMBfZVsrzD4fa3q+JEOVNk1HKy04RC620OMa/kx1n4D/eMXC nGsDa3Qj6rgxMivEqIKN1y14iE9hnvfUx8IpiLhYPhfjGW62w2xXyqCFJYZJvLL7AvPl N4Dg== X-Gm-Message-State: AOAM531kLF7Woo0dBBmHBzdhAM4EFJRLAiqJbP58NsHIMgp++34VaANz 5mp7jojieoUQ99B/9duYP9I= X-Google-Smtp-Source: ABdhPJylIm/KnklNZJfA0oXLF+feq4ivYSCOmIP5JGKjQgQSr/04T6hruCxz/YTQJXPvP/zTFusV/w== X-Received: by 2002:ae9:e807:: with SMTP id a7mr20469073qkg.53.1604438123966; Tue, 03 Nov 2020 13:15:23 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:e5ef:7eb4:1609:98bb? ([2620:10d:c091:480::1:bc2d]) by smtp.googlemail.com with ESMTPSA id j16sm11788125qkg.26.2020.11.03.13.15.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Nov 2020 13:15:23 -0800 (PST) Sender: Nathan Sidwell From: Nathan Sidwell Subject: [13/32] new options To: GCC Patches , Jason Merrill , Richard Biener References: <7fc9e868-3db9-4972-ed67-6ff249f549c3@acm.org> <0bdf00a8-d8ad-9e97-134d-6668c0e8c86b@acm.org> <85996243-86cf-88b4-5b3b-451eaf3a0df6@acm.org> <4d14b230-3263-9a13-3159-c4853f282761@acm.org> <688bd28f-5998-0def-8c40-03b817832d63@acm.org> <89819c10-e86d-9b01-5673-5223a525a135@acm.org> <35879e15-d74a-c664-4d44-15f4b3783d77@acm.org> <9ae23c4c-67a5-a267-c939-5a96e9488612@acm.org> Message-ID: <6e4bc3b9-4263-b114-b118-fcb5799976fb@acm.org> Date: Tue, 3 Nov 2020 16:15:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------B9FE58BA55881098B5835314" Content-Language: en-US X-Spam-Status: No, score=-11.3 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: , X-List-Received-Date: Tue, 03 Nov 2020 21:15:26 -0000 This is a multi-part message in MIME format. --------------B9FE58BA55881098B5835314 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Here are the new options, along with the C++ lang-spec changes. Modules is enabled by -fmodules-ts, it is not implicitly enabled by -std=c++20. Usually that's the only option you need to add for a module-aware build. to build a header unit you can either add -fmodule-header to a c++ build, or you can set the language to be c++-header and add -fmodules-ts: g++ -x c++-header -fmodules-ts my-header-file to search the user or system include paths select c++-user-header of c++-system-header as the language. enabling -fmodules-ts will disable PCH, they do not play well together. There is a potential issue down the road when we implicitly enable modules. At that point building a header-unit could become indistinguishable from building a PCH. Perhaps we should consider phasing in an explicit PCH option? -- Nathan Sidwell --------------B9FE58BA55881098B5835314 Content-Type: text/x-patch; charset=UTF-8; name="13-family-options.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="13-family-options.diff" diff --git c/gcc/c-family/c-opts.c w/gcc/c-family/c-opts.c index 120f4489f6c..c8f08d9e014 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 a2292f46a7d..f55a1fde3ad 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 10e53ea67c9..1edc7f2b2bd 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. @@ -1666,6 +1674,53 @@ 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 Binary 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) +Note #include directives translated to import declarations. + +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}, --------------B9FE58BA55881098B5835314--