From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Dynamic module building and reloading Date: Tue, 13 Jun 2023 19:55:48 +0300 Message-ID: <834jnbwbcb.fsf@gnu.org> References: <87mt13tk8s.fsf@valhala.localdomain> 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="8451"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Nicolas Martyanoff Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jun 13 18:56:19 2023 Return-path: Envelope-to: ged-emacs-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 1q97Ja-0001xc-I5 for ged-emacs-devel@m.gmane-mx.org; Tue, 13 Jun 2023 18:56:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q97Iq-0003IF-96; Tue, 13 Jun 2023 12:55:32 -0400 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 1q97In-0003Hm-W4 for emacs-devel@gnu.org; Tue, 13 Jun 2023 12:55:30 -0400 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 1q97In-00073W-Ie; Tue, 13 Jun 2023 12:55:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=i0mzLLnMSA7ea0uIr7k75Uj0s/0WI5Sm3vHZTRDFVtM=; b=nabe6RgeNdfBGiwPx2f6 GHy0VMVGI2/+VBYclVNYXwKxv7GcArIwaV0FpPU+3puE/BZz+NQ5OJ2tLDOeKrWNZnjBu3NXFWVXS cx0PeqW2s4kgNtjIUyshbTmjRRtrT4Wwn8TFI2vd4H9ciT6bbFBgHf81WRgyLPi1J3cngcBiJXFOD TnVXuYWmA+NDLd43zJhy5PcjAE8EtRfUAoA5FbLtVhdIlvUx87fYMxFx1wq38slS7RsQOUFLFhO+f Tauqe6gbRDyf2+vUuqxO1RMiKVG8PLFDAWeGo3PFLew/RIOIl5lQEfzCTnoUmwFL6DMKXQTCl22tH V0jMXSm6q/PNhA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q97In-0006qg-2P; Tue, 13 Jun 2023 12:55:29 -0400 In-Reply-To: <87mt13tk8s.fsf@valhala.localdomain> (message from Nicolas Martyanoff on Tue, 13 Jun 2023 18:11:47 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306781 Archived-At: > From: Nicolas Martyanoff > Date: Tue, 13 Jun 2023 18:11:47 +0200 > > 1. There does not seem to be any builtin utilities to deal with > the process of building and loading shared library. I ended up writing a > couple elisp functions to find the location of the C file, spawn cc, > load the shared library… Is this the expected method? In this state, it > would seem that every Emacs packages using dynamic modules has to write > its own build/load code. The expected method of building a shared library is the same as you'd use for building any other shared library out there. The Emacs modules aren't special in any way, and the details of their build procedures depend on what code you are compiling in, which other libraries you need to link against, etc. There's no way an Emacs command could cover all that. However, if you write a Makefile to compile and link the module, you can use "M-x compile" to run the Make utility to build your module. > 2. It seems that once a dynamic module has been loaded, it cannot be > reloaded after the shared library has been rebuilt. A Google search > seems to confirm it. Is there a workaround? If I pursue my little > project, I'll have to write quite a lot of C code in the dynamic module; > I *really* do not want to restart Emacs to test every single > modification. We don't have a facility to unload a module, no. The usual way of testing your development code is to start a new scratch session (in addition to your production Emacs session) each time you recompile a module.