From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel,gmane.comp.gnu.guix.devel Subject: [PATCH 0/3] Add '-Wunused-module' Date: Sun, 12 Feb 2023 00:32:31 +0100 Message-ID: <20230211233234.14425-1-ludo@gnu.org> References: <20230203181126.5ee4003c@tachikoma.lepiller.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23690"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guix-devel@gnu.org, =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Feb 12 00:33:28 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQzN1-000607-NU for guile-devel@m.gmane-mx.org; Sun, 12 Feb 2023 00:33:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQzMd-0006ko-PM; Sat, 11 Feb 2023 18:33:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQzMc-0006kb-1z; Sat, 11 Feb 2023 18:33:02 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQzMa-0004Po-Kn; Sat, 11 Feb 2023 18:33:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=6wwAtNkzHOsGEUZCxz9Rptp1wyBSj24symbXhblQHkU=; b=LjSl1SCqy/gE/9AFEXUg Ap4ENSQSJeS2ue99QNyzxN4XiYAEYU9A+8X673NVGwjDr4UJrDgeuB298KK+dpG1HR3j9KMzgul9v +9S7D8HHSofUx3KNz5WDT24bGTKFO9DoPLTr769QfszuToOAr3GIiC8P8Kv2QhaluTkyEZOcp5S3j QMfK0OIDwCY+/NKWNhyjZF4NJeOaFtT46t1dFgH7xFy+cMPzF/EiecH4jpgzCVgsW8e9AM1oKTuNj OxN9ZQbKljqMzFoXNO88thw93m4+CHISh7uRBh22yt+m/QJxUaFVfV0g2oF8UcfLXVjanwWpEGhR4 3sKg9omaH6a1lA==; Original-Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQzMZ-0001E1-Vj; Sat, 11 Feb 2023 18:33:00 -0500 X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203181126.5ee4003c@tachikoma.lepiller.eu> X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21695 gmane.comp.gnu.guix.devel:65352 Archived-At: Hello Guilers! Following a discussion started at the Guix Days and continued online¹, it seems we could benefit from a compiler warning for unused modules, and this is what this patch does. The new ‘-Wunused-module’ warning is enabled at ‘-W2’ only. The main reason for not enabling it at ‘-W1’ is that in the case of modules used at macro-expansion time only, such as (srfi srfi-26), it cannot determine whether a module is definitely unused. In this case, the compiler reports the module as “possibly unused”, and it is up to the programmer to check that claim. Currently we cannot do any better because warnings operate at the tree-il, after macro expansion, and there’s nothing indicating whether a piece of code results from macro expansion. There’s also the rare case of modules imported for their side effects, not for their bindings, and that should be kept even if seemingly “unused”. One example might be the use of (rnrs bytevectors) in (rnrs io ports). But again, that’s super unusual. Anyway, it’s pretty useful already and has allowed me to trim imports in Guile modules. Thoughts? Ludo’. ¹ https://lists.gnu.org/archive/html/guix-devel/2023-02/msg00028.html Ludovic Courtès (3): Add -Wunused-module. Add 'record-case' to '.dir-locals.el'. Remove unnecessary module imports. .dir-locals.el | 1 + NEWS | 17 +++ module/ice-9/copy-tree.scm | 1 - module/ice-9/eval-string.scm | 1 - module/ice-9/getopt-long.scm | 1 - module/ice-9/poll.scm | 1 - module/ice-9/popen.scm | 1 - module/ice-9/sandbox.scm | 1 - module/ice-9/threads.scm | 1 - module/language/tree-il/analyze.scm | 138 +++++++++++++++++++++++- module/language/tree-il/fix-letrec.scm | 4 - module/sxml/apply-templates.scm | 2 - module/sxml/simple.scm | 1 - module/system/base/message.scm | 11 +- module/system/base/types.scm | 1 - module/system/repl/command.scm | 3 - module/system/repl/common.scm | 2 - module/system/repl/coop-server.scm | 1 - module/system/repl/debug.scm | 6 -- module/system/repl/error-handling.scm | 1 - module/system/repl/repl.scm | 4 - module/system/repl/server.scm | 1 - module/system/vm/assembler.scm | 2 - module/system/vm/disassembler.scm | 2 - module/system/vm/dwarf.scm | 2 - module/system/vm/elf.scm | 2 - module/system/vm/frame.scm | 2 - module/system/vm/inspect.scm | 5 - module/system/vm/linker.scm | 2 - module/system/vm/program.scm | 1 - module/system/vm/trace.scm | 3 - module/system/vm/trap-state.scm | 1 - module/system/vm/traps.scm | 2 - module/system/xref.scm | 1 - module/texinfo/indexing.scm | 1 - module/texinfo/plain-text.scm | 3 - module/texinfo/reflection.scm | 2 - module/texinfo/string-utils.scm | 2 - module/web/client.scm | 3 - module/web/http.scm | 2 - module/web/request.scm | 1 - module/web/response.scm | 2 - test-suite/tests/tree-il.test | 141 ++++++++++++++++++++++++- 43 files changed, 305 insertions(+), 77 deletions(-) base-commit: 9d339ea1a95c3b2d04a88aa6b116f997349fc4f4 -- 2.39.1