From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Abou Samra Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: 'guild compile' and C(++) extensions (in the context of LilyPond) Date: Tue, 22 Feb 2022 07:34:10 +0100 Message-ID: <48e30b1b-2f2b-d09d-8aa3-ed9a0c41923a@abou-samra.fr> References: <1fbaea64-8a8f-ea4b-714c-68ced7e1eab8@abou-samra.fr> <875ypa7dm2.fsf@laura> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34586"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 To: Olivier Dion , guile-user@gnu.org, guile-devel@gnu.org, 52230@debbugs.gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Feb 22 07:35:05 2022 Return-path: Envelope-to: guile-user@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 1nMOlN-0008nS-Jw for guile-user@m.gmane-mx.org; Tue, 22 Feb 2022 07:35:05 +0100 Original-Received: from localhost ([::1]:43986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMOlM-0004us-Ac for guile-user@m.gmane-mx.org; Tue, 22 Feb 2022 01:35:04 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMOkq-0004uK-Dy; Tue, 22 Feb 2022 01:34:32 -0500 Original-Received: from mout.kundenserver.de ([212.227.17.13]:58697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMOko-0003v2-Lq; Tue, 22 Feb 2022 01:34:32 -0500 Original-Received: from [10.188.216.67] ([46.193.67.184]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.184]) with ESMTPSA (Nemesis) id 1MMFdY-1ndWA12byw-00JMIM; Tue, 22 Feb 2022 07:34:11 +0100 Content-Language: en-US In-Reply-To: <875ypa7dm2.fsf@laura> X-Provags-ID: V03:K1:/kHgbcz3UHKXYxnMUq8m8jQsUOkqfbpCfPoBL0/KFAdQ0AOF420 c2jvqrGawPeKT7Af/jGEMitPJUokNlbuLoxMPSo5kfDgaVZbZ6oVtTwwcaLKSU6st41E2lW VF7j3HainI9pedWxwv4sGLuc3NA41bhNJ40coa16xev3yV6HogepzxO2eQI6fziBd8lFKQy ke39fyWm9yLRyndU2aLjw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0HM7cUI/ThE=:lQzAPNcRuuZ5b28HuzTdBO GR1NUevNsldyxjFnqpwXjE/KVGtA9zMbKVNTqKSLng6DdvPEkFJiCHXl9foBWhXUQZPadqQVt zLAqPjSdwANW3KckcZSvDNW0c5ar+e6kPd8UPki5zBJAqoII3FaTq/W9o8TEaOmMaW83Ljw0T +TGCvDxmuTVsB0SNv4piC09zqgO0ynt0ceQ9JkEE6UmSTVgJUJbZx5/Vfi7uQKxVSRUGndPOb BLUnE6/8xr2F6DMY8DOFKIFetKfpgWYwnBxATRJEorhfbx863U7qx7yEB3d48MGJf6uRbyNDx CTVCO5HyuT0lbA9NPDsP8yChjDwO2bGcreoaPYGdojR14OJ/9wflbZYOVc+C1sOiaX1CB57JY X+cbIfv3msV9VygOvxglP0DAbsFcGSBG9vqM632F2ly6XlHkO9hRPevRPfcv3C0LDYmWvnC9v y7LPWdkm0hP2fozLhWJHcFMuFMbN+J/2VAK8GAg9eFXfjMF7kKyp6RDVV3S/7/qNZpGkK4R7h sIM4SxBV6UFWwh60qZoBYp/3ThyellYFzjIxOFxDIgKHxR0+qbJ4APLOWWGESiBWX42vpfJAd 6+hQ3pxjGR7s6+UUwVSnIfpZ4MVR7Lf2F//A95fFbicN4Apifhy2tCZX5eWUa3l4G+uR6ufcQ 89Yoh2LyHxvpbaIujXY/0MjoUCLk3NFD/xNJ1O0okcXrES5+US4vhm0kzIDp0IT02lTI= Received-SPF: none client-ip=212.227.17.13; envelope-from=jean@abou-samra.fr; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18114 gmane.lisp.guile.devel:21141 Archived-At: Le 19/02/2022 à 22:25, Olivier Dion a écrit : > On Sat, 19 Feb 2022, Jean Abou Samra wrote: > > I had similar problem with Jami. I added C++ primitives to Guile, but > these were not load using the foreign function interface. Note, I'm > using Guile 3.0.8, but I think the same could be done for Guile 2.0. > > Basically what I do is to add a `compile` command to my program so to > speak. > > So usually the program does this: > main -> install_scheme_primitives() -> Run the program > > And for compilation > main -> compile_in_guile() -> install_scheme_primitives() -> compile-file > > > To be clear here's what install_scheme_primitives() does: > -------------------------------------------------------------------------------- > void > install_scheme_primitives() > { > /* Define modules here */ > auto load_module = [](auto name, auto init){ > scm_c_define_module(name, init, NULL); > }; > > load_module("jami account", install_account_primitives); > load_module("jami call", install_call_primitives); > load_module("jami conversation", install_conversation_primitives); > load_module("jami logger bindings", install_logger_primitives); > load_module("jami signal bindings", install_signal_primitives); > } > -------------------------------------------------------------------------------- > > and here's what compile_in_guile() does: > -------------------------------------------------------------------------------- > void* > compile_in_guile(void* args_raw) > { > // ... > install_scheme_primitives(); > > // This string is usually formatted > scm_c_eval_string("(use-modules (system base compile))" > "(compile-file \"foo.scm\" #:output-file \"foo.go\")") > > // .. > } > -------------------------------------------------------------------------------- > > so now I can correctly compile any file in the project. I just add this > to Makefile.am: > -------------------------------------------------------------------------------- > MODULES = foo.scm > GOBJECTS = $(MODULES:%=%.go) > > %.go: %.scm | program > @echo GUILD; ./program compile $< $@ > -------------------------------------------------------------------------------- > > Hope that can help. Thank you Olivier, this is hugely helpful. So far we thought we'd need to restructure our set of Scheme files in proper modules to make separate byte-compilation happen. This works in my experiments, and can compile several files that are part of the same module as well, using the #:env argument of compile-file. Thanks again, much appreciated. Best regards, Jean