This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to tell if gcc uses GNU or Sun linker on Solaris?


Dennis Clarke wrote:
Is there any way to tell for certain if gcc uses the GNU or Sun linker
on Solaris, in a program? I would also like to do the same for the
assembler, though that is less important to me.

I can tell on my machine it uses the Sun linker and assembler

$ gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.10
Configured with: ../gcc-4.4.1/configure
--prefix=/usr/local/gcc-4.4.1-sun-linker/ --with-as=/usr/ccs/bin/as
--without-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--enable-languages=c,c++,fortran --with-mpfr-include=/usr/local/include
--with-mpfr-lib=/usr/local/lib --with-gmp-include=/usr/local/include
--with-gmp-lib=/usr/local/lib CC=/usr/sfw/bin/gcc CXX=/usr/sfw/bin/g++
LDFLAGS='-R /usr/local/lib -L /usr/local/lib'
Thread model: posix
gcc version 4.4.1 (GCC)


Looking there I see '--without-gnu-as' and '--without-gnu-ld', but there is no guarantee someone uses those options when configure gcc. Here it is even more clear, with -with-ld=/usr/ccs/bin/ld and --with-as=/usr/ccs/bin/as. But what happens if I don't specify any of this when I build gcc? Would it just find the first linker and assembler in the path? In which case, how could I now determine what it uses?

Run gcc -v foo.c


$ gcc -v -o hello hello.c
Using built-in specs.
Target: i386-pc-solaris2.10
Configured with: /export/medusa/dclarke/build/GCC/gcc-4.3.4/configure
--build=i386-pc-solaris2.10 --with-gnu-as --with-as=/opt/csw/bin/gas
--without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-cpu-32=i386
--with-cpu-64=opteron --with-arch-32=i386 --with-arch-64=opteron
--enable-stage1-languages=c --enable-nls --with-libiconv-prefix=/opt/csw
--enable-threads=posix --prefix=/opt/csw/gcc4 --with-local-prefix=/opt/csw
--enable-shared --enable-multilib --with-included-gettext
--with-system-zlib --with-gmp=/opt/csw --with-mpfr=/opt/csw
--enable-languages=c,c++,objc,fortran --enable-bootstrap
Thread model: posix
gcc version 4.3.4 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic'
 /opt/csw/gcc4/libexec/gcc/i386-pc-solaris2.10/4.3.4/cc1 -quiet -v hello.c
-quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o
/var/tmp//ccTig2Nt.s
ignoring nonexistent directory
"/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/../../../../i386-pc-solaris2.10/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/csw/include
 /opt/csw/gcc4/include
 /opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/include
 /opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.3.4 (i386-pc-solaris2.10)
        compiled by GNU C version 4.3.4, GMP version 4.3.1, MPFR version
2.4.2-rc1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9ba7f205b9cefa6eae48c8f511c89b44
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic'
 /opt/csw/bin/gas -v -V -Qy -s -o /var/tmp//ccClhznU.o /var/tmp//ccTig2Nt.s
GNU assembler version 2.19.1 (i386-pc-solaris2.8) using BFD version (GNU
Binutils) 2.19.1
COMPILER_PATH=/opt/csw/gcc4/libexec/gcc/i386-pc-solaris2.10/4.3.4/:/opt/csw/gcc4/libexec/gcc/i386-pc-solaris2.10/4.3.4/:/opt/csw/gcc4/libexec/gcc/i386-pc-solaris2.10/:/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/:/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/:/usr/ccs/bin/
LIBRARY_PATH=/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/:/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic'
 /opt/csw/gcc4/libexec/gcc/i386-pc-solaris2.10/4.3.4/collect2 -V -Y
P,/usr/ccs/lib:/usr/lib -Qy -o hello /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/values-Xa.o
/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/crtbegin.o
-L/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4
-L/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/../../..
/var/tmp//ccClhznU.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/opt/csw/gcc4/lib/gcc/i386-pc-solaris2.10/4.3.4/crtend.o /usr/lib/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.496
$

If you look closely you see :

GNU assembler version 2.19.1 (i386-pc-solaris2.8) using BFD version (GNU
Binutils) 2.19.1

and then

ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.496

$ file hello
hello: ELF 32-bit LSB executable 80386 Version 1, dynamically linked, not
stripped, no debugging information available

$ /usr/ccs/bin/mcs -p hello
hello:

@(#)SunOS 5.10 Generic January 2005

@(#)SunOS 5.10 Generic January 2005

@(#)SunOS 5.10 Generic January 2005

GCC: (GNU) 4.3.4

GCC: (GNU) 4.3.4

GCC: (GNU) 4.3.4

@(#)SunOS 5.10 Generic January 2005
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.496




I can see in this case you can tell, but it's hardly a reliable way is it. Who knows exactly what the output will be. I don't see any guarantee this could be used reliably in a test.


I must admit, I can't ever actually recall seeing a gcc where the building has not put --with-gnu-ld or --without-gnu-ld, or specified something on the configure options to give it away. But I suspect someone has built a gcc without doing that.

I think in some open solaris distributions, the gnu assembler is used, but the sun linker. So even finding binutils in an output somewhere does not really help.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]