From patchwork Sun Jan 13 22:28:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1024171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493968-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YGpQ+71C"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="InJbqdY1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43dB8417zRz9rxp for ; Mon, 14 Jan 2019 09:28:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ZNTOgiUronAj2QwbqXWKsp6HSoqKbm5YWfbRKidYnQ33qEahGu L+QO/CsDi5iwaIU3NpmRuP1ObKbCfKR/GjDt3DBjosv/BGb3Y9htPZMdrkb6C1k3 za+p8BPxgMEo1OIrURqV8nWXw8Qts1hoS9wOTwXAKQm8LinA2KXcKeNi4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=R6eoaOJYhgHyZC6Y+9CUotJxCo4=; b=YGpQ+71CCB6PEEGUfaWZ MoOnA+Swuy7+lSBxdBFcWrVGEXERWbLA0HhFKMasFelBcJiGGMSsrdCX0Bgg5Ox+ w8egJ3dtNoe9OktP/CscKp2Squ+xVi3T+WGhCcu/hhfV3mUAIRsWBhFoAfN0Nton uuoRU10W7Rqamu/fYQtgXhs= Received: (qmail 1999 invoked by alias); 13 Jan 2019 22:28:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1951 invoked by uid 89); 13 Jan 2019 22:28:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.8 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=advantages, fsyntaxonly, fsyntax-only, Copy X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Jan 2019 22:28:04 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 885B613180; Sun, 13 Jan 2019 23:28:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1547418481; bh=UIzpxE/fd/KVXMndP4XK9OIr9wBJ/5klmDCnGYEXvfU=; h=To:From:Subject:Message-ID:Date:From; b=InJbqdY11fN2meiVbX/2nSklWchO3g2+X5JpKcDGCI/PZhVkMQDIax1cUuP9MiET7 l7HQSV7UwoxQjvJ9sYIVbiQVDJKHynXzUj2gj2wpWhEwbsP/SBJAtOP+AtLY8uMJbK GBPKnfxVC9L1zzkFPVvlB8mUIL+0KrUG+nUag8gP/Bbat4vetihNgMsZZ75WoW5PSu BR+FMhkTqJSVawZxBGCMiw0dVRorOvFLIo1VjC35KaRkIAagmx7Dk8qsBhyF7Cr1DG HvVpXgacyWrc1dps+/hgp3WVtV0yc9J2pgMq8FUeuYyE9H/I8e2QaUpvElwMT+o/V2 wp2wybKCrC+hw== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id 7B19F11EAE; Sun, 13 Jan 2019 23:28:01 +0100 (CET) Received: from [78.35.146.213] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c3bbb71-01b0-7f0000012729-7f000001e6f8-1 for ; Sun, 13 Jan 2019 23:28:01 +0100 Received: from [192.168.178.68] (xdsl-78-35-146-213.nc.de [78.35.146.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Sun, 13 Jan 2019 23:28:00 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Add -fwrite-module-files option Message-ID: <69b6de3d-7df0-bc43-5b89-3e830b0b9c0f@netcologne.de> Date: Sun, 13 Jan 2019 23:28:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Hello world, the attached patch adds a -fwrite-module-files options, but the main point is that it adds its opposite, -fno-write-module-files. This has advantages in parallel compiling, as it is quite fast to generate a module file with -fsyntax-only, and a subsequent compilation with -fno-write-module-files will not overwrite this. Yes, submodules also address some of the same issues. For details, see the PR. Regression-tested. Documentation tested with "make info", "make dvi" and "make pdf". Test case... well, it works when run by hand, and I'm not sure how to check for the presence or absence of a module file in dejagnu. OK for trunk? Regards Thomas 2019-01-13 Thomas Koenig PR fortran/82215 * invoke.texi: Document -fwrite-module-files. * lang.opt: Add -fwrite-module-files. * parse.c (gfc_parse_file): Write module only if -f-write-module-files is in effect. Index: invoke.texi =================================================================== --- invoke.texi (Revision 267903) +++ invoke.texi (Arbeitskopie) @@ -102,6 +102,7 @@ one is not the default. and register usage. * Interoperability Options:: Options for interoperability with other languages. +* File Output Options:: Which files the compiler generates during compilation. * Environment Variables:: Environment variables that affect @command{gfortran}. @end menu @@ -178,6 +179,10 @@ and warnings}. @xref{Interoperability Options,,Options for interoperability}. @gccoptlist{-fc-prototypes} +@item File Output Options +@xref{File Output Options,,Options for determining output of files}. +@gccoptlist{-fwrite-module-files} + @item Code Generation Options @xref{Code Gen Options,,Options for code generation conventions}. @gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol @@ -791,9 +796,12 @@ messages produced. @item -fsyntax-only @opindex @code{fsyntax-only} @cindex syntax checking -Check the code for syntax errors, but do not actually compile it. This -will generate module files for each module present in the code, but no -other output file. +Check the code for syntax errors, but do not actually compile it. +This will generate module files for each module present in the code, +but no other output file. Using this option, it is possible to +generate module files much faster. Together with the +@option{-fwrite-module-files} options, it can be used for speeding up +compilation processes. @item -Wpedantic @itemx -pedantic @@ -1865,6 +1873,44 @@ where the C code intended for interoperating with then uses @code{#include "foo.h"}. @end table +@node File Output Options +@section Which files the compiler generates during compilation + +@table @asis + +@item -fwrite-module-files +@opindex @code{write-module-files} +@cindex Writing out module files +This option will write out a @file{foo.mod} file when the module +@code{foo} has been successfully compiled. This file will be read in +later when @code{use foo} is encountered in the code. +Writing out the file is the default. + +The negative form, @option{-fno-write-module-files}, supresses writing +of module files. This can be useful when the module files have +previously been generated with @option{-fsyntax-only}, for example to +support a more parallel make process. When code has been changed and +@option{-fno-write-module-files} is used, it is possible to generate +inconsistent module files, which will lead to hard-to-find bugs. Use +with care. + +An example of how this could be used is the following Makefile +snippet. It assumes that @file{foo.f90} contains a module @code{foo}, +which is used by module @code{bar} in @file{bar.f90}. This would +allow parallel compilation of @file{foo.f90} and @file{bar.f90}. + +@smallexample +foo.mod: foo.f90 + gfortran -fmodule-files=only foo.f90 + +foo.o: foo.f90 + gfortran -fmodule-files=no foo.f90 + +bar.o: bar.f90 foo.mod + gfortran -c bar.f90 +@end smallexample +@end table + @node Environment Variables @section Environment variables affecting @command{gfortran} @cindex environment variable Index: lang.opt =================================================================== --- lang.opt (Revision 267903) +++ lang.opt (Arbeitskopie) @@ -722,6 +722,10 @@ frepack-arrays Fortran Var(flag_repack_arrays) Copy array sections into a contiguous block on procedure entry. +fwrite-module-files +Fortran Var(flag_write_module_files) Init(1) +Write module files. + fcoarray= Fortran RejectNegative Joined Enum(gfc_fcoarray) Var(flag_coarray) Init(GFC_FCOARRAY_NONE) -fcoarray= Specify which coarray parallelization should be used. Index: parse.c =================================================================== --- parse.c (Revision 267903) +++ parse.c (Arbeitskopie) @@ -6284,7 +6284,9 @@ loop: gfc_get_errors (NULL, &errors); if (s.state == COMP_MODULE || s.state == COMP_SUBMODULE) { - gfc_dump_module (s.sym->name, errors_before == errors); + if (flag_write_module_files) + gfc_dump_module (s.sym->name, errors_before == errors); + gfc_current_ns->derived_types = gfc_derived_types; gfc_derived_types = NULL; goto prog_units;