chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Static eggs query (was Re: [Chicken-users] ok my first egg is ready)


From: Peter Wright
Subject: Static eggs query (was Re: [Chicken-users] ok my first egg is ready)
Date: Tue, 6 Nov 2007 20:08:16 +0900
User-agent: Mutt/1.5.16 (2007-06-11)

Hi all,

This egg announcement inspired me to ask a couple of questions -

On 06/11 07:09:28, felix winkelmann wrote:
> On 11/6/07, naruto canada <address@hidden> wrote:
> > ok my first egg is ready.
[ ... ]
> > http://downloads.sourceforge.net/math-linux/predicate-calculus.egg
> 
> Thanks, Naruto!
> 
> I have added the egg to the repository, it should be available soon.

I've recently been trying to work out how to build a Chicken app with
statically-linked extensions. This was useful:

http://galinha.ucpel.tche.br:8080/chicken-setup#linking-extensions-statically

The instructions mostly worked correctly (see example below), though
the only way I could think to make absolutely sure it was linking an
extension statically was to make the contents of
/usr/local/lib/chicken/3 temporarily unreadable.

Using Naruto's predicate-calculus egg as a test (thanks, Naruto :)), I
modified the predicate-calculus.setup as described in the above link
(patch attached) and rebuilt/reinstalled it - then made a trivial test
program:

---------------- pct.scm --------------------------------------------
(declare (uses predicate-calculus))
(begin
  (display "This is a static-linking test.")
  (newline)
  (write (clausal-form '(all x (all y (=> (P x y) (Q x y))))))
  (newline)
  (display "The above line should show \"(((not (P ?x10 ?x11)) (Q ?x10 
?x11)))\".")
  (newline))
---------------- pct.scm --------------------------------------------

I managed to build a standalone executable like so (using '$' to
indicate a shell prompt):

$ csc -c++ -static-extensions -c pct.scm
$ csc -c++ -static-libs pct.o /usr/local/lib/chicken/3/predicate-calculus.o -o 
pct

(though the -static-libs wasn't necessary just to link the extension
statically, of course)

Anyway, the upshot is that I have two questions. If anyone can suggest
an answer (or two), that'd be good :-).

First - is there a "nicer" way to build a Chicken app with
statically-linked extensions?

To clarify, I mean that I couldn't figure out a way to build a working
pct without explicitly including /usr/local/lib/chicken/3/predicate-calculus.o
in the link phase (see above).

Is there a way to avoid this? The chicken-setup link above suggests
that it could be done like the below, but this doesn't work:

$ csc -static-extensions pct.scm -uses predicate-calculus
pct.o: In function `f_26':
pct.c:(.text+0x5cc): undefined reference to `C_predicate_calculus_toplevel'
pct.o: In function `f_23':
pct.c:(.text+0x643): undefined reference to `C_predicate_calculus_toplevel'
collect2: ld returned 1 exit status
*** Shell command terminated with exit status 1: gcc pct.o -o pct 
-L/usr/local/lib  -Wl,-R/usr/local/lib -lm -ldl -lchicken
$ 

This doesn't really matter a _great_ deal - I can explicitly link the
extension .o files in the final link phase without too much effort - I
just feel that it should be something the compiler can work out for me.
Maybe. :)


Second question (or perhaps a group of questions) - does anyone have
any idea how many of the 348 or so Chicken eggs are set up for static
linking? The link I mentioned above states:

  If you require a statically linkable version of an egg that has not been
  converted yet, contact the extension author or the CHICKEN mailing list.

Is there a Grand Plan(tm) to convert existing eggs for static linking?
It looks like the process should be pretty straightforward, but just
hasn't been done yet for some (many? most? all?) eggs.

Of course I appreciate that some (many? most?) Chicken users may not
care very much about statically-linkable extensions, but... er...
well, I think some of us do. :)

If it's largely a matter of just doing the boring grunt work of
patching the .setup files and testing... well, I'm happy to try doing
that, at least for the eggs that I use most frequently (Naruto, see
attached :)).

Or are there some hideously tricky potential problems that I haven't
noticed yet? If so, I bet it involves those bloody macros. Sigh.

> BTW, the current egg count is 348. Two more to go!

I'm sure CPAN will have to admit defeat soon. :-)

> cheers,
> felix

Thanks,

Pete.
-- 
"Expressions including c (call-with-current-continuation) function
calls tend to be hopelessly difficult to track down. This was, of
course, the reason for including it in the language in the first place."
    -- Unlambda: Your Functional Programming Language Nightmares Come True

Attachment: pred-calc-static.setup.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]