TalkFFI: automatic FFI generation for Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

TalkFFI: automatic FFI generation for Pharo

Ciprian Teodorov-3
Happy new year everybody!

I am pleased to announce today the initial release of TalkFFI.

TalkFFI enables automatic FFI generation for Smalltalk.
It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
For now it supports the generation of NativeBoost FFI bindings.

The project is released under MIT license, and you can find it on the smalltalkhub site.
http://smalltalkhub.com/#!/~CipT/TalkFFI

Please do not hesitate send me your comments/critics/ideas.

Best regards,
--
Dr. Ciprian TEODOROV
Ingénieur Développement CAO

tél : 06 08 54 73 48
mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Mariano Martinez Peck
That's super awesome. Thanks!!
And the documentation answer that I was just going to ask you :)
"The libclang bindings themselves were also generated using TalkFFI (using minimal hand-written binding for bootstrapping)."

sweet :)

On Sun, Jan 6, 2013 at 1:22 PM, Ciprian Teodorov <[hidden email]> wrote:
Happy new year everybody!

I am pleased to announce today the initial release of TalkFFI.

TalkFFI enables automatic FFI generation for Smalltalk.
It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
For now it supports the generation of NativeBoost FFI bindings.

The project is released under MIT license, and you can find it on the smalltalkhub site.
http://smalltalkhub.com/#!/~CipT/TalkFFI

Please do not hesitate send me your comments/critics/ideas.

Best regards,
--
Dr. Ciprian TEODOROV
Ingénieur Développement CAO

tél : <a href="tel:06%2008%2054%2073%2048" value="+33608547348" target="_blank">06 08 54 73 48
mail : [hidden email]
www.teodorov.ro



--
Mariano
http://marianopeck.wordpress.com
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Marcus Denker-4

On Jan 6, 2013, at 7:07 PM, Mariano Martinez Peck <[hidden email]> wrote:

That's super awesome. Thanks!!
And the documentation answer that I was just going to ask you :)
"The libclang bindings themselves were also generated using TalkFFI (using minimal hand-written binding for bootstrapping)."

sweet :)

Yes, that looks very interesting!

Marcus


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Ciprian Teodorov-3
Hi guys, 

I have just uploaded a short presentation video on youtube (generation of LLVM mapping), so that you can get the taste of it.

http://youtu.be/y_zfgUh27m0

On Sun, Jan 6, 2013 at 7:18 PM, Marcus Denker <[hidden email]> wrote:

On Jan 6, 2013, at 7:07 PM, Mariano Martinez Peck <[hidden email]> wrote:

That's super awesome. Thanks!!
And the documentation answer that I was just going to ask you :)
"The libclang bindings themselves were also generated using TalkFFI (using minimal hand-written binding for bootstrapping)."

sweet :)

Yes, that looks very interesting!

Marcus





--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stéphane Ducasse
In reply to this post by Ciprian Teodorov-3
Thanks Ciprian. It is a nice extension :).
we should write a little tutorial :)

Stef


> Happy new year everybody!
>
> I am pleased to announce today the initial release of TalkFFI.
>
> TalkFFI enables automatic FFI generation for Smalltalk.
> It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
> For now it supports the generation of NativeBoost FFI bindings.
>
> The project is released under MIT license, and you can find it on the smalltalkhub site.
> http://smalltalkhub.com/#!/~CipT/TalkFFI
>
> Please do not hesitate send me your comments/critics/ideas.
>
> Best regards,
> --
> Dr. Ciprian TEODOROV
> Ingénieur Développement CAO
>
> tél : 06 08 54 73 48
> mail : [hidden email]
> www.teodorov.ro


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Ciprian Teodorov-3


On Sun, Jan 6, 2013 at 7:31 PM, Stéphane Ducasse <[hidden email]> wrote:
Thanks Ciprian. It is a nice extension :).
we should write a little tutorial :)
Yes a tutorial will come too ... but first I want to test it a little more, and maybe get some feedback from volunteers ;)

I will have to check if it works on other platforms besides my mac.
Then figure a way to package/distribute easily with libclang - since compiling libclang might not be trivial for a user.

Moreover If any of you guys have comments, different usage scenarios, api improvement ideas please don't hesitate.

Cheers,
Ciprian

Stef


> Happy new year everybody!
>
> I am pleased to announce today the initial release of TalkFFI.
>
> TalkFFI enables automatic FFI generation for Smalltalk.
> It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
> For now it supports the generation of NativeBoost FFI bindings.
>
> The project is released under MIT license, and you can find it on the smalltalkhub site.
> http://smalltalkhub.com/#!/~CipT/TalkFFI
>
> Please do not hesitate send me your comments/critics/ideas.
>
> Best regards,
> --
> Dr. Ciprian TEODOROV
> Ingénieur Développement CAO
>
> tél : 06 08 54 73 48
> mail : [hidden email]
> www.teodorov.ro





--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stéphane Ducasse
>
> Yes a tutorial will come too ... but first I want to test it a little more, and maybe get some feedback from volunteers ;)

excellent!
For the video, may be use larger fonts.

> I will have to check if it works on other platforms besides my mac.
> Then figure a way to package/distribute easily with libclang - since compiling libclang might not be trivial for a user.
>
> Moreover If any of you guys have comments, different usage scenarios, api improvement ideas please don't hesitate.
>
> Cheers,
> Ciprian
>
> Stef
>
>
> > Happy new year everybody!
> >
> > I am pleased to announce today the initial release of TalkFFI.
> >
> > TalkFFI enables automatic FFI generation for Smalltalk.
> > It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
> > For now it supports the generation of NativeBoost FFI bindings.
> >
> > The project is released under MIT license, and you can find it on the smalltalkhub site.
> > http://smalltalkhub.com/#!/~CipT/TalkFFI
> >
> > Please do not hesitate send me your comments/critics/ideas.
> >
> > Best regards,
> > --
> > Dr. Ciprian TEODOROV
> > Ingénieur Développement CAO
> >
> > tél : 06 08 54 73 48
> > mail : [hidden email]
> > www.teodorov.ro
>
>
>
>
>
> --
> Dr. Ciprian TEODOROV
> Ingénieur Développement CAO
>
> tél : 06 08 54 73 48
> mail : [hidden email]
> www.teodorov.ro


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Igor Stasenko
Wow.. that's great.
Having a way to automatically generate bindings makes life much easier :)

Few questions:
 - did you tried to run it against some libraries around there, except
from LLVM?

- i saw, in video, you can customize generation a bit.. to what
extent? Is there interface
(suppose i want to use own naming prefix, suppress generation of
certain declaration etc)?

--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Ciprian Teodorov-3

hi Igor,

Yes I have tried some little external libraries, nothing big yet (besides llvm, and libclang). For the moment I did not see any show-stopper problems... But there are still some rough edges. What I have under scrutiny right now are:
- adding unions to NB
- supporting vectors (and constant arrays, which are flattened right now). Vectors appear to be used in cblas.
- there are some problems with my callback naming scheme, which I found trying to map Cairo.

Besides these there are some improvements to NB, to simplify code generation and maintenance like:
- an unified parser for the simplified c declarations.
- unifying fieldDecl, enumDecl, fnSpec under a single naming convention... Maybe nativeSpec, or nativeDecl

For the customizations I think right now is to early to say that I have a good interface. But certainly over time we will have different filters. Right now you can customize fct names using a block, and u can specify a prefix for the generated classes.

I am also thinking about a graphical interface, somewhat on the lines of the dllcc in vw.

Anyways I think using libclang offers nice opportunities, maybe retrieving comments from headers, or even autocomplete-like ffi generation...

So yeah for now I will call TalkFFI a tech-preview... We will see how it goes ;)

Cheers

On Jan 7, 2013 1:13 AM, "Igor Stasenko" <[hidden email]> wrote:
>
> Wow.. that's great.
> Having a way to automatically generate bindings makes life much easier :)
>
> Few questions:
>  - did you tried to run it against some libraries around there, except
> from LLVM?
>
> - i saw, in video, you can customize generation a bit.. to what
> extent? Is there interface
> (suppose i want to use own naming prefix, suppress generation of
> certain declaration etc)?
>
> --
> Best regards,
> Igor Stasenko.
>

Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Igor Stasenko
On 7 January 2013 12:38, Ciprian Teodorov <[hidden email]> wrote:

> hi Igor,
>
> Yes I have tried some little external libraries, nothing big yet (besides
> llvm, and libclang). For the moment I did not see any show-stopper
> problems... But there are still some rough edges. What I have under scrutiny
> right now are:
> - adding unions to NB
> - supporting vectors (and constant arrays, which are flattened right now).
> Vectors appear to be used in cblas.
> - there are some problems with my callback naming scheme, which I found
> trying to map Cairo.
>
> Besides these there are some improvements to NB, to simplify code generation
> and maintenance like:
> - an unified parser for the simplified c declarations.
> - unifying fieldDecl, enumDecl, fnSpec under a single naming convention...
> Maybe nativeSpec, or nativeDecl
>

Feel free to discuss the details.
Getting NB more feature-complete won't hurt anyone :)

> For the customizations I think right now is to early to say that I have a
> good interface. But certainly over time we will have different filters.
> Right now you can customize fct names using a block, and u can specify a
> prefix for the generated classes.
>
> I am also thinking about a graphical interface, somewhat on the lines of the
> dllcc in vw.
>
> Anyways I think using libclang offers nice opportunities, maybe retrieving
> comments from headers, or even autocomplete-like ffi generation...
>
> So yeah for now I will call TalkFFI a tech-preview... We will see how it
> goes ;)
>

Yes, we should start from somewhere,  and it looks like a good starting point.
About customizations, i was thinking about SWIG-style customization
where you can write-down a list of rules, how you would like to
generate bindings to some concrete library + target language etc.

Since depending on the library, you will need some adjustments here or
there, you will find that we're
need that inevitably.


> Cheers
>
> On Jan 7, 2013 1:13 AM, "Igor Stasenko" <[hidden email]> wrote:
>>
>> Wow.. that's great.
>> Having a way to automatically generate bindings makes life much easier :)
>>
>> Few questions:
>>  - did you tried to run it against some libraries around there, except
>> from LLVM?
>>
>> - i saw, in video, you can customize generation a bit.. to what
>> extent? Is there interface
>> (suppose i want to use own naming prefix, suppress generation of
>> certain declaration etc)?
>>
>> --
>> Best regards,
>> Igor Stasenko.
>>



--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Göran Krampe
In reply to this post by Ciprian Teodorov-3
Hey!

On 01/06/2013 05:22 PM, Ciprian Teodorov wrote:
> Happy new year everybody!
>
> I am pleased to announce today the initial release of TalkFFI.

Wow! I have been waiting for something "SWIG" like for Squeak/Pharo
since... hell, I dunno, since like ever. ;)

This kind of stuff might very well be the most important "piece" of the
puzzle when it comes to *really* growing Pharo outside of the general
Smalltalk community.

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stéphane Ducasse
> On 01/06/2013 05:22 PM, Ciprian Teodorov wrote:
>> Happy new year everybody!
>>
>> I am pleased to announce today the initial release of TalkFFI.
>
> Wow! I have been waiting for something "SWIG" like for Squeak/Pharo since... hell, I dunno, since like ever. ;)
>
> This kind of stuff might very well be the most important "piece" of the puzzle when it comes to *really* growing Pharo outside of the general Smalltalk community.

yes!
:)
Let us escape the image :)


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

CdAB63
In reply to this post by Ciprian Teodorov-3
Repository refuses connection.

On 06-01-2013 14:22, Ciprian Teodorov wrote:
Happy new year everybody!

I am pleased to announce today the initial release of TalkFFI.

TalkFFI enables automatic FFI generation for Smalltalk.
It uses libclang to parse unmodified C header files and generate FFI bindings to c libraries.
For now it supports the generation of NativeBoost FFI bindings.

The project is released under MIT license, and you can find it on the smalltalkhub site.
http://smalltalkhub.com/#!/~CipT/TalkFFI

Please do not hesitate send me your comments/critics/ideas.

Best regards,
--
Dr. Ciprian TEODOROV
Ingénieur Développement CAO

tél : 06 08 54 73 48
mail : [hidden email]
www.teodorov.ro


signature.asc (269 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Göran Krampe
On 01/08/2013 06:26 PM, Casimiro de Almeida Barreto wrote:
> Repository refuses connection.

Works for me. Both anon or with my SH credentials.

regards, Göran


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Göran Krampe
In reply to this post by Ciprian Teodorov-3
Hey!

Got it installed in a Pharo 2.0 image etc. I am on Ubuntu 12.10 64. You
wrote I need libclang.so for 32 bits? And version 3.1 specifically?

Also, is there a "sanity test" I can run? That verifies libclang + NB etc.

I want to try this on a quite simple little C lib.

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stefan Marr-3
In reply to this post by Ciprian Teodorov-3
Hi Ciprian:

On 06 Jan 2013, at 17:22, Ciprian Teodorov wrote:
> The project is released under MIT license, and you can find it on the smalltalkhub site.
> http://smalltalkhub.com/#!/~CipT/TalkFFI

I was trying to play with TalkFFI, but it looks like libclang3.1 is not compiled correctly or something.

How do you build it? In your code I see you are also targeting OSX, so that doesn't seem to be the problem.

I was trying to use the MacPorts version of libclang3.1 without having set any special compiler flags.
So, I am not entirely sure whether it is build correctly.

Any hints are appreciate.

Thanks
Stefan


--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stefan Marr-3
Hi:

On 23 Jan 2013, at 15:28, Stefan Marr wrote:

> On 06 Jan 2013, at 17:22, Ciprian Teodorov wrote:
>> The project is released under MIT license, and you can find it on the smalltalkhub site.
>> http://smalltalkhub.com/#!/~CipT/TalkFFI
>
> I was trying to play with TalkFFI, but it looks like libclang3.1 is not compiled correctly or something.
>
> How do you build it? In your code I see you are also targeting OSX, so that doesn't seem to be the problem.
>
> I was trying to use the MacPorts version of libclang3.1 without having set any special compiler flags.
> So, I am not entirely sure whether it is build correctly.

I searched a bit more and found the libclang of Xcode (/Developer/usr/clang-ide/lib/libclang.dylib).

With that lib it crashes the VM on a callout to parse the header file (clang_createTranslationUnitFromSourceFile).
The MacPorts version already stopped way earlier when trying to use clang_createIndex.

So, still not a lot of luck.

I am on a OSX 10.6 with the latest NBCog, downloaded today (http://pharo.gforge.inria.fr/ci/vm/nbcog/mac/NBCog-mac-latest.zip)

Best regards
Stefan

--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Mariano Martinez Peck


On Wed, Jan 23, 2013 at 11:51 AM, Stefan Marr <[hidden email]> wrote:
Hi:

On 23 Jan 2013, at 15:28, Stefan Marr wrote:

> On 06 Jan 2013, at 17:22, Ciprian Teodorov wrote:
>> The project is released under MIT license, and you can find it on the smalltalkhub site.
>> http://smalltalkhub.com/#!/~CipT/TalkFFI
>
> I was trying to play with TalkFFI, but it looks like libclang3.1 is not compiled correctly or something.
>
> How do you build it? In your code I see you are also targeting OSX, so that doesn't seem to be the problem.
>
> I was trying to use the MacPorts version of libclang3.1 without having set any special compiler flags.
> So, I am not entirely sure whether it is build correctly.

I searched a bit more and found the libclang of Xcode (/Developer/usr/clang-ide/lib/libclang.dylib).

With that lib it crashes the VM on a callout to parse the header file (clang_createTranslationUnitFromSourceFile).
The MacPorts version already stopped way earlier when trying to use clang_createIndex.

So, still not a lot of luck.

Maybe the lib needs to be 32 bits? can you check if the lib you are trying is compiled for 32 or 64?


 

I am on a OSX 10.6 with the latest NBCog, downloaded today (http://pharo.gforge.inria.fr/ci/vm/nbcog/mac/NBCog-mac-latest.zip)

Best regards
Stefan

--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: <a href="tel:%2B32%202%20629%202974" value="+3226292974">+32 2 629 2974
Fax:   <a href="tel:%2B32%202%20629%203525" value="+3226293525">+32 2 629 3525





--
Mariano
http://marianopeck.wordpress.com
Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Stefan Marr-3
Hi Mariano:

On 23 Jan 2013, at 16:59, Mariano Martinez Peck wrote:

> Maybe the lib needs to be 32 bits? can you check if the lib you are trying is compiled for 32 or 64?

Yes, it needs to be 32bit, but that's not the problem:

smarr@minerva ~/tmp/libgit/libgit2$ file /Developer/usr/clang-ide/lib/libclang.dylib
/Developer/usr/clang-ide/lib/libclang.dylib: Mach-O universal binary with 2 architectures
/Developer/usr/clang-ide/lib/libclang.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/Developer/usr/clang-ide/lib/libclang.dylib (for architecture i386): Mach-O dynamically linked shared library i386

smarr@minerva ~/tmp/libgit/libgit2$ file /opt/local/libexec/llvm-3.1/lib/libclang.dylib
/opt/local/libexec/llvm-3.1/lib/libclang.dylib: Mach-O universal binary with 2 architectures
/opt/local/libexec/llvm-3.1/lib/libclang.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/opt/local/libexec/llvm-3.1/lib/libclang.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

Both version I have are universal binaries.

Best regards
Stefan


--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


Reply | Threaded
Open this post in threaded view
|

Re: TalkFFI: automatic FFI generation for Pharo

Ciprian Teodorov-3
The libs should be 32 bits... but it seems it is not this the issue...
I have compiled clang+llvm from sources using the source distribution at: http://www.llvm.org/releases/

then I have built the whole llvm distribution (using the getting started guide):
../src/configure --prefix=<path-to-install-dir> --enable-optimized --enable-jit --target=i686-apple-darwin10

There is also a Getting started guide at: http://llvm.org/releases/3.1/docs/GettingStarted.html

As soon as I get some time I'll try to use osx/macport distribs maybe I can figure out what is the problem...
If you guys have any ideas on how to easily distribute an image+vm+libclang i'm very interested.

For now I'm thinking of doing something like CMakeVMMaker script, but I don't like that the that package seems tigtly couple with VMMaker...

Cheers,
ciprian

On Wed, Jan 23, 2013 at 5:08 PM, Stefan Marr <[hidden email]> wrote:
Hi Mariano:

On 23 Jan 2013, at 16:59, Mariano Martinez Peck wrote:

> Maybe the lib needs to be 32 bits? can you check if the lib you are trying is compiled for 32 or 64?

Yes, it needs to be 32bit, but that's not the problem:

smarr@minerva ~/tmp/libgit/libgit2$ file /Developer/usr/clang-ide/lib/libclang.dylib
/Developer/usr/clang-ide/lib/libclang.dylib: Mach-O universal binary with 2 architectures
/Developer/usr/clang-ide/lib/libclang.dylib (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
/Developer/usr/clang-ide/lib/libclang.dylib (for architecture i386):    Mach-O dynamically linked shared library i386

smarr@minerva ~/tmp/libgit/libgit2$ file /opt/local/libexec/llvm-3.1/lib/libclang.dylib
/opt/local/libexec/llvm-3.1/lib/libclang.dylib: Mach-O universal binary with 2 architectures
/opt/local/libexec/llvm-3.1/lib/libclang.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/opt/local/libexec/llvm-3.1/lib/libclang.dylib (for architecture x86_64):       Mach-O 64-bit dynamically linked shared library x86_64

Both version I have are universal binaries.

Best regards
Stefan


--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: <a href="tel:%2B32%202%20629%202974" value="+3226292974">+32 2 629 2974
Fax:   <a href="tel:%2B32%202%20629%203525" value="+3226293525">+32 2 629 3525





--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
12