Compiling and Linking 64Bit Programs on Solaris Sparc with GCC 3.x

  • Follow


Hi Folks:

I would like to be able to compile source programs to 64 bit binaries on 
the solaris sparc platform using gcc 3.x.   In the past I've given what 
I've thought we're the correct arguments to the compile program, but 
when it links the program it complains about the linker not compiling 64 
bit programs.   So I guess my question is how I can get a version of gnu 
ld compiled that will support 64bit binaries...

Any hints on how to accomplish this would be greatly appreciated, 
including recommended reading if that is necessary.


Thanks for the help.

Brian Seppanen
seppanen@chartermi.net

0
Reply seppanen (30) 2/10/2004 9:59:05 PM

Brian E. Seppanen wrote:
> Hi Folks:
> 
> I would like to be able to compile source programs to 64 bit binaries on 
> the solaris sparc platform using gcc 3.x.   In the past I've given what 
> I've thought we're the correct arguments to the compile program, but 
> when it links the program it complains about the linker not compiling 64 
> bit programs.   So I guess my question is how I can get a version of gnu 
> ld compiled that will support 64bit binaries...
> 
> Any hints on how to accomplish this would be greatly appreciated, 
> including recommended reading if that is necessary.
> 
> 
> Thanks for the help.
> 
> Brian Seppanen
> seppanen@chartermi.net
> 

The manual says:
      -m32
      -m64
          Generate code for a 32-bit or 64-bit environment.  The
          32-bit environment sets int, long and pointer to 32
          bits.  The 64-bit environment sets int to 32 bits and
          long and pointer to 64 bits.

Which parameter do you give for compiling and linking in 64Bit mode ?
0
Reply Frank 2/10/2004 10:08:40 PM


On Tue, 10 Feb 2004, Brian E. Seppanen wrote:

> I would like to be able to compile source programs to 64 bit binaries on
> the solaris sparc platform using gcc 3.x.   In the past I've given what

Sun's compilers are a better choice...

> I've thought we're the correct arguments to the compile program, but
> when it links the program it complains about the linker not compiling 64
> bit programs.   So I guess my question is how I can get a version of gnu
> ld compiled that will support 64bit binaries...

GNU Ld isn't required.  Use the one provided by Solaris.

> Any hints on how to accomplish this would be greatly appreciated,
> including recommended reading if that is necessary.

It would help if you told us what you did.

Assuming you used gcc -m64, don't forget that you also have to link with
64-bit libraries.

-- 
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net
0
Reply Rich 2/10/2004 10:53:07 PM


Rich Teer wrote:
> On Tue, 10 Feb 2004, Brian E. Seppanen wrote:
> 
> 
>>I would like to be able to compile source programs to 64 bit binaries on
>>the solaris sparc platform using gcc 3.x.   In the past I've given what
> 
> 
> Sun's compilers are a better choice...
> 
> 
>>I've thought we're the correct arguments to the compile program, but
>>when it links the program it complains about the linker not compiling 64
>>bit programs.   So I guess my question is how I can get a version of gnu
>>ld compiled that will support 64bit binaries...
> 
> 
> GNU Ld isn't required.  Use the one provided by Solaris.
> 

Hadn't thought of that...

> 
>>Any hints on how to accomplish this would be greatly appreciated,
>>including recommended reading if that is necessary.
> 
> 
> It would help if you told us what you did.
> 
> Assuming you used gcc -m64, don't forget that you also have to link with
> 64-bit libraries.

Alright I have gcc-3.3.2.   I'm passing CFLAGS=-m64 to gcc  and I'm 
using LD_OPTIONS=-64.

My compile gets to this point when trying to compile mysql 4.0.17

64 bit

ld: fatal: file 
/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o: wrong ELF 
class: ELFCLASS32
ld: fatal: File processing errors. No output written to .libs/mysql
collect2: ld returned 1 exit status

Now this is using /usr/ccs/bin/ld as my linker.

I do have /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/sparcv9/crt1.o

How can I get the 64 bit support and bypass 32bit support.

Thanks,

> 

0
Reply Brian 2/11/2004 6:33:49 PM

Brian E. Seppanen <seppanen@chartermi.net> wrote:

> ld: fatal: file 
> /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o: wrong ELF 
> class: ELFCLASS32
> ld: fatal: File processing errors. No output written to .libs/mysql
> collect2: ld returned 1 exit status

Do a 'file /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o'.
I'm imagining this is a 32-bit ELF file.  There should be a 64-bit copy
in ...3.3.2/sparcv9/crt1.o

You cannot mix 32 bit and 64 bit libraries in the same executable.

I'm not certain why the compiler is trying to link that library.  I
would imagine that there should be a 64 bit version of that library if
the compiler is capable of producing 64 bit code, and it should be using
that version.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply Darren 2/11/2004 7:01:29 PM


Darren Dunham wrote:
> Brian E. Seppanen <seppanen@chartermi.net> wrote:
> 
> 
>>ld: fatal: file 
>>/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o: wrong ELF 
>>class: ELFCLASS32
>>ld: fatal: File processing errors. No output written to .libs/mysql
>>collect2: ld returned 1 exit status
> 
> 
> Do a 'file /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o'.
> I'm imagining this is a 32-bit ELF file.  There should be a 64-bit copy
> in ...3.3.2/sparcv9/crt1.o
> 
> You cannot mix 32 bit and 64 bit libraries in the same executable.
> 
> I'm not certain why the compiler is trying to link that library.  I
> would imagine that there should be a 64 bit version of that library if
> the compiler is capable of producing 64 bit code, and it should be using
> that version.
> 

That's exactly correct.   It is a 32bit library.   In one directory up 
sparcv9  is crt1.o 64bit.   How do I compile it such that it knows that 
it should use files in that directory rather than the another.   I was 
wondering if maybe I had to pass -mcpu=sparcv9, but that doesn't seem to 
work for me.   Unless I'm specifying it incorrectly.

Thanks for the help.

Brian seppanen
seppanen@chartermi.net

0
Reply Brian 2/11/2004 7:52:29 PM

"Brian E. Seppanen" <seppanen@chartermi.net> writes:


>ld: fatal: file 
>/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/crt1.o: wrong ELF 
>class: ELFCLASS32
>ld: fatal: File processing errors. No output written to .libs/mysql
>collect2: ld returned 1 exit status

There should be two copies of crt1.o under that directory; one for
sparcv9 and one ordinary one; the linker determines the type of
binary from the first object it finds.

>Now this is using /usr/ccs/bin/ld as my linker.

>I do have /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/sparcv9/crt1.o

>How can I get the 64 bit support and bypass 32bit support.


Hm, then there's something wrong with the spec file or are you not linking
with gcc -m64?


Casper
0
Reply Casper 2/12/2004 11:20:17 AM

6 Replies
429 Views

(page loaded in 0.826 seconds)

Similiar Articles:













7/25/2012 5:58:15 PM


Reply: