John Leuner | 14 Apr 18:27

port of jolt-burg

I've been working on an experimental port of jolt-burg. The main difference is that my implementation language is Common Lisp and that my compiler targets relocatable ELF object files.

Currently I have a compiler that can read sexp input, eg:

(define |main| (lambda ()
        ((call-c |dlsym| 0 "puts") "hello, dynamic world!")))

and then compile it down to a tree of blocks and instruction objects (see instruction.lisp or Instruction.st) BLOCK(--- NIL ---)                                                                                                                                  &n bsp;                      | | 0(--- VOID BLOCK --- 369                                                                                                                                &nbs p;              | | | | | 0(+++ REG CALLI4 ---                                                                                                                                &n bsp;            | | | | | | 0(+++ REG CNSTP4 --- reloc ---)                                                                                                                              & nbsp; | | | | | | 0(+++ REG CNSTI4 --- 0)                                                                                                                               &nb sp;        | | | | | | 0(+++ REG CNSTP4 --- reloc ---))                                                                                                                               | | | | | 0(+++ REG CNSTP4 --- reloc ---))                                                                                                                              &n bsp;  | | 0(--- VOID BLOCK --- 369                                                                                                                                &nbs p;              | | | | | 0(+++ REG CALLI4 EBX                                                                                                                                &n bsp;            | | | | | | 0(+++ REG CNSTP4 EBX reloc ---)                                                                                                                              & nbsp; | | | | | | 0(+++ REG CNSTI4 EAX 0)                                                                                                                               &nb sp;        | | | | | | 0(+++ REG CNSTP4 ECX reloc ---))                                                                                                                               | | | | | 0(+++ REG CNSTP4 EAX reloc ---))                      
This tree is processed by the burg compiler to emit x86 machine code. (in the diagram we see registers being assigned to the tree nodes)

The last stage is when I collect the machine code generated by the burg compiler and combine it with data and relocation entries to generate an ELF object file.

I can then pass this to the unix linker (ld) to produce an executable.

ld --dynamic-linker=/lib/ld-linux.so.2 state/start.o state/hello.state.o -ldl  -lc -o myhello

Here you can see the disassembled elf object file with relocation entries for the "dlsym" symbol and the "puts" and "hello world" strings.

objdump -d state/hello.state.o -r

Disassembly of section .text: 00000000 <main>:    0:   55                      push   %ebp    1:   89 e5                   mov    %esp,%ebp    3:   53                      push   %ebx    4:   83 ec 14                sub    $0x14,%esp    7:   bb 00 00 00 00          mov    $0x0,%ebx                         8: R_386_32     dlsym    c:   b8 00 00 00 00          mov    $0x0,%eax   11:   b9 00 00 00 00          mov    $0x0,%ecx                         12: R_386_32    _data_286   16:   89 4c 24 04             mov    %ecx,0x4(%esp)   1a:   89 04 24                mov    %eax,(%esp)   1d:   ff d3                   call   *%ebx   1f:   89 c3                   mov    %eax,%ebx   21:   b8 00 00 00 00          mov    $0x0,%eax                         22: R_386_32    _data_287   26:   89 04 24                mov    %eax,(%esp)   29:   ff d3                   call   *%ebx   2b:   89 c0                   mov    %eax,%eax   2d:   89 c0                   mov    %eax,%eax   2f:   83 c4 14                add    $0x14,%esp   32:   5b                      pop    %ebx   33:   5d                      pop    %ebp   34:   c3                      ret    You can view the code at:

http://subvert-the-dominant-paradigm.net/repos/hgwebdir.cgi/bootstrap/

(click manifest to see the files, or run 'hg clone <url>' to get a local copy)

John Leuner

<div>
I've been working on an experimental port of jolt-burg. The main difference is that my implementation language is Common Lisp and that my compiler targets relocatable ELF object files.<br><br>
Currently I have a compiler that can read sexp input, eg:<br><br>
(define |main| (lambda ()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((call-c |dlsym| 0 "puts") "hello, dynamic world!")))<br><br>
and then compile it down to a tree of blocks and instruction objects (see instruction.lisp or Instruction.st)

BLOCK(--- NIL ---)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

| | | | | 0(+++ REG CNSTP4 EAX reloc ---))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

<br>
This tree is processed by the burg compiler to emit x86 machine code. (in the diagram we see registers being assigned to the tree nodes)<br><br>
The last stage is when I collect the machine code generated by the burg compiler and combine it with data and relocation entries to generate an ELF object file.<br><br>
I can then pass this to the unix linker (ld) to produce an executable.<br><br>
ld --dynamic-linker=/lib/ld-linux.so.2 state/start.o state/hello.state.o -ldl&nbsp; -lc -o myhello<br><br>
Here you can see the disassembled elf object file with relocation entries for the "dlsym" symbol and the "puts" and "hello world" strings.<br><br>
objdump -d state/hello.state.o -r<br><br>
Disassembly of section .text:

00000000 &lt;main&gt;:
&nbsp;&nbsp; 0:&nbsp;&nbsp; 55&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pop&nbsp;&nbsp;&nbsp; %ebx
&nbsp; 33:&nbsp;&nbsp; 5d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pop&nbsp;&nbsp;&nbsp; %ebp
&nbsp; 34:&nbsp;&nbsp; c3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp; 

You can view the code at:<br><br><a href="http://subvert-the-dominant-paradigm.net/repos/hgwebdir.cgi/bootstrap/">http://subvert-the-dominant-paradigm.net/repos/hgwebdir.cgi/bootstrap/</a><br><br>
(click manifest to see the files, or run 'hg clone &lt;url&gt;' to get a local copy)<br><br>
John Leuner<br><br>
</div>
Michael FIG | 24 Apr 07:43
Favicon

static compilation [was: port of jolt-burg]

John Leuner <jewel@...> writes:

> I've been working on an experimental port of jolt-burg. The main difference is
> that my implementation language is Common Lisp and that my compiler targets
> relocatable ELF object files.

Interesting!

I was inspired by you, and tried my hand at getting similar changes
into jolt2.  The attached patch should apply cleanly on top of SVN
-r407, followed by my jolt2-fixes.patch that I posted earlier.

Here is the function/examples2/slink/README file (also included in the
attached jolt2-slink.patch) for more information:

SLINK 0.2
*********

Slink is the beginning of a statically-linking compiler extension for
Jolt2 (think "Static LINK" or "System LINK").  It was partly inspired
by John Leuner's Common Lisp port of jolt-burg that creates
relocatable ELF objects.  I'm basically attempting to land the same
kinds of features in COLA proper without changing too much of the
existing compiler machinery.

It has many limitations, but is a proof-of-concept and will probably
evolve (the main direction for evolution is to make the changes less
and less dependent on patching Jolt2's Id sources directly, and
instead accomplish its features at runtime via slink.k and friends).

The centerpiece of this system is slink-compile, which currently can
only generate i386 assembly code.  The following new syntax is
introduced:

(define (slink SYMBOL))
  Import SYMBOL from the system linker.  If running with the dynamic
  compiler, this is equivalent to:

     (active SYMBOL (dlsym "SYMBOL"))

  If under the static compiler (slink-compile), this will cause future
  references to SYMBOL to be resolved at link time rather than
  runtime.

(define (slink SYMBOL) EXPRESSION)
  Create a region of memory containing the results of EXPRESSION.
  SYMBOL is exported to the system linker.  Only expressions resulting
  in integers, strings, floats, and lambdas currently work.

To get a feel for things, run "make test" which exercises slink both
at runtime and compile time.  You'll notice that the results of this
execution are a binary executable (slinktest) with no runtime
dependency on COLA.

IMPLEMENTATION
**************

I did a lot of work creating a bunch of slink-specific methods in the
existing COLA compiler.  Now I'm gradually undoing as much of that
work as possible to leave only the core features in Jolt2, so that the
rest can be just another unprivileged application.

Once you understand what the slink syntax does, it shouldn't be too
hard to follow what I needed to do to get things working.  A "grep -i
slink *.st" is very informative (and half the reason I needed to find
a catchy name that wouldn't be buried in the other identifiers).

Toplevel Jolt expressions are gathered up and attached to the system's
initialisation functions so that they are executed at program start
(for i386, using the same method as C++ constructors).

The syntax and actives systems will need to be revisited, probably to
do something like Scheme-48 where a "load-syntax" or "require-syntax"
will import only the syntax elements into the namespace (thereby
avoiding problems with importing undesired lambdas and toplevel code
evaluation by accident).

It would be really nice to implement a few more CodeGenerator backends
to bypass assembly language entirely and generate binaries.

Slink has a naive three-region model for assembler output.  First
comes a bss section with all the variables, then a data section with
all the strings, then finally a text section with all the compiled
functions.  To my knowledge, this is adequate for the platforms on
which COLA already runs, but of course it would be good to be able to
provide something akin to linker scripts in the future to allow much
more flexible layout.

Have fun,

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//

Attachment (jolt2-slink.patch): text/x-diff, 39 KiB
John Leuner <jewel@...> writes:

> I've been working on an experimental port of jolt-burg. The main difference is
> that my implementation language is Common Lisp and that my compiler targets
> relocatable ELF object files.

Interesting!

I was inspired by you, and tried my hand at getting similar changes
into jolt2.  The attached patch should apply cleanly on top of SVN
-r407, followed by my jolt2-fixes.patch that I posted earlier.

Here is the function/examples2/slink/README file (also included in the
attached jolt2-slink.patch) for more information:

SLINK 0.2
*********

Slink is the beginning of a statically-linking compiler extension for
Jolt2 (think "Static LINK" or "System LINK").  It was partly inspired
by John Leuner's Common Lisp port of jolt-burg that creates
relocatable ELF objects.  I'm basically attempting to land the same
kinds of features in COLA proper without changing too much of the
existing compiler machinery.

It has many limitations, but is a proof-of-concept and will probably
evolve (the main direction for evolution is to make the changes less
and less dependent on patching Jolt2's Id sources directly, and
instead accomplish its features at runtime via slink.k and friends).

The centerpiece of this system is slink-compile, which currently can
only generate i386 assembly code.  The following new syntax is
introduced:

(define (slink SYMBOL))
  Import SYMBOL from the system linker.  If running with the dynamic
  compiler, this is equivalent to:

     (active SYMBOL (dlsym "SYMBOL"))

  If under the static compiler (slink-compile), this will cause future
  references to SYMBOL to be resolved at link time rather than
  runtime.

(define (slink SYMBOL) EXPRESSION)
  Create a region of memory containing the results of EXPRESSION.
  SYMBOL is exported to the system linker.  Only expressions resulting
  in integers, strings, floats, and lambdas currently work.

To get a feel for things, run "make test" which exercises slink both
at runtime and compile time.  You'll notice that the results of this
execution are a binary executable (slinktest) with no runtime
dependency on COLA.

IMPLEMENTATION
**************

I did a lot of work creating a bunch of slink-specific methods in the
existing COLA compiler.  Now I'm gradually undoing as much of that
work as possible to leave only the core features in Jolt2, so that the
rest can be just another unprivileged application.

Once you understand what the slink syntax does, it shouldn't be too
hard to follow what I needed to do to get things working.  A "grep -i
slink *.st" is very informative (and half the reason I needed to find
a catchy name that wouldn't be buried in the other identifiers).

Toplevel Jolt expressions are gathered up and attached to the system's
initialisation functions so that they are executed at program start
(for i386, using the same method as C++ constructors).

The syntax and actives systems will need to be revisited, probably to
do something like Scheme-48 where a "load-syntax" or "require-syntax"
will import only the syntax elements into the namespace (thereby
avoiding problems with importing undesired lambdas and toplevel code
evaluation by accident).

It would be really nice to implement a few more CodeGenerator backends
to bypass assembly language entirely and generate binaries.

Slink has a naive three-region model for assembler output.  First
comes a bss section with all the variables, then a data section with
all the strings, then finally a text section with all the compiled
functions.  To my knowledge, this is adequate for the platforms on
which COLA already runs, but of course it would be good to be able to
provide something akin to linker scripts in the future to allow much
more flexible layout.

Have fun,

--

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//

John Leuner | 24 Apr 16:41

Re: static compilation [was: port of jolt-burg]

On Wed, 2008-04-23 at 23:43 -0600, Michael FIG wrote:
> John Leuner <jewel@...> writes:
> 
> > I've been working on an experimental port of jolt-burg. The main difference is
> > that my implementation language is Common Lisp and that my compiler targets
> > relocatable ELF object files.
> 
> Interesting!
> 
> I was inspired by you, and tried my hand at getting similar changes
> into jolt2.  The attached patch should apply cleanly on top of SVN
> -r407, followed by my jolt2-fixes.patch that I posted earlier.
...
> It would be really nice to implement a few more CodeGenerator backends
> to bypass assembly language entirely and generate binaries.

It shouldn't be too different from what is there already. Although we
have a "static" and "dynamic" generator, the dynamic generator is
perfect for generating relocatable code which can then be linked into a
static executable.

> Slink has a naive three-region model for assembler output.  First
> comes a bss section with all the variables, then a data section with
> all the strings, then finally a text section with all the compiled
> functions.  To my knowledge, this is adequate for the platforms on
> which COLA already runs, but of course it would be good to be able to
> provide something akin to linker scripts in the future to allow much
> more flexible layout.

For my simple tests I have managed with a .text and .data segment (plus
a list of relocations and a symbol table).

I haven't implemented any initializers for static variables like you
have though.

John

Nathan Cain | 25 Apr 23:16

Re: static compilation [was: port of jolt-burg]

Hi Michael,

I was hoping to toy with this some, and start in on adapting an arm 
backend... unfortunately, the patch does not want to apply, as it seems 
to expect a different jolt2/boot.k then what is in svn r407.  Perhaps I 
need another of your patches as well, beyond just jolt2-fixes?  Could 
you tell me which?

I've attached my boot.k.rej for you to glance at.

Thanks for any help you can provide,
--Nathan

Michael FIG wrote:
> John Leuner <jewel@...> writes:
>
>   
>> I've been working on an experimental port of jolt-burg. The main difference is
>> that my implementation language is Common Lisp and that my compiler targets
>> relocatable ELF object files.
>>     
>
> Interesting!
>
> I was inspired by you, and tried my hand at getting similar changes
> into jolt2.  The attached patch should apply cleanly on top of SVN
> -r407, followed by my jolt2-fixes.patch that I posted earlier.
>
> Here is the function/examples2/slink/README file (also included in the
> attached jolt2-slink.patch) for more information:
>
> SLINK 0.2
> *********
>
> Slink is the beginning of a statically-linking compiler extension for
> Jolt2 (think "Static LINK" or "System LINK").  It was partly inspired
> by John Leuner's Common Lisp port of jolt-burg that creates
> relocatable ELF objects.  I'm basically attempting to land the same
> kinds of features in COLA proper without changing too much of the
> existing compiler machinery.
>
> It has many limitations, but is a proof-of-concept and will probably
> evolve (the main direction for evolution is to make the changes less
> and less dependent on patching Jolt2's Id sources directly, and
> instead accomplish its features at runtime via slink.k and friends).
>
> The centerpiece of this system is slink-compile, which currently can
> only generate i386 assembly code.  The following new syntax is
> introduced:
>
> (define (slink SYMBOL))
>   Import SYMBOL from the system linker.  If running with the dynamic
>   compiler, this is equivalent to:
>
>      (active SYMBOL (dlsym "SYMBOL"))
>
>   If under the static compiler (slink-compile), this will cause future
>   references to SYMBOL to be resolved at link time rather than
>   runtime.
>
> (define (slink SYMBOL) EXPRESSION)
>   Create a region of memory containing the results of EXPRESSION.
>   SYMBOL is exported to the system linker.  Only expressions resulting
>   in integers, strings, floats, and lambdas currently work.
>
> To get a feel for things, run "make test" which exercises slink both
> at runtime and compile time.  You'll notice that the results of this
> execution are a binary executable (slinktest) with no runtime
> dependency on COLA.
>
> IMPLEMENTATION
> **************
>
> I did a lot of work creating a bunch of slink-specific methods in the
> existing COLA compiler.  Now I'm gradually undoing as much of that
> work as possible to leave only the core features in Jolt2, so that the
> rest can be just another unprivileged application.
>
> Once you understand what the slink syntax does, it shouldn't be too
> hard to follow what I needed to do to get things working.  A "grep -i
> slink *.st" is very informative (and half the reason I needed to find
> a catchy name that wouldn't be buried in the other identifiers).
>
> Toplevel Jolt expressions are gathered up and attached to the system's
> initialisation functions so that they are executed at program start
> (for i386, using the same method as C++ constructors).
>
> The syntax and actives systems will need to be revisited, probably to
> do something like Scheme-48 where a "load-syntax" or "require-syntax"
> will import only the syntax elements into the namespace (thereby
> avoiding problems with importing undesired lambdas and toplevel code
> evaluation by accident).
>
> It would be really nice to implement a few more CodeGenerator backends
> to bypass assembly language entirely and generate binaries.
>
> Slink has a naive three-region model for assembler output.  First
> comes a bss section with all the variables, then a data section with
> all the strings, then finally a text section with all the compiled
> functions.  To my knowledge, this is adequate for the platforms on
> which COLA already runs, but of course it would be good to be able to
> provide something akin to linker scripts in the future to allow much
> more flexible layout.
>
> Have fun,
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> fonc mailing list
> fonc@...
> http://vpri.org/mailman/listinfo/fonc

***************
*** 194,200 ****
  ;; Add features that aren't present in the original grammar.
  (define ColaFunctionGrammar (import "ColaFunctionGrammar"))
  (define Integer (import "Integer"))
- ['{
       // Add character literals ($CHAR)
       atom = number | charLiteral | identifier | string
       charLiteral = '$' char->0				<- [self @ '0]
--- 195,201 ----
  ;; Add features that aren't present in the original grammar.
  (define ColaFunctionGrammar (import "ColaFunctionGrammar"))
  (define Integer (import "Integer"))
+ (define new-grammar '{
       // Add character literals ($CHAR)
       atom = number | charLiteral | identifier | string
       charLiteral = '$' char->0				<- [self @ '0]
***************
*** 217,223 ****
       ;
       EXTENDS: ColaFunctionGrammar // Import from the default grammar.
       expression // Start term
-   } name: 'JoltBurgCompatibleFunctionGrammar]

  (load "syntax.k")
  (load "debug.k")
--- 218,227 ----
       ;
       EXTENDS: ColaFunctionGrammar // Import from the default grammar.
       expression // Start term
+   })
+ 
+ [new-grammar name: 'ColaFunctionGrammar]
+ (export "ColaFunctionGrammar" new-grammar)

  (load "syntax.k")
  (load "debug.k")
***************
*** 194,200 ****
  ;; Add features that aren't present in the original grammar.
  (define ColaFunctionGrammar (import "ColaFunctionGrammar"))
  (define Integer (import "Integer"))
- ['{
       // Add character literals ($CHAR)
       atom = number | charLiteral | identifier | string
       charLiteral = '$' char->0				<- [self @ '0]
--- 195,201 ----
  ;; Add features that aren't present in the original grammar.
  (define ColaFunctionGrammar (import "ColaFunctionGrammar"))
  (define Integer (import "Integer"))
+ (define new-grammar '{
       // Add character literals ($CHAR)
       atom = number | charLiteral | identifier | string
       charLiteral = '$' char->0				<- [self @ '0]
***************
*** 217,223 ****
       ;
       EXTENDS: ColaFunctionGrammar // Import from the default grammar.
       expression // Start term
-   } name: 'JoltBurgCompatibleFunctionGrammar]

  (load "syntax.k")
  (load "debug.k")
--- 218,227 ----
       ;
       EXTENDS: ColaFunctionGrammar // Import from the default grammar.
       expression // Start term
+   })
+ 
+ [new-grammar name: 'ColaFunctionGrammar]
+ (export "ColaFunctionGrammar" new-grammar)

  (load "syntax.k")
  (load "debug.k")
Michael FIG | 26 Apr 00:21
Favicon

Slink 0.3 [was: static compilation]

Hi,

Nathan Cain <nate@...> writes:

> I was hoping to toy with this some, and start in on adapting an arm
> backend...

Cool!  I'd be more than happy to help with this process, if you need
any assistance at all.  I think most of it should be relatively
straightforward by staring at the patch to CodeGenerator-i386.st.

> unfortunately, the patch does not want to apply, as it seems to
> expect a different jolt2/boot.k then what is in svn r407.  Perhaps I
> need another of your patches as well, beyond just jolt2-fixes?
> Could you tell me which?

Actually, I just described the patch requirements really badly.  The
idea is:

$ svn checkout -r407 ...
$ cd idst
$ patch -p0 < ../jolt2-fixes.patch
$ patch -p0 < ../jolt2-slink.patch

I've attached new versions of these patches that fix a few issues
(forgot the '{...} grammar syntax in jolt2-fixes.patch, mangle Jolt
names that can't be directly expressed in the output) and demonstrates
the use of (syntax ...) in function/examples2/slink/main.k.

Good luck,

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//

Attachment (jolt2-fixes.patch): text/x-diff, 13 KiB
Attachment (jolt2-slink.patch): text/x-diff, 40 KiB
Hi,

Nathan Cain <nate@...> writes:

> I was hoping to toy with this some, and start in on adapting an arm
> backend...

Cool!  I'd be more than happy to help with this process, if you need
any assistance at all.  I think most of it should be relatively
straightforward by staring at the patch to CodeGenerator-i386.st.

> unfortunately, the patch does not want to apply, as it seems to
> expect a different jolt2/boot.k then what is in svn r407.  Perhaps I
> need another of your patches as well, beyond just jolt2-fixes?
> Could you tell me which?

Actually, I just described the patch requirements really badly.  The
idea is:

$ svn checkout -r407 ...
$ cd idst
$ patch -p0 < ../jolt2-fixes.patch
$ patch -p0 < ../jolt2-slink.patch

I've attached new versions of these patches that fix a few issues
(forgot the '{...} grammar syntax in jolt2-fixes.patch, mangle Jolt
names that can't be directly expressed in the output) and demonstrates
the use of (syntax ...) in function/examples2/slink/main.k.

Good luck,

--

-- 
Michael FIG <michael@...> //\
   http://michael.fig.org/    \//

Nathan Cain | 26 Apr 00:37

Re: Slink 0.3 [was: static compilation]

Michael FIG wrote:
> Hi,
>
> Nathan Cain <nate@...> writes:
>
>   
>> I was hoping to toy with this some, and start in on adapting an arm
>> backend...
>>     
>
> Cool!  I'd be more than happy to help with this process, if you need
> any assistance at all.  I think most of it should be relatively
> straightforward by staring at the patch to CodeGenerator-i386.st.
>   
Yes, i've spent the past few days staring at it, alongside the original 
-i386 and the -arm generators, and think it's sufficiently stared at for 
a reasonable understanding of how it will come together.

>   
>> unfortunately, the patch does not want to apply, as it seems to
>> expect a different jolt2/boot.k then what is in svn r407.  Perhaps I
>> need another of your patches as well, beyond just jolt2-fixes?
>> Could you tell me which?
>>     
>
> Actually, I just described the patch requirements really badly.  The
> idea is:
>
> $ svn checkout -r407 ...
> $ cd idst
> $ patch -p0 < ../jolt2-fixes.patch
> $ patch -p0 < ../jolt2-slink.patch
>
> I've attached new versions of these patches that fix a few issues
> (forgot the '{...} grammar syntax in jolt2-fixes.patch, mangle Jolt
> names that can't be directly expressed in the output) and demonstrates
> the use of (syntax ...) in function/examples2/slink/main.k.
>   
Yup, it looks like this jolt2-fixes patch should resolve the problem I 
was running into with the slink patch.  I'll let you know how it goes 
from here!

Thanks much,
--Nathan

> Good luck,
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> fonc mailing list
> fonc@...
> http://vpri.org/mailman/listinfo/fonc


Gmane