http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54155
--- Comment #2 from damz <dshanke at gmail dot com> 2012-08-02 10:02:46 UTC --- (In reply to comment #1) > > /******* COMPILATION OUTPUT *******************/ > > bash-3.2# gcc -o test1 test.cpp -m32 -mcpu=ultrasparc -lstdc++ > > /usr/local/bin/ld: target elf32-sparc not found > > collect2: ld returned 1 exit status > > ############################################################# > > > > If I eliminate the -m32/-m64 flag output file is successfully generated. > > ############################################################# > > bash-3.2# file test1 > > test1: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, > > dynamically linked, not stripped > > ############################################################# > > > > Is it something that has gone wrong during configuration due to which the > > compiler does not recognize the -m option? > > Rather strange indeed. What does `/usr/local/bin/ld -V' report? > > Could you compare the command line passed to collect2 w/ and w/o the -m32 > flag? > You need to add -v on the link line to have it printed. ################################################################################ Output of ld -V is as follows: bash-3.2# /usr/local/bin/ld -V GNU ld (GNU Binutils) 2.21.1 Supported emulations: elf32_sparc_sol2 elf32_sparc elf64_sparc_sol2 elf64_sparc ################################################################################ Collect options passed are as follows: Without -m32: COLLECT_GCC_OPTIONS='-o' 'test' '-v' '-shared-libgcc' '-mcpu=v9' With -m32: COLLECT_GCC_OPTIONS='-o' 'test' '-m32' '-v' '-shared-libgcc' '-mcpu=v9' Without -m32: collect2 -V -Y P,/usr/ccs/lib:/usr/lib -rpath-link... With -m32: collect2 -V -m elf32_sparc -Y P,/usr/ccs/lib:/usr/lib -rpath-link ################################################################################ Note: On another machine where the output of ld -V is as follows, gcc 4.4.4 is able to compile successfully with the -m32/-m64 options bash-3.00# /usr/local/bin/ld -V GNU ld (GNU Binutils) 2.20.1.20100303 Supported emulations: elf32_sparc elf64_sparc bash-3.00# ################################################################################ If I replace only the ld from GNU Binutils 2.21.x with the ld from 2.20.x then the compilation is successful with -m32/-m64. Is this a bug in the GNU ld 2.21.x? I read the following link (http://archives.gentoo.org/gentoo-alt/msg_a4641a1c17ce5f66a05c6440dd5cfc87.xml) which suggests a solution to the problem but it did not help me. I ran the following command but no change in behavior when i use ld from gnu binutils 2.21.x ################################################################################ sed -i -e 's/^OUTPUT_FORMAT ( elf32-sparc )$/OUTPUT_FORMAT ( elf32-sparc-sol2 )/' $EPREFIX/usr/lib/lib*.so ################################################################################ Please help. Thanks, damz