Thanks all,

In order to build a ppc gfortran app, I need the Xcode 3 PPC compiler (I think 
that's what a lot of these comments have been about). There is a SO thread 
about how to do this:

  http://stackoverflow.com/questions/5333490

But once I have my universal gcc48 (not apple-gcc*), it would appear that the 
-arch flags must be passed one at a time. BTW, it seems the default gcc48 can 
build 32 bit fortran apps (even though it's a x86_64 build) but can't link them 
(hence the need for "gcc48 +universal").

Before I embark on the insane mission of obtaining xcode3 ppc compilers, can 
somebody confirm for me if the "gcc48 +universal" (with universal including 
ppc) will be able to compile ppc binaries using "-arch ppc"?


* one could edit 
https://trac.macports.org/browser/trunk/dports/lang/apple-gcc42/Portfile to 
include the fortran language, but I'd rather not get into customising 
portfiles. Besides, I thought apple used LLVM nowadays.

-- 
Sam

On 25 Aug 2013, at 03:17, Jeremy Huddleston Sequoia <jerem...@macports.org> 
wrote:

> 
> On Aug 24, 2013, at 8:00, Ryan Schmidt <ryandes...@macports.org> wrote:
> 
>> 
>> On Aug 24, 2013, at 07:29, Samuel Halliday wrote:
>> 
>>> I'm using the macports distro of gcc in order to get fortran support.
>>> 
>>> Could somebody please show me how to build universal binaries that work on 
>>> the four targets: PPC/Intel 32/64?
>>> 
>>> I presume I'll need to get this fixed:
>>> 
>>> $ file /opt/local/lib/libgcc/libgfortran.3.dylib 
>>> /opt/local/lib/libgcc/libgfortran.3.dylib: Mach-O 64-bit x86_64 dynamically 
>>> linked shared library
>> 
>> Edit /opt/local/etc/macports/macports.conf and set universal_archs to x86_64 
>> i386 ppc64 ppc. Then reinstall libgcc with the universal variant. And maybe 
>> the gcc port you're using too. If you already had any ports installed using 
>> the universal variant they'll have to be rebuilt using the new set of 
>> architectures. Not sure if MacPorts will do that for you automatically or 
>> not.
>> 
>> I would expect that modern versions of OS X cannot build for PowerPC 
>> anymore, so you'll need to be running as sufficiently old version of OS X. 
>> Lion and later are too new. Snow Leopard is probably old enough. Leopard is 
>> definitely old enough. Tiger is too old to build 64-bit in some cases.
> 
> If you're on SL, you'll need to use the 10.5 SDK if you actually want ppc64 
> support.  You probably don't want or need ppc64 support (and ppc64 is likely 
> horrifically broken in MacPorts), so I suggest using Snow Leopard with 
> universal_archs to x86_64 i386 ppc.
> 
> On Aug 24, 2013, at 15:07, Samuel Halliday <sam.halli...@gmail.com> wrote:
> 
>> On 24 Aug 2013, at 16:24, Ryan Schmidt wrote:
>>>> what command line arguments do I use to get universal builds in my own 
>>>> projects?
>>> 
>>> add all the -arch flags (e.g. "-arch x86_64 -arch i386 -arch ppc64 -arch 
>>> ppc") 
>> 
>> I'm guessing these instructions are for the apple gcc? Because doing this 
>> with the gcc / gfortran that I've been installing with macports gives
>> 
>> gcc-mp-4.8: error: unrecognized command line option '-arch'
> 
> Did you build it with the +universal variant?
> 
> Also, I think FSF just aliases -arch to -mXXX.  It does not seem to support 
> multiple -arch options right:
> 
> ~ $ gcc-mp-4.8 -arch x86_64 -c test.c
> ~ $ file test.o
> test.o: Mach-O 64-bit x86_64 object
> 
> ~ $ gcc-mp-4.8 -arch x86_64 -arch i386 -c test.c
> ~ $ file test.o
> test.o: Mach-O i386 object
> 
> ~ $ gcc-mp-4.8 -arch i386 -arch x86_64 -c test.c
> /var/folders/1b/f1bzh5152y9bvygzl07fn87m0000gn/T//cc7eJXt5.s:5:bad register 
> name `%rbp'
> /var/folders/1b/f1bzh5152y9bvygzl07fn87m0000gn/T//cc7eJXt5.s:7:bad register 
> name `%rsp'
> /var/folders/1b/f1bzh5152y9bvygzl07fn87m0000gn/T//cc7eJXt5.s:10:bad register 
> name `%rbp'
> 
>> and trying to compile C code on Mountain Lion with the apple gcc gives
>> 
>> llvm-gcc-4.2: error trying to exec 
>> '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: 
>> No such file or directory
>> llvm-gcc-4.2: error trying to exec 
>> '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: 
>> No such file or directory
> 
> Yeah.  You need to be on Snow Leopard if you want to compile for ppc.
> 
>> So I'm concluding it is impossible to build universal fortran apps since the 
>> apple gcc doesn't come with gfortran.
> 
> That depends on what you mean by "universal".  It's possible to build 
> i386/x86_64 using gfortran plus lipo (look at the libgcc subport of gcc48 for 
> example)
> 
>> My only hope would be to build separate binaries for each architecture by:
>> 
>> 1. access to old OS X machines (+ macports)
>> 2. cross compile
>> 
>> I don't have access to old machines (and it would be incredibly inconvenient 
>> in any case), and I'm guessing macports doesn't supply cross compilers for 
>> older OS X architectures.
> 
> You just need the SDK.  It's theoretically possible for you to use the 10.5 
> SDK on a modern system, but you'll need to build a ppc compiler.  There's a 
> chance that the apple-gcc42 port may work for you, but it will likely require 
> a bit of massaging (patches welcome).
> 
> --Jeremy

_______________________________________________
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users

Reply via email to