views:

138

answers:

2

I have a Solaris sparc machine and when i build my programs, it generates 32bit code which should be 64bit. How to check the cause?

$uname -a
SunOS sol 5.10 Generic_118833-33 sun4u sparc SUNW,Sun-Fire-V240
$/usr/sfw/bin/gcc --version
gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$/usr/sfw/bin/gcc test.c
$file a.out
a.out: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped, no debugging information available $

+1  A: 

You should be able to force a 64-bit build using the -m64 option.

If that fails, you can download and install a prebuilt GCC package with 64-bit SPARC support for Solaris 10 from SunFreeware.com (download, gunzip, install with pkgadd -d gcc-...-sparc-local) which will run from /usr/local/bin/gcc.

vladr
Yes it turn out to be 32bit. But why? Is it selected during package installation?
Adil
@Adil Unlike on x86_64, 64-bit SPARC code requires more memory for no performance gain over 32-bit, so it is best only used when the 32-bit address space is insufficient. SPARC userspace is therefore 32-bit by default, even when the hardware and kernel are 64-bit.
ephemient
+1  A: 

OSNews - SPARC Optimizations With GCC

The creation of 64-bit code requires using the -m64 flag (-m32 for 32-bit code is implied by default).

(Yes, this is different than GCC for x86_64, which defaults to -m64 unless overridden with -m32.)

ephemient