Professional Web Applications Themes

Compiling in 32/64-bit mode with a G5 - Mac Programming

Hello everybody, sorry for crossposting but I don't know where post this message. I am trying to compile some stuff code in 32 and 64-bit mode but I am only successfull to compile it in 32-bit mode. To see if the gcc compiler compiles my programs in 32 or 64-bit modes I wrote a silly program like this, where we can see in which mode is the code: #include <stdio.h> int main() { int *p; long l; if ((sizeof(p)==4) && (sizeof(l)==4)) /* 32-bit mode */ printf("\n32-bit compilation!\n"); else printf("\n64-bit compilation!\n"); /* 64-bit mode */ printf("\nSize of int*: %d bytes", sizeof(p)); ...

  1. #1

    Default Compiling in 32/64-bit mode with a G5

    Hello everybody, sorry for crossposting but I don't know where post this
    message.

    I am trying to compile some stuff code in 32 and 64-bit mode but I am
    only successfull to compile it in 32-bit mode.

    To see if the gcc compiler compiles my programs in 32 or 64-bit modes I
    wrote a silly program like this, where we can see in which mode is the code:

    #include <stdio.h>

    int main()
    {
    int *p;
    long l;

    if ((sizeof(p)==4) && (sizeof(l)==4)) /* 32-bit mode */
    printf("\n32-bit compilation!\n");
    else
    printf("\n64-bit compilation!\n"); /* 64-bit mode */

    printf("\nSize of int*: %d bytes", sizeof(p));
    printf("\nSize of long: %d bytes\n", sizeof(l));

    return;
    }

    I needed to write this code because the BSD 'file' program doesn't
    inform about in which mode is compiled the binary unlike the GNU/Linux
    version.

    I am using the next flags for GCC:

    -O3 -fno-strict-aliasing -static-libgcc \
    -ffast-math -fmove-all-movables -freduce-all-givs \
    -finline-functions -frerun-loop-opt -frerun-cse-after-loop

    As you can see all flags are for optimization and for static binaries. I
    see the optional flag -arch only avaliable for Darwin systems
    (introduced by Apple in gcc).

    So I decided to try '-arch ppc64' as soon as I saw in 'man gcc'. But It
    doesn't work because I need a ppc64 directory under
    /usr/libexec/gcc/darwin (compiler libraries for gcc darwin). On the
    other side I suppose that, like in GNU/Linux box, I need some libraries
    for 64-bit mode under /lib64 or /usr/lib64 (directories which don't
    exist at this moment).

    Do you know where I can get information to complete such process (obtain
    64-bit binaries programs with GCC)?

    Thx in advance,
    Regards!
    --
    ----------------------------------------------------------------------
    o//o Raúl de la Cruz Martínez E-mail: delacruz at ac upc es
    o//o CEPBA-IBM Research Institute (CIRI) www.cepba.upc.es/ciri
    o//o http://people.ac.upc.es/delacruz Tel: +34 93-401 16 49
    o//o CIRI C/Jordi Girona 1-3, Despatx C6-S103. BCN, Catalonia, SPAIN
    ----------------------------------------------------------------------
    Raúl Guest

  2. #2

    Default Re: Compiling in 32/64-bit mode with a G5

    In article <c6nv3c$4a4$upc.es>, Raúl de la Cruz <com>
    wrote:
     

    <http://developer.apple.com/technotes/tn/tn2086.html>

    hth

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  3. #3

    Default Re: Compiling in 32/64-bit mode with a G5

    Miro Jurisic wrote: 
    >
    >
    > <http://developer.apple.com/technotes/tn/tn2086.html>
    >
    > hth
    >
    > meeroh
    >[/ref]

    Thank you Miro,... this page seems to be very useful.

    BTW do you know how can I check that a program has been compiled in 32
    or 64-bit mode?

    In a PPC970 computer with GNU/Linux box is very easy using the 'file'
    command. This programs gives an output like this:

    32-bit bin:
    ============
    delacruzc11b03-0:/export/testVMX-0.1> file testVMX-gcc-32
    testVMX-gcc-32: ELF 32-bit MSB executable, PowerPC or cisco 4500,
    version 1 (SYSV), statically linked, not stripped

    64-bit bin:
    ============
    delacruzc11b03-0:/export/testVMX-0.1> file testVMX-gcc-64
    testVMX-gcc-64: ELF 64-bit MSB executable, cisco 7500, version 1 (SYSV),
    statically linked, not stripped

    On the other side in a PPC970 computer with Mac OS X (BSD) when I use
    file command I only get this output:

    bellver:/opt/testVMX-0.1 delacruz$ file testBit-32
    testBit-32: Mach-O executable ppc

    As you can see it doesn't inform about what type of binary it is.
    Do you know how can I get this info?

    Thx in advance again,
    Regards!
    --
    ----------------------------------------------------------------------
    o//o Raúl de la Cruz Martínez E-mail: delacruz at ac upc es
    o//o CEPBA-IBM Research Institute (CIRI) www.cepba.upc.es/ciri
    o//o http://people.ac.upc.es/delacruz Tel: +34 93-401 16 49
    o//o CIRI C/Jordi Girona 1-3, Despatx C6-S103. BCN, Catalonia, SPAIN
    ----------------------------------------------------------------------
    Raúl Guest

  4. #4

    Default Re: Compiling in 32/64-bit mode with a G5

    In article <c6o4dj$bke$upc.es>, Raúl de la Cruz <com>
    wrote:
     
    > >
    > >
    > > <http://developer.apple.com/technotes/tn/tn2086.html>
    > >
    > > hth
    > >
    > > meeroh
    > >[/ref]
    >
    > Thank you Miro,... this page seems to be very useful.
    >
    > BTW do you know how can I check that a program has been compiled in 32
    > or 64-bit mode?[/ref]

    There is no such thing as 32 or 64 bit mode. All programs are in 32-bit mode,
    the entire userland runs in 32 bit mode, and the only pieces of code allowed
    access to the full 64-bit address space are some drivers. The only thing that
    you can get right now is to compile with G5 instructions enabled, which allows
    you access to 64-bit wide integer registers and a few other things. It doesn't
    make sense to speak of 64-bit mode when the granularity is per instruction.

    hth

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  5. #5

    Default Re: Compiling in 32/64-bit mode with a G5

    Raúl de la Cruz <com> wrote in message news:<c6nv3c$4a4$upc.es>... 
    <snip> 

    Currently you cannot. Mac OS X 10.3 only supports a 32-bit address
    space per application.

    Thorsten
    Thorrsten Guest

Similar Threads

  1. Replies: 3
    Last Post: August 21st, 01:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139