How best to produce a standalone executable with Guile?

2020-04-05 Thread James Cooper
Hi Guile folks,

I am currently experimenting with a handful of languages that include
modern implementations of Concurrent ML, to determine which one appears
best able to handle computationally- and message-heavy workloads (at least
for my purposes, Computer Vision).  Guile is one of the languages I am
trying out with the Fibers library.

My question is, how can I best go about creating Linux executables from
Guile, where said programs benefit from the most ahead-of-time compilation
and optimisation possible?  I don't believe they strictly need to be
standalone, as the environment I will be running the programs in will
likely be the same as the development environment. So they can undoubtedly
have dependencies on external libraries.  Furthermore, I am perfectly happy
with the process being a bit convoluted, as I can easily automate it with a
makefile.  I would, however, prefer if at all possible that the option to
target other processor architectures remains available down the line (I
assume using GCC can enable this, but I'm not sure).

I have looked at all the sections of the Guile manual that appeared
relevant, but to be honest I'm still a bit confused about what the best
approach would be.  *s* *9.4.5 Bytecode* in the manual seems to suggest
that one can use guild to produce what will be a standalone executable that
looks like an ELF binary to the system and runs on the Guile VM, but I'm
entirely sure if I am reading it correctly.  *s 6.18.5 Compiling Scheme
Code* also discusses compilation but seems to denounce the practice
explicitly.  *s 9.3.8 Just-In-Time Native Code* talks about JIT compilation
to native code for a given target.  Is it possible to apply this process
ahead-of-time?

A potential alternative approach I can see is using the capabilities of
running Guile code in a C program (compiled with GCC).  This would
presumably involve creating a template C program that just calls the
appropriate Guile functions and passes the relevant command line parameters
in.

Any thoughts on what would likely produce the most efficient executable in
the end?  The target programs do not need to modify themselves at run-time
(or really do anything dynamic) if that makes a difference.  And does
anyone know of pre-existing examples they could point me to?  Please do let
me know if there is further information I could provide that would help.
Thanks in advance.

Regards,

James


Re: How best to produce a standalone executable with Guile?

2020-04-05 Thread Matt Wette

On 4/4/20 10:28 PM, James Cooper wrote:

Hi Guile folks,

I am currently experimenting with a handful of languages that include
modern implementations of Concurrent ML, to determine which one appears
best able to handle computationally- and message-heavy workloads (at least
for my purposes, Computer Vision).  Guile is one of the languages I am
trying out with the Fibers library.

My question is, how can I best go about creating Linux executables from
Guile, where said programs benefit from the most ahead-of-time compilation
and optimisation possible?  I don't believe they strictly need to be
standalone, as the environment I will be running the programs in will
likely be the same as the development environment. So they can undoubtedly
have dependencies on external libraries.  Furthermore, I am perfectly happy
with the process being a bit convoluted, as I can easily automate it with a
makefile.  I would, however, prefer if at all possible that the option to
target other processor architectures remains available down the line (I
assume using GCC can enable this, but I'm not sure).

[...]

You can't produce a pre-compiled machine code binary of your guile
program.  I believe you can use the environment variable
GUILE_JIT_THRESHOLD set to zero to have your code compiled to
machine code on first use.

$ GUILE_JIT_THRESHOLD=0 guile my-program.scm

You can also start execution of your guile program from C using
the techniques described in the section "Programming in C" in the
Guile Reference Manual.

Matt




How best to produce a standalone executable with Guile?

2020-04-05 Thread Christopher Howard
Are you a Guix user? One you come up with a Guix package definition, it
is I think a one line command to generate an exportable executable with
a full dependency chain included, or a docker image.

-- 
Christopher Howard
p: +1 (907) 374-0257
w: https://librehacker.com
social: https://gnusocial.club/librehacker
gpg: ADDEAADE5D607C8D (keys.gnupg.net)

On Sun, 2020-04-05 at 12:00 -0400, guile-user-requ...@gnu.org wrote:
> Send guile-user mailing list submissions to
>   guile-user@gnu.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   https://lists.gnu.org/mailman/listinfo/guile-user
> or, via email, send a message with subject or body 'help' to
>   guile-user-requ...@gnu.org
> 
> You can reach the person managing the list at
>   guile-user-ow...@gnu.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of guile-user digest..."
> 
> 
> Today's Topics:
> 
>1. How best to produce a standalone executable with Guile?
>   (James Cooper)
>2. Re: How best to produce a standalone executable with Guile?
>   (Matt Wette)
> 
> 
> ---
> ---
> 
> Message: 1
> Date: Sun, 5 Apr 2020 05:28:10 +
> From: James Cooper 
> To: guile-user@gnu.org
> Subject: How best to produce a standalone executable with Guile?
> Message-ID:
>   <
> CAB_RW2E5s7Wd4yRA81OcaGLtGoFsvjOR1hCGhD=w7ec4fhr...@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
> 
> Hi Guile folks,
> 
> I am currently experimenting with a handful of languages that include
> modern implementations of Concurrent ML, to determine which one
> appears
> best able to handle computationally- and message-heavy workloads (at
> least
> for my purposes, Computer Vision).  Guile is one of the languages I
> am
> trying out with the Fibers library.
> 
> My question is, how can I best go about creating Linux executables
> from
> Guile, where said programs benefit from the most ahead-of-time
> compilation
> and optimisation possible?  I don't believe they strictly need to be
> standalone, as the environment I will be running the programs in will
> likely be the same as the development environment. So they can
> undoubtedly
> have dependencies on external libraries.  Furthermore, I am perfectly
> happy
> with the process being a bit convoluted, as I can easily automate it
> with a
> makefile.  I would, however, prefer if at all possible that the
> option to
> target other processor architectures remains available down the line
> (I
> assume using GCC can enable this, but I'm not sure).
> 
> I have looked at all the sections of the Guile manual that appeared
> relevant, but to be honest I'm still a bit confused about what the
> best
> approach would be.  *s* *9.4.5 Bytecode* in the manual seems to
> suggest
> that one can use guild to produce what will be a standalone
> executable that
> looks like an ELF binary to the system and runs on the Guile VM, but
> I'm
> entirely sure if I am reading it correctly.  *s 6.18.5 Compiling
> Scheme
> Code* also discusses compilation but seems to denounce the practice
> explicitly.  *s 9.3.8 Just-In-Time Native Code* talks about JIT
> compilation
> to native code for a given target.  Is it possible to apply this
> process
> ahead-of-time?
> 
> A potential alternative approach I can see is using the capabilities
> of
> running Guile code in a C program (compiled with GCC).  This would
> presumably involve creating a template C program that just calls the
> appropriate Guile functions and passes the relevant command line
> parameters
> in.
> 
> Any thoughts on what would likely produce the most efficient
> executable in
> the end?  The target programs do not need to modify themselves at
> run-time
> (or really do anything dynamic) if that makes a difference.  And does
> anyone know of pre-existing examples they could point me to?  Please
> do let
> me know if there is further information I could provide that would
> help.
> Thanks in advance.
> 
> Regards,
> 
> James
> 
> 
> --
> 
> Message: 2
> Date: Sun, 5 Apr 2020 07:44:18 -0700
> From: Matt Wette 
> To: guile-user@gnu.org
> Subject: Re: How best to produce a standalone executable with Guile?
> Message-ID: 
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> On 4/4/20 10:28 PM, James Cooper wrote:
> > Hi Guile folks,
> > 
> > I am currently experimenting with a handful of languages that
> > include
> > modern implementations of Concurrent ML, to determine which one
> > appears
> > best able to handle computationally- and message-heavy workloads
> > (at least
> > for my purposes, Computer Vision).  Guile is one of the languages I
> > am
> > trying out with the Fibers library.
> > 
> > My question is, how can I best go about creating Linux executables
> > from
> > Guile, where said programs benefit from the most ahead-of-time
> > compilation
> > and optimisation possible?  I don't believe they st