Which arch-dependent binary is used?
-
I have a question about which binary is used from a fat binary in a
framework. For an app, of course the most appropriate binary available
is used. So a PPC machine will use the ppc binary, a 32-bit Intel
machine will use the i386 binary and a 64-bit Intel will use the
x86_64 binary, assuming the fat binary contains binaries for those
archs. But what happens when I build a framework as a fat binary for
those 3 binaries? Is the actual binary that's used determined by the
app loading the framework, or is it only determined by the machine?
To make it more explicit, assume the framework is build for ARCHS =
ppc i386 x86_64, while the app is build for ARCHS = ppc i386. What
will happen on a 64-bit Intel machine? For the app of course the i386
binary will be used. But which binary will be used for the framework,
is it the i386 or x86_64 binary?
Christiaan -
On 04.01.2009, at 23:10, Christiaan Hofman wrote:> To make it more explicit, assume the framework is build for ARCHS =
> ppc i386 x86_64, while the app is build for ARCHS = ppc i386. What
> will happen on a 64-bit Intel machine? For the app of course the
> i386 binary will be used. But which binary will be used for the
> framework, is it the i386 or x86_64 binary?
Code from the app has to call into the framework. You can't have
mixed architectures in the same memory space, so the only thing that
works is that the architecture matching the app's gets loaded from the
framework.
So, if the framework is built as x64, but the app isn't, this app
will never make use of that architecture.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de -
On Jan 4, 2009, at 7:11 PM, Uli Kusterer wrote:> On 04.01.2009, at 23:10, Christiaan Hofman wrote:
>> To make it more explicit, assume the framework is build for ARCHS =
>> ppc i386 x86_64, while the app is build for ARCHS = ppc i386. What
>> will happen on a 64-bit Intel machine? For the app of course the
>> i386 binary will be used. But which binary will be used for the
>> framework, is it the i386 or x86_64 binary?
>
>
> Code from the app has to call into the framework. You can't have
> mixed architectures in the same memory space, so the only thing that
> works is that the architecture matching the app's gets loaded from
> the framework.
>
> So, if the framework is built as x64, but the app isn't, this app
> will never make use of that architecture.
Also, the system loader checks the libraries & frameworks an app is
linked to when it's launching it. So, if the app includes x64, but a
framework it's linked to is i386-only, the app will run it as i386.
Obviously though, it can't do that for frameworks or bundles loaded at
run-time; in that case the loader will simply fail and report an error.
sherm-- -
That's not true. The kernel only looks at the executable itself when
picking which architecture to use. If the dynamic linker (dyld) can't
find a dependent library of the correct architecture, the program will
crash at that point with a message saying as much.
Shantonu
Sent from my MacBook
On Jan 4, 2009, at 9:50 PM, Sherm Pendley wrote:> On Jan 4, 2009, at 7:11 PM, Uli Kusterer wrote:
>
>> On 04.01.2009, at 23:10, Christiaan Hofman wrote:
>>> To make it more explicit, assume the framework is build for ARCHS
>>> = ppc i386 x86_64, while the app is build for ARCHS = ppc i386.
>>> What will happen on a 64-bit Intel machine? For the app of course
>>> the i386 binary will be used. But which binary will be used for
>>> the framework, is it the i386 or x86_64 binary?
>>
>>
>> Code from the app has to call into the framework. You can't have
>> mixed architectures in the same memory space, so the only thing
>> that works is that the architecture matching the app's gets loaded
>> from the framework.
>>
>> So, if the framework is built as x64, but the app isn't, this app
>> will never make use of that architecture.
>
> Also, the system loader checks the libraries & frameworks an app is
> linked to when it's launching it. So, if the app includes x64, but a
> framework it's linked to is i386-only, the app will run it as i386.
> Obviously though, it can't do that for frameworks or bundles loaded
> at run-time; in that case the loader will simply fail and report an
> error.
>
> sherm--
>
> _______________________________________________
> MacOSX-dev mailing list
> <MacOSX-dev...>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev -
Thanks all for your answers.
But Shantonu, just to be sure, are you saying Sherm Pendley's remark
is not true, or Uli Kusterer's? In other words, when you say "the
executable itself" do you mean the app's executable (AOT the
framework's)? And do you mean by "the correct architecture" the same
architecture as was chosen for the app's executable?
Christiaan
On 5 Jan 2009, at 12:58 PM, Shantonu Sen wrote:> That's not true. The kernel only looks at the executable itself when
> picking which architecture to use. If the dynamic linker (dyld)
> can't find a dependent library of the correct architecture, the
> program will crash at that point with a message saying as much.
>
> Shantonu
>
> Sent from my MacBook
>
> On Jan 4, 2009, at 9:50 PM, Sherm Pendley wrote:
>
>> On Jan 4, 2009, at 7:11 PM, Uli Kusterer wrote:
>>
>>> On 04.01.2009, at 23:10, Christiaan Hofman wrote:
>>>> To make it more explicit, assume the framework is build for ARCHS
>>>> = ppc i386 x86_64, while the app is build for ARCHS = ppc i386.
>>>> What will happen on a 64-bit Intel machine? For the app of course
>>>> the i386 binary will be used. But which binary will be used for
>>>> the framework, is it the i386 or x86_64 binary?
>>>
>>>
>>> Code from the app has to call into the framework. You can't have
>>> mixed architectures in the same memory space, so the only thing
>>> that works is that the architecture matching the app's gets loaded
>>> from the framework.
>>>
>>> So, if the framework is built as x64, but the app isn't, this app
>>> will never make use of that architecture.
>>
>> Also, the system loader checks the libraries & frameworks an app is
>> linked to when it's launching it. So, if the app includes x64, but
>> a framework it's linked to is i386-only, the app will run it as
>> i386. Obviously though, it can't do that for frameworks or bundles
>> loaded at run-time; in that case the loader will simply fail and
>> report an error.
>>
>> sherm--
>>
>> _______________________________________________
>> MacOSX-dev mailing list
>> <MacOSX-dev...>
>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
> _______________________________________________
> MacOSX-dev mailing list
> <MacOSX-dev...>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev


