Has anyone gotten FFI working on squeak on a Mac lately?

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

Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.

I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.

So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.

Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.


L

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Eliot Miranda-2
Hi Lawson,

> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>
> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>
> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>
> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>
> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.

The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.

>
>
> L
>

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
I’m not saying it isn’t stable.

However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.

I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.

SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?

I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.

WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.

WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?

I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.


L

> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>
> Hi Lawson,
>
>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>
>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>
>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>
>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>
>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>
> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>
>>
>>
>> L
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Eliot Miranda-2
Hi Lawson,

> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>
> I’m not saying it isn’t stable.

I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.

> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.

There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.

> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>
> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?

Yes.

> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>
> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>
> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?

Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.

>
> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.

Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.

So first question, what’s the output of
     otool -L mylib

(You can omit all the /System/Library ones)

> L
>
>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>
>> Hi Lawson,
>>
>>>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>>
>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>
>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>
>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>
>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>
>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>
>>>
>>>
>>> L
>>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

timrowledge


> On 2020-08-14, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>
> change the hard-coded paths of any other non-system Dublin’s a Bykov depends on

The what who?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Computers are useless.  They can only give you answers.



Reply | Threaded
Open this post in threaded view
|

Fwd: Has anyone gotten FFI working on squeak on a Mac lately?

Eliot Miranda-2
In reply to this post by Eliot Miranda-2
Edited for clarity

From: Eliot Miranda <[hidden email]>
Date: August 14, 2020 at 9:19:40 PM PDT
To: The general-purpose Squeak developers list <[hidden email]>
Subject: Re:  [squeak-dev] Has anyone gotten FFI working on squeak on a Mac lately?

Hi Lawson,

On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:

I’m not saying it isn’t stable.

I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.

However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.

There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.

I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.

SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?

Yes.

I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.

WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.

WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?

Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system dylibs a dylib depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.

I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.

Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.

So first question, what’s the output of
    otool -L mylib

(You can omit all the /System/Library ones)

L

On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:

Hi Lawson,

On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:

I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.

I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.

So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.

Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.

The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.



L


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
In reply to this post by Eliot Miranda-2
Thanks.I checked, and inded my dylib was pointing back to the directory it was created in. I’ll look at how the bundled libraries’ paths are set up and try to recreate that.

Should I get it working, I foresee  several new “From the very start” videos in the works, but I think I’ll need a new title for the series at this level.

L

> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>
> Hi Lawson,
>
>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>
>> I’m not saying it isn’t stable.
>
> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>
>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>
> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>
>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>
>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>
> Yes.
>
>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>
>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>
>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>
> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>
>>
>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>
> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>
> So first question, what’s the output of
>     otool -L mylib
>
> (You can omit all the /System/Library ones)
>
>> L
>>
>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>
>>> Hi Lawson,
>>>
>>>>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>>>
>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>
>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>
>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>
>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>
>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>
>>>>
>>>>
>>>> L
>>>>
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
In reply to this post by Eliot Miranda-2
A followup issue is that simply getting the “External module not found” error the way I do eventually caues either a freeze, or a crash on startup.

That’s happened with 3 different all-in-one Squeak 5.3’s.

The debug VM also eventually freezes it seems, when I left it unattended overnight after trying to run that FFI call and getting that error. So far we haven’t figured out where to put a break in the C code to halt  just before that error emerges, but just getting that error enough times seems to have its own bad effects on squeak, even if it takes a while to show up.

L




> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>
> Hi Lawson,
>
>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>
>> I’m not saying it isn’t stable.
>
> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>
>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>
> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>
>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>
>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>
> Yes.
>
>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>
>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>
>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>
> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>
>>
>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>
> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>
> So first question, what’s the output of
>     otool -L mylib
>
> (You can omit all the /System/Library ones)
>
>> L
>>
>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>
>>> Hi Lawson,
>>>
>>>>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>>>
>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>
>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>
>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>
>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>
>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>
>>>>
>>>>
>>>> L
>>>>
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Eliot Miranda-2
Hi Lawson,

> On Aug 15, 2020, at 1:54 PM, LawsonEnglish <[hidden email]> wrote:
>
> A followup issue is that simply getting the “External module not found” error the way I do eventually caues either a freeze, or a crash on startup.
>
> That’s happened with 3 different all-in-one Squeak 5.3’s.
>
> The debug VM also eventually freezes it seems, when I left it unattended overnight after trying to run that FFI call and getting that error. So far we haven’t figured out where to put a break in the C code to halt  just before that error emerges, but just getting that error enough times seems to have its own bad effects on squeak, even if it takes a while to show up.

Remember that if you run the vm from a terminal window then when it freezes up you can open another terminal and attach to the process using lldb abd then start exploring, eg using call printAllStacks() and call dumpPrimTraceLog() to find out what state it is in and what was the last external primitive it executed before locking up.

You can also simply open a terminal and use pushOutputFile to send output to the new terminal, but that’s a bit involved.

> L
>
>> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>>
>> Hi Lawson,
>>
>>>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>>
>>> I’m not saying it isn’t stable.
>>
>> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>>
>>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>>
>> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>>
>>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>>
>>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>>
>> Yes.
>>
>>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>>
>>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>>
>>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>>
>> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>>
>>>
>>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>>
>> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>>
>> So first question, what’s the output of
>>    otool -L mylib
>>
>> (You can omit all the /System/Library ones)
>>
>>> L
>>>
>>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>>
>>>> Hi Lawson,
>>>>
>>>>>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>>>>
>>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>>
>>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>>
>>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>>
>>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>>
>>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>>
>>>>>
>>>>>
>>>>> L
>>>>>
>>>>
>>>
>>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
In reply to this post by Eliot Miranda-2
Running otool -L on my dylib:

otool -L otool -L libFFITest.dylib
libFFITest.dylib:
        /libFFITest.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

however, running it on the executable int eh SqueakFFIPrims.bundle:

otool -L SqueakFFIPrims
SqueakFFIPrims:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)


I’m not sure what the difference means. I can sorta remove /libFFITest.dylib  but the "(compatibility version 1.0.0, current version 1.0.0)” remains, and I still get the same error whether or not /libFFITest.dylib is present.




Can you give me a hint as to what the output from otool -L should look like for a dylib that is useable from within  /Resources?

L


> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>
> Hi Lawson,
>
>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>
>> I’m not saying it isn’t stable.
>
> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>
>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>
> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>
>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>
>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>
> Yes.
>
>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>
>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>
>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>
> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>
>>
>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>
> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>
> So first question, what’s the output of
>     otool -L mylib
>
> (You can omit all the /System/Library ones)
>
>> L
>>
>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>
>>> Hi Lawson,
>>>
>>>>> On Aug 14, 2020, at 6:04 PM, LawsonEnglish <[hidden email]> wrote:
>>>>
>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>
>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>
>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>
>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>
>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>
>>>>
>>>>
>>>> L
>>>>
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Craig Latta
In reply to this post by LawsonEnglish

Hi Lawson--

> I let Craig Latta watch me, via screen sharing on skype, set up the
> whole thing from scratch, and his response was to start to coach me in
> how to create and use the VM with a c-debugger.

     No, catching your error with the C debugger was my first suggestion
after hearing FFI wasn't working for you, before I saw anything. Helping
you set up the VM build and debugging environment was the reason for the
screen-sharing session.

> So I don’t think I’m doing anything obviously wrong or at least Craig
> didn’t catch it while he watched.

     I wasn't trying to catch anything. I was helping you set up the
tools for finding the wrong thing yourself.


-C

--
Craig Latta
Black Page Digital
Berkeley, California
blackpagedigital.com



Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Tobias Pape
In reply to this post by LawsonEnglish
Hi

> On 16.08.2020, at 09:36, LawsonEnglish <[hidden email]> wrote:
>
> Running otool -L on my dylib:
>
> otool -L otool -L libFFITest.dylib
> libFFITest.dylib:
> /libFFITest.dylib (compatibility version 1.0.0, current version 1.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
>
> however, running it on the executable int eh SqueakFFIPrims.bundle:
>
> otool -L SqueakFFIPrims
> SqueakFFIPrims:
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
>
>
> I’m not sure what the difference means. I can sorta remove /libFFITest.dylib  but the "(compatibility version 1.0.0, current version 1.0.0)” remains, and I still get the same error whether or not /libFFITest.dylib is present.
>
>

there's a stark difference, sadly.
The Plugins, which are bundles on macOS, are _not_ simply dynamic libs:


[Squeak.app/Contents/Resources]$ otool -L CameraPlugin.bundle/Contents/MacOS/CameraPlugin
CameraPlugin.bundle/Contents/MacOS/CameraPlugin:
        /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1450.15.0)
        /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1129.5.0)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1450.15.0)
        /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

[Squeak.app/Contents/Resources]$ file CameraPlugin.bundle/Contents/MacOS/CameraPlugin
CameraPlugin.bundle/Contents/MacOS/CameraPlugin: Mach-O 64-bit bundle x86_64

Dynamic libs look differently:

[~]$ otool -L /usr/lib/libbz2.dylib
/usr/lib/libbz2.dylib:
        /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)

[~]$  file /usr/lib/libbz2.dylib
/usr/lib/libbz2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386]
/usr/lib/libbz2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libbz2.dylib (for architecture i386): Mach-O dynamically linked shared library i386

=-=-=

I would suggest you first try to call a known function in a  known library. For example:

const char* BZ2_bzlibVersion(void); from libbzip2.


=-=-=

Other than that, I can't help without some artifact to look at, sorry :/

Best regards
        -Tobias



>
> Can you give me a hint as to what the output from otool -L should look like for a dylib that is useable from within  /Resources?
>
> L
>
>
>> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>>
>> Hi Lawson,
>>
>>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>>
>>> I’m not saying it isn’t stable.
>>
>> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>>
>>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>>
>> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>>
>>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>>
>>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>>
>> Yes.
>>
>>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>>
>>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>>
>>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>>
>> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>>
>>>
>>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>>
>> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>>
>> So first question, what’s the output of
>>    otool -L mylib
>>
>> (You can omit all the /System/Library ones)
>>
>>> L
>>>
>>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>>
>>>> Hi Lawson,
>>>>
>>>>>
>>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>>
>>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>>
>>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>>
>>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>>
>>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>>
>>>>>
>>>>>
>>>>> L
>>>>>
>>>>
>>>
>>>
>>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
If you look at the FFIPrim bundle, it looks different.

I still can’t get anything to work except those bundles that are included with the all-in-one.


L

This is with Cataina.

L

> On Aug 19, 2020, at 12:31 AM, Tobias Pape <[hidden email]> wrote:
>
> Hi
>
>> On 16.08.2020, at 09:36, LawsonEnglish <[hidden email]> wrote:
>>
>> Running otool -L on my dylib:
>>
>> otool -L otool -L libFFITest.dylib
>> libFFITest.dylib:
>> /libFFITest.dylib (compatibility version 1.0.0, current version 1.0.0)
>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
>>
>> however, running it on the executable int eh SqueakFFIPrims.bundle:
>>
>> otool -L SqueakFFIPrims
>> SqueakFFIPrims:
>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
>>
>>
>> I’m not sure what the difference means. I can sorta remove /libFFITest.dylib  but the "(compatibility version 1.0.0, current version 1.0.0)” remains, and I still get the same error whether or not /libFFITest.dylib is present.
>>
>>
>
> there's a stark difference, sadly.
> The Plugins, which are bundles on macOS, are _not_ simply dynamic libs:
>
>
> [Squeak.app/Contents/Resources]$ otool -L CameraPlugin.bundle/Contents/MacOS/CameraPlugin
> CameraPlugin.bundle/Contents/MacOS/CameraPlugin:
> /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1450.15.0)
> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1129.5.0)
> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1450.15.0)
> /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
> /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
>
> [Squeak.app/Contents/Resources]$ file CameraPlugin.bundle/Contents/MacOS/CameraPlugin
> CameraPlugin.bundle/Contents/MacOS/CameraPlugin: Mach-O 64-bit bundle x86_64
>
> Dynamic libs look differently:
>
> [~]$ otool -L /usr/lib/libbz2.dylib
> /usr/lib/libbz2.dylib:
> /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
>
> [~]$  file /usr/lib/libbz2.dylib
> /usr/lib/libbz2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386]
> /usr/lib/libbz2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
> /usr/lib/libbz2.dylib (for architecture i386): Mach-O dynamically linked shared library i386
>
> =-=-=
>
> I would suggest you first try to call a known function in a  known library. For example:
>
> const char* BZ2_bzlibVersion(void); from libbzip2.
>
>
> =-=-=
>
> Other than that, I can't help without some artifact to look at, sorry :/
>
> Best regards
> -Tobias
>
>
>
>>
>> Can you give me a hint as to what the output from otool -L should look like for a dylib that is useable from within  /Resources?
>>
>> L
>>
>>
>>> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>>>
>>> Hi Lawson,
>>>
>>>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>>>
>>>> I’m not saying it isn’t stable.
>>>
>>> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>>>
>>>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>>>
>>> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>>>
>>>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>>>
>>>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>>>
>>> Yes.
>>>
>>>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>>>
>>>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>>>
>>>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>>>
>>> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>>>
>>>>
>>>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>>>
>>> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>>>
>>> So first question, what’s the output of
>>>   otool -L mylib
>>>
>>> (You can omit all the /System/Library ones)
>>>
>>>> L
>>>>
>>>>> On Aug 14, 2020, at 6:14 PM, Eliot Miranda <[hidden email]> wrote:
>>>>>
>>>>> Hi Lawson,
>>>>>
>>>>>>
>>>>>> I realize that the test library works, but I can’t use ANY kind of library user specified/user made library for FFI with Squeak on Catalina OR Mojave, and I can’t tell what I am doing wrong.
>>>>>>
>>>>>> I let Craig Latta watch me, via screen sharing on skype, set up the whole thing from scratch, and his response was to start to coach me in how to create and use the VM with a c-debugger.
>>>>>>
>>>>>> So I don’t think I’m doing anything obviously wrong or at least Craig didn’t catch it while he watched.
>>>>>>
>>>>>> Still don’t have the VM working, so I thought I ask if anyone has actually done it lately? The FFIPrim libray is in a .bundle, which may or may not be signficiant to this issue.
>>>>>
>>>>> The FFI tests work out if the biz for me on MacOS 64-bit. The test functions are included in the FFI plugin.  I haven’t tried x86/32-bit in a while but I’d be surprised if this was broken.  The code is stable.
>>>>>
>>>>>>
>>>>>>
>>>>>> L
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

Tobias Pape

> On 20.08.2020, at 09:19, LawsonEnglish <[hidden email]> wrote:
>
> If you look at the FFIPrim bundle, it looks different.
>
> I still can’t get anything to work except those bundles that are included with the all-in-one.
>
>
> L
>
> This is with Cataina.
>
> L

Can you share the source of your test library?

best regards
        -tobias

>
>> On Aug 19, 2020, at 12:31 AM, Tobias Pape <[hidden email]> wrote:
>>
>> Hi
>>
>>> On 16.08.2020, at 09:36, LawsonEnglish <[hidden email]> wrote:
>>>
>>> Running otool -L on my dylib:
>>>
>>> otool -L otool -L libFFITest.dylib
>>> libFFITest.dylib:
>>> /libFFITest.dylib (compatibility version 1.0.0, current version 1.0.0)
>>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
>>>
>>> however, running it on the executable int eh SqueakFFIPrims.bundle:
>>>
>>> otool -L SqueakFFIPrims
>>> SqueakFFIPrims:
>>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
>>>
>>>
>>> I’m not sure what the difference means. I can sorta remove /libFFITest.dylib  but the "(compatibility version 1.0.0, current version 1.0.0)” remains, and I still get the same error whether or not /libFFITest.dylib is present.
>>>
>>>
>>
>> there's a stark difference, sadly.
>> The Plugins, which are bundles on macOS, are _not_ simply dynamic libs:
>>
>>
>> [Squeak.app/Contents/Resources]$ otool -L CameraPlugin.bundle/Contents/MacOS/CameraPlugin
>> CameraPlugin.bundle/Contents/MacOS/CameraPlugin:
>> /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
>> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1450.15.0)
>> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1129.5.0)
>> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1450.15.0)
>> /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
>> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
>> /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
>>
>> [Squeak.app/Contents/Resources]$ file CameraPlugin.bundle/Contents/MacOS/CameraPlugin
>> CameraPlugin.bundle/Contents/MacOS/CameraPlugin: Mach-O 64-bit bundle x86_64
>>
>> Dynamic libs look differently:
>>
>> [~]$ otool -L /usr/lib/libbz2.dylib
>> /usr/lib/libbz2.dylib:
>> /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
>> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
>>
>> [~]$  file /usr/lib/libbz2.dylib
>> /usr/lib/libbz2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386]
>> /usr/lib/libbz2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
>> /usr/lib/libbz2.dylib (for architecture i386): Mach-O dynamically linked shared library i386
>>
>> =-=-=
>>
>> I would suggest you first try to call a known function in a  known library. For example:
>>
>> const char* BZ2_bzlibVersion(void); from libbzip2.
>>
>>
>> =-=-=
>>
>> Other than that, I can't help without some artifact to look at, sorry :/
>>
>> Best regards
>> -Tobias
>>
>>
>>
>>>
>>> Can you give me a hint as to what the output from otool -L should look like for a dylib that is useable from within  /Resources?
>>>
>>> L
>>>
>>>
>>>> On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:
>>>>
>>>> Hi Lawson,
>>>>
>>>>> On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:
>>>>>
>>>>> I’m not saying it isn’t stable.
>>>>
>>>> I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.
>>>>
>>>>> However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.
>>>>
>>>> There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.
>>>>
>>>>> I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.
>>>>>
>>>>> SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?
>>>>
>>>> Yes.
>>>>
>>>>> I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.
>>>>>
>>>>> WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.
>>>>>
>>>>> WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?
>>>>
>>>> Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.
>>>>
>>>>>
>>>>> I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.
>>>>
>>>> Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.
>>>>
>>>> So first question, what’s the output of
>>>>  otool -L mylib
>>>>
>>>> (You can omit all the /System/Library ones)
>>>>
>>>>> L
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Has anyone gotten FFI working on squeak on a Mac lately?

LawsonEnglish
It’s the simplest library I could think of:

.h file:
#ifndef FFITest_h
#define FFITest_h


#define PI 3.14159
double GetPi(void);
#endif /* FFITest_h */


.c file:
#include "FFITest.h"
double GetPi(void){return PI;};


.

By the way, I managed to get things working just fine in my own build of the Mac 64-bit vm, but some new odd behavior as shown up.

Ill explain in a yet another thread.

L

On Aug 20, 2020, at 12:31 AM, Tobias Pape <[hidden email]> wrote:


On 20.08.2020, at 09:19, LawsonEnglish <[hidden email]> wrote:

If you look at the FFIPrim bundle, it looks different.

I still can’t get anything to work except those bundles that are included with the all-in-one.


L

This is with Cataina.

L

Can you share the source of your test library?

best regards
-tobias


On Aug 19, 2020, at 12:31 AM, Tobias Pape <[hidden email]> wrote:

Hi

On 16.08.2020, at 09:36, LawsonEnglish <[hidden email]> wrote:

Running otool -L on my dylib:

otool -L otool -L libFFITest.dylib
libFFITest.dylib:
/libFFITest.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

however, running it on the executable int eh SqueakFFIPrims.bundle:

otool -L SqueakFFIPrims
SqueakFFIPrims:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)


I’m not sure what the difference means. I can sorta remove /libFFITest.dylib  but the "(compatibility version 1.0.0, current version 1.0.0)” remains, and I still get the same error whether or not /libFFITest.dylib is present.



there's a stark difference, sadly.
The Plugins, which are bundles on macOS, are _not_ simply dynamic libs:


[Squeak.app/Contents/Resources]$ otool -L CameraPlugin.bundle/Contents/MacOS/CameraPlugin
CameraPlugin.bundle/Contents/MacOS/CameraPlugin:
/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1450.15.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1129.5.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1450.15.0)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

[Squeak.app/Contents/Resources]$ file CameraPlugin.bundle/Contents/MacOS/CameraPlugin
CameraPlugin.bundle/Contents/MacOS/CameraPlugin: Mach-O 64-bit bundle x86_64

Dynamic libs look differently:

[~]$ otool -L /usr/lib/libbz2.dylib
/usr/lib/libbz2.dylib:
/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)

[~]$  file /usr/lib/libbz2.dylib
/usr/lib/libbz2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386]
/usr/lib/libbz2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libbz2.dylib (for architecture i386): Mach-O dynamically linked shared library i386

=-=-=

I would suggest you first try to call a known function in a  known library. For example:

const char* BZ2_bzlibVersion(void); from libbzip2.


=-=-=

Other than that, I can't help without some artifact to look at, sorry :/

Best regards
-Tobias




Can you give me a hint as to what the output from otool -L should look like for a dylib that is useable from within  /Resources?

L


On Aug 14, 2020, at 9:19 PM, Eliot Miranda <[hidden email]> wrote:

Hi Lawson,

On Aug 14, 2020, at 6:21 PM, LawsonEnglish <[hidden email]> wrote:

I’m not saying it isn’t stable.

I know.  I was just saying I don’t think anything has been broken recently, so the issue is not in the FFI per se.

However, the test functions are in the FFI plugin, which is a .bundle. I’ve been trying to use a .dylib.

There’s a SqueakFFIPlugin dylib (a dylib in all but name) in SqueakFFIPlugin.bundle/Contents/MacOS/SqueakFFIPlugin.  That’s what the FFI actually loads.

I realize that this should. make no difference, and yet, as I said, Craig Latta watched me do the whole thing from scratch via skype screensharing and he didn’t see an error.

SO again: has anyone used a non-Squeak distribution/non-bundle with FFI lately?

Yes.

I tested it on both Catlaina and Mojave and I get teh External module not found error, even with my own .dylib that isn’t hardcoded to sit in a specific directory.

WHich leads to a suggestion: if it really is a Mac OS x issue, rather than my own stupidity, it may be necessary to start testing against a library that is merely sitting in the Resource directory, rather than inside a .bundle.

WHich is why I’m still asking: has anyone used their own library (outside a .bundle) with FFI lately on Mac OS X, Catalina OR Mojave?

Yes, and it is extremely tricky.  I’ve been using libav and libffmpeg and others.  I’ve found one has to examine carefully the output of otool -L and use install_name_tool to change the hard-coded paths of any other non-system Dublin’s a Bykov depends on and make sure one understands and uses @rpath.  If your dylib uses any other dylib you’re going to have to do the same exploration.


I’m still trying to figure out how to PUT a library into a .bundle, or I’d test my theory.

Look at the vm build makefiles for macos; they do this and they can be configured to generate dylibs in a directory, etc.

So first question, what’s the output of
otool -L mylib

(You can omit all the /System/Library ones)

L