From: Jim Newton
Subject: lisp compiling to elf
Date: 
Message-ID: <320ct3F3bj7duU1@individual.net>
does anyone know of a lisp compiler that compiles
to ELF format?  apparently cmucl compiles to a.out.

For example what formats do lispworks, sbcl,
and lispworks or gcl compile to?

-jim

From: Thomas F. Burdick
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <xcvd5xgk8jt.fsf@conquest.OCF.Berkeley.EDU>
Jim Newton <·····@rdrop.com> writes:

> does anyone know of a lisp compiler that compiles
> to ELF format?  apparently cmucl compiles to a.out.
>
> For example what formats do lispworks, sbcl,
> and lispworks or gcl compile to?

CMUCL, SBCL, and OpenMCL all compile to custom-format fasl files.  GCL
and ECL use C as an intermediary language, so they produce fasls in
the format the system C compiler uses (ELF or Mach-O).  I'm not sure
about LW or Allegro, but I'd bet they both use custom fasl formats.  I
looked a bit at writing a Mach-O format fasl dumper for SBCL, and it
should be fairly straightforward, but I have too much on my plate
already.

Now for the obvious question, why do you care about the fasl format
your lisp uses?  One reason might be because you want the code for a
library to be shared between different Lisp processes that use it --
at the moment, I think the only easy way to do this is to dump a core
with the library loaded.
From: Jim Newton
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <320sn6F3f6t03U1@individual.net>
has anyone done any work to try to make any of the popular
lisp compilers create elf format?  i know less than nothing
about elf, but it has to be just some sort of loader or
wrapper around the compiled program.  am i thinking about
it too simplisitically?    If cmucl for example could
produce an elf file then you could compile stand alone
lisp programs right?  of course there would have to
be some dynamically linkable library somewhere which
provides the lisp engine.

Is the some low level difference between what the
lisp compiler creates that makes it incompatible with
ELF or is it simply work that noone has cared enough
about to actually do?

-jim

Thomas F. Burdick wrote:
> Jim Newton <·····@rdrop.com> writes:
> 
> 
>>does anyone know of a lisp compiler that compiles
>>to ELF format?  apparently cmucl compiles to a.out.
>>
>>For example what formats do lispworks, sbcl,
>>and lispworks or gcl compile to?
> 
> 
> CMUCL, SBCL, and OpenMCL all compile to custom-format fasl files.  GCL
> and ECL use C as an intermediary language, so they produce fasls in
> the format the system C compiler uses (ELF or Mach-O).  I'm not sure
> about LW or Allegro, but I'd bet they both use custom fasl formats.  I
> looked a bit at writing a Mach-O format fasl dumper for SBCL, and it
> should be fairly straightforward, but I have too much on my plate
> already.
> 
> Now for the obvious question, why do you care about the fasl format
> your lisp uses?  One reason might be because you want the code for a
> library to be shared between different Lisp processes that use it --
> at the moment, I think the only easy way to do this is to dump a core
> with the library loaded.
From: R. Mattes
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <pan.2004.12.11.21.03.16.136361@mh-freiburg.de>
On Sat, 11 Dec 2004 19:30:32 +0100, Jim Newton wrote:

> has anyone done any work to try to make any of the popular
> lisp compilers create elf format?  i know less than nothing
> about elf, but it has to be just some sort of loader or
> wrapper around the compiled program.  am i thinking about
> it too simplisitically?    If cmucl for example could
> produce an elf file then you could compile stand alone
> lisp programs right?  of course there would have to
> be some dynamically linkable library somewhere which
> provides the lisp engine.

Well, AFAIK at least GCL does exactly this - you can
call (link ...) on a list of object files and this
will create a "standalone" executable linked with
the gcl library (using the system's native linker).
IIRC ecl does similar things - it's even possible to 
link your compiled lisp code into a C based application
(so one can use ECL embedded).

> Is the some low level difference between what the
> lisp compiler creates that makes it incompatible with
> ELF or is it simply work that noone has cared enough
> about to actually do?

Well, i'm not a loader expert but ELF (as well as a.out)
is object code PLUS linking information (and more). I think
the needs for a fasl and linkable object code are quite different.

 Ralf Mattes

> 
> -jim
> 
> Thomas F. Burdick wrote:
>> Jim Newton <·····@rdrop.com> writes:
>> 
>> 
>>>does anyone know of a lisp compiler that compiles
>>>to ELF format?  apparently cmucl compiles to a.out.
>>>
>>>For example what formats do lispworks, sbcl,
>>>and lispworks or gcl compile to?
>> 
>> 
>> CMUCL, SBCL, and OpenMCL all compile to custom-format fasl files.  GCL
>> and ECL use C as an intermediary language, so they produce fasls in
>> the format the system C compiler uses (ELF or Mach-O).  I'm not sure
>> about LW or Allegro, but I'd bet they both use custom fasl formats.  I
>> looked a bit at writing a Mach-O format fasl dumper for SBCL, and it
>> should be fairly straightforward, but I have too much on my plate
>> already.
>> 
>> Now for the obvious question, why do you care about the fasl format
>> your lisp uses?  One reason might be because you want the code for a
>> library to be shared between different Lisp processes that use it --
>> at the moment, I think the only easy way to do this is to dump a core
>> with the library loaded.
From: Julian Stecklina
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <86k6rnpiq0.fsf@goldenaxe.localnet>
"R. Mattes" <··@mh-freiburg.de> writes:

> Well, AFAIK at least GCL does exactly this - you can
> call (link ...) on a list of object files and this
> will create a "standalone" executable linked with
> the gcl library (using the system's native linker).
> IIRC ecl does similar things - it's even possible to 
> link your compiled lisp code into a C based application
> (so one can use ECL embedded).

Yes, this is pretty cool. I have written an ECL plugin for
X-Chat. This works by providing a shared library for X-Chat written in
C and CL which is merely 83K in size. ECL itself is loaded as shared
library, too, and is also quite small for a Lisp environment (3.3M).

Regards,
-- 
                    ____________________________
 Julian Stecklina  /  _________________________/
  ________________/  /
  \_________________/  LISP - truly beautiful
From: Kristian Elof Sørensen
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <41be08c6$0$172$edfadb0f@dread11.news.tele.dk>
Jim Newton wrote:
> does anyone know of a lisp compiler that compiles
> to ELF format?  apparently cmucl compiles to a.out.
> 
> For example what formats do lispworks, sbcl,
> and lispworks or gcl compile to?
> 
> -jim
> 

Lispworks and Allegro can do it.

Lispworks creates a single executable file that includes your program, 
any 3. party lisp code you are using, the lisp runtime, the compiler, 
top level etc. It is smart about omitting unused code to keep the size 
of the executable down. 4-5 MB is archiveable if you are not using that 
many libraries.

So installation instructions to your users consists of "Place this file 
on your desktop and double click on it." This is a real enabler for 
successfully delivering applications to end users.

I think Allegro does the same, but have not tried myself.

Neither can do this in their free/personal/trial versions, only in the 
"for money" versions. Price and conditions for Lispworks are on their 
website. Allegro prices and conditions are secret and somewhat 
negotiable, you have to ask them, to find out what the price is for your 
situation.

	Kristian
From: Peter Herth
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <cpm99q$hgj$1@newsreader2.netcologne.de>
As both Cmucl/SBCL work by loading their core file from a small startup 
executable, my way to create "stand-allone" executables was to save a
custom core with my program, and bundle this with a renamed copy of the
startup executable and a small shell script which just called this
program with the parameter --core mycore  to start the lisp application.
But it would be great, if those lisps had an option to create a single
executable file from their starter and a specified core file so this
process becomes a bit more streamlined.

Peter

-- 
pet project: http://dawn.netcologne.de
homepage:    http://www.peter-herth.de
lisp stuff:  http://www.peter-herth.de/lisp.html
get Ltk here: http://www.peter-herth.de/ltk/
From: Fred Gilham
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <u7is74uc1g.fsf@snapdragon.csl.sri.com>
Peter Herth <·····@netcologne.de> writes:

> As both Cmucl/SBCL work by loading their core file from a small startup 
> executable, my way to create "stand-allone" executables was to save a
> custom core with my program, and bundle this with a renamed copy of the
> startup executable and a small shell script which just called this
> program with the parameter --core mycore  to start the lisp application.
> But it would be great, if those lisps had an option to create a single
> executable file from their starter and a specified core file so this
> process becomes a bit more streamlined.

It can be done.  I did it.  But if you want to do it in a portable
way, you have to teach CMUCL how to write valid ELF executables.

The way I did it was to have save-lisp write out three ELF object
files, corresponding to CMUCL's three memory areas, then I used ld to
link those object files along with the rest of the files that make up
the lisp binary into an executable.  I had to use a linker script (to
see what a linker script is, type ld --verbose) to tell the linker how
to lay things out in memory.

It was nice because it worked the same way any other executable would
work, including mmapping and demand paging the CMUCL memory areas.

Unfortunately this is non-portable.  The required linker script would
differ from OS to OS.  For example, I don't remember ever getting it
to work for Solaris.  When I found out that it also differed from OS
release to OS release, I gave up on it as a valid approach.

-- 
Fred Gilham                                         ······@csl.sri.com
I'm skeptical about attempts to proclaim hell to people that don't
already have the taste of it in their mouths.  Hell as the ultimate
loss of relationship, of health, of even sanity, makes sense to
someone who already sees the beginnings of that process taking hold in
his own life.  Hell as an imaginary place that is like being sent to
your room for a long, long time, with the heat turned up really high,
doesn't make sense.
From: Oyvin Halfdan Thuv
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <cpmq3f$ki1$1@orkan.itea.ntnu.no>
Peter Herth wrote:
> As both Cmucl/SBCL work by loading their core file from a small startup 
> executable, my way to create "stand-allone" executables was to save a
> custom core with my program, and bundle this with a renamed copy of the
> startup executable and a small shell script which just called this
> program with the parameter --core mycore  to start the lisp application.
> But it would be great, if those lisps had an option to create a single
> executable file from their starter and a specified core file so this
> process becomes a bit more streamlined.

The SBCL guys are trying: "sb-executable::make-executable" creates a 
shell script using some automated magic. I don't think it creates a core 
file for your app, but rather puts compiled lisp code into your script 
so that you can run that code in whatever core you like.

-- 
�yvin
From: Peter Herth
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <cpnp20$ae3$1@newsreader2.netcologne.de>
Oyvin Halfdan Thuv wrote:

> The SBCL guys are trying: "sb-executable::make-executable" creates a 
> shell script using some automated magic. I don't think it creates a core 
> file for your app, but rather puts compiled lisp code into your script 
> so that you can run that code in whatever core you like.

Yes I have seen this facility. But I deem it even less usefull than my
solution, since the user has to preinstall sbcl first (besides that even 
  loading compiled code takes quite long while loading a core is nearly 
instaneous). So putting just the starter and a core in a single 
executable file would give very nice executables. Of course not very 
small, but in our times acceptable for most tasks.

Peter



-- 
pet project: http://dawn.netcologne.de
homepage:    http://www.peter-herth.de
lisp stuff:  http://www.peter-herth.de/lisp.html
get Ltk here: http://www.peter-herth.de/ltk/
From: Christopher C. Stacy
Subject: Re: lisp compiling to elf
Date: 
Message-ID: <u3by61ezn.fsf@news.dtpq.com>
Jim Newton <·····@rdrop.com> writes:
> does anyone know of a lisp compiler that compiles
> to ELF format?  apparently cmucl compiles to a.out.

What are you really trying to do?