1

On Solaris 10 I built gcc 4.9.0 for 64 bit. At least I thought I did. I'm building an Apache based stack, and other prerequisite tools.

If I build apache file shows a 64bit httpd:

file apache-test/bin/httpd 
apache-test/bin/httpd:        ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available

So this suggests to me that my GCC is 64bit, but in the directory where I build my binaries I run for f in *; do file $f; done to run file against the whole directory I get:

for f in *; do file $f; done 
a.out:          empty file 
addr2line:      ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
ar:             ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
as:             ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
c_rehash:       executable /usr/bin/perl script 
c++:            ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
c++filt:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
compile_et:     executable shell script 
cpp:            ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
elfedit:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
g++:            ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
gcc:            ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
gcc-ar:         ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
gcc-nm:         ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
gcc-ranlib:     ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
gcov:           ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS POPC], dynamically linked, not stripped
gprof:          ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
gss-client:     ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
k5srvutil:      executable shell script 
kadmin:         ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
kdestroy:       ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
kinit:          ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
klist:          ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
kpasswd:        ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
krb5-config:    executable shell script 
kswitch:        ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
ktutil:         ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
kvno:           ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
ld:             ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
ld.bfd:         ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
nm:             ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
objcopy:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
objdump:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
openssl:        ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC1 Extensions Required, dynamically linked, not stripped, no debugging information available
pcre-config:    executable shell script 
pcregrep:       ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC3 Extensions Required, dynamically linked, not stripped
pcretest:       ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC3 Extensions Required, dynamically linked, not stripped
ranlib:         ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
readelf:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
sclient:        ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
sim_client:     ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
size:           ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
sparc-sun-solaris2.10-c++:      ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
sparc-sun-solaris2.10-g++:      ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
sparc-sun-solaris2.10-gcc:      ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
sparc-sun-solaris2.10-gcc-4.9.0:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 FMAF VIS], dynamically linked, not stripped
sparc-sun-solaris2.10-gcc-ar:   ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
sparc-sun-solaris2.10-gcc-nm:   ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
sparc-sun-solaris2.10-gcc-ranlib:       ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3], dynamically linked, not stripped
strings:        ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
strip:          ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, UltraSPARC3 Extensions Required [CBCOND VIS3 VIS], dynamically linked, not stripped
uuclient:       ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available

Why am I seeing so many 32bit builds? If I've used gcc to build apache how can it be 64 bit when the gcc files are showing 32bit?

4

GCC on Solaris has some defaults that are different, for example, than GCC on Linux.

For compiling 64 binaries you have to add

-m64

to your compile and link lines.

This makes GCC compatible to the Solaris Studio C compiler, in that respect.

On SPARC, compiling programs as 32 bit does not have as much disadvantages as on e.g. x86, where 64 Bit also gives you additional registers.

  • Thanks, my question was why are the gcc files in the bin directory showing as 32bit, if I've used them to build 64bit apache? – Dr.Avalanche Nov 28 '14 at 14:49
  • 1
    A 32- bit compiler program may generate 32-bit or 64-bit binaries; similarly for a 64-bit compiler. – Jonathan Leffler Nov 28 '14 at 15:05
0

You should think of a compiler as a function which generates output from some input, or

output_program = compile_function(input_source, args)

The exsistence of compile_function as a 32 or 64 bit binary affects how it does its job but not the output.

If we grossly simplify the role of 64-bit to simply increasing the amount of addressable memory, then technically a 32-bit compiler should only be problematic for situations where more than 4GB of addressable memory is requires to produce the output. Such a situation for current times, is mostly inconceivable (although I'm sure some people can come up with a contrived example that does exactly that).

  • Actually, when GCC switched to the TreeSSA internal representation and at the same time added whole program optimizations, it used to run out of memory somewhat regularly, until a simple garbage collector was added to GCC. Also, the Stalin compiler for Scheme is known for two things: producing code that can perform comparably to hand-optimized C, and using ridiculous amounts of memory and time to do so. – Jörg W Mittag Nov 28 '14 at 17:50
  • @JörgWMittag Thanks for the enlightening comment. The main purpose of the second paragraph waffle was to illustrate that in all but a few cases it should not matter, although maybe I have underestimated "all but a few cases". Is there a way I can make this point better? – user1207217 Dec 2 '14 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.