Thread overview
[phobos] 64 & 32 bit libraries for OSX
Nov 09, 2011
Walter Bright
Nov 09, 2011
Michel Fortin
Nov 09, 2011
Michel Fortin
Nov 10, 2011
Walter Bright
Nov 10, 2011
Michel Fortin
Nov 13, 2011
Walter Bright
Nov 10, 2011
Walter Bright
Nov 09, 2011
Martin Nowak
November 08, 2011
On Linux, the 64 bit and 32 bit libraries exist along separate paths, and we put both paths on the command to the linker:

DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic

However, attempting to do this on OSX fails (using -L-no_arch_warnings instead of -L--no-warn-search-mismatch). It apparently always tries to link in the first library found, not the first one with matching architecture.

What is the right way on OSX to do a dual-architecture library?
November 08, 2011
Le 2011-11-08 ? 20:45, Walter Bright a ?crit :

> On Linux, the 64 bit and 32 bit libraries exist along separate paths, and we put both paths on the command to the linker:
> 
> DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic
> 
> However, attempting to do this on OSX fails (using -L-no_arch_warnings instead of -L--no-warn-search-mismatch). It apparently always tries to link in the first library found, not the first one with matching architecture.
> 
> What is the right way on OSX to do a dual-architecture library?

Fuse both architectures into one "fat" file using lipo:

	lipo lib32/libphobos.a lib64/libphobos.a -create -output lib/libphobos.a


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



November 09, 2011
On Wed, 09 Nov 2011 02:45:08 +0100, Walter Bright <walter at digitalmars.com> wrote:

> On Linux, the 64 bit and 32 bit libraries exist along separate paths, and we put both paths on the command to the linker:
>
> DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic
>
> However, attempting to do this on OSX fails (using -L-no_arch_warnings instead of -L--no-warn-search-mismatch). It apparently always tries to link in the first library found, not the first one with matching architecture.
>
> What is the right way on OSX to do a dual-architecture library?
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

Building two static libraries and merging them with lipo(1) should do the trick.
November 08, 2011
Le 2011-11-08 ? 22:19, Michel Fortin a ?crit :

> Le 2011-11-08 ? 20:45, Walter Bright a ?crit :
> 
>> On Linux, the 64 bit and 32 bit libraries exist along separate paths, and we put both paths on the command to the linker:
>> 
>> DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic
>> 
>> However, attempting to do this on OSX fails (using -L-no_arch_warnings instead of -L--no-warn-search-mismatch). It apparently always tries to link in the first library found, not the first one with matching architecture.
>> 
>> What is the right way on OSX to do a dual-architecture library?
> 
> Fuse both architectures into one "fat" file using lipo:
> 
> 	lipo lib32/libphobos.a lib64/libphobos.a -create -output lib/libphobos.a


Also, you should do the same for the compiler binary file, assuming you release a 64-bit version of the compiler too. Instead of having separate 32 and 64 bit executables in separate folders, merge them into one using lipo.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



November 10, 2011

On 11/8/2011 7:19 PM, Michel Fortin wrote:
> Le 2011-11-08 ? 20:45, Walter Bright a ?crit :
>
>> On Linux, the 64 bit and 32 bit libraries exist along separate paths, and we put both paths on the command to the linker:
>>
>> DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic
>>
>> However, attempting to do this on OSX fails (using -L-no_arch_warnings instead of -L--no-warn-search-mismatch). It apparently always tries to link in the first library found, not the first one with matching architecture.
>>
>> What is the right way on OSX to do a dual-architecture library?
> Fuse both architectures into one "fat" file using lipo:
>
> 	lipo lib32/libphobos.a lib64/libphobos.a -create -output lib/libphobos.a

Thanks. I'll give it a whirl. That's just what I was looking for.

November 10, 2011

On 11/8/2011 8:31 PM, Michel Fortin wrote:
>
> Also, you should do the same for the compiler binary file, assuming you release a 64-bit version of the compiler too. Instead of having separate 32 and 64 bit executables in separate folders, merge them into one using lipo.
>

Is there any purpose to shipping 32 bit executables for dmd for the Mac any more?
November 10, 2011
Le 2011-11-10 ? 15:18, Walter Bright a ?crit :

> On 11/8/2011 8:31 PM, Michel Fortin wrote:
>> 
>> Also, you should do the same for the compiler binary file, assuming you release a 64-bit version of the compiler too. Instead of having separate 32 and 64 bit executables in separate folders, merge them into one using lipo.
> 
> Is there any purpose to shipping 32 bit executables for dmd for the Mac any more?


Apple shipped 32-bit Macs until 2006. While it's true that most Intel Macs can run 64-bit programs, some may not be able to run dmd if you remove the 32-bit version.

Perhaps the best way to know if you should maintain a 32-bit version is to release a 64-bit-only version and see if you get complains. :-) Then re-release it as a dual-architecture binary if some people wants it.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



November 12, 2011

On 11/10/2011 1:04 PM, Michel Fortin wrote:
>
> Apple shipped 32-bit Macs until 2006. While it's true that most Intel Macs can run 64-bit programs, some may not be able to run dmd if you remove the 32-bit version.
>
> Perhaps the best way to know if you should maintain a 32-bit version is to release a 64-bit-only version and see if you get complains. :-) Then re-release it as a dual-architecture binary if some people wants it.
>

Sounds like a plan. Even my ancient Mac mini turned out to run 64 bit code jes' fine. I'm not sure when I bought it.

I will continue to build and test the 32 bit dmd to make sure it keeps working, but won't include it in the regular distribution.