Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags

Hello experts,

This issue has kept me busy all day long. It started off with openssl compilation which was giving linking error with following message:
/usr/local/bin/ld: target elf32-sparc not found
collect2: ld returned 1 exit status

I tried every step possible thing that I could think of but was not able to resolve the issue. Although I came to know that specifying -m32/-m64 flag with my newly built gcc has started reporting this issue. I have tried to provide all neccessary details below including the test program which when I try to compile gives the same issue.
Note: I am using GNU binaries(bintuils 2.21)

#############################################################
bash-3.2# uname -a
SunOS CSAPI-DEV-SOL3 5.10 Generic_147440-01 sun4u sparc SUNW,Sun-Fire-V240
#############################################################
bash-3.2# gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.10
Configured with: ../gcc-4.4.4/configure --prefix=/usr/local/gcc-4.4.4  --program-suffix=-4.4.4 --enable-threads=posix --enable-shared  --enable-languages=c,c++ --with-gnu-as --with-as=/usr/local/bin/as  --with-gnu-ld --with-ld=/usr/local/bin/ld
Thread model: posix
gcc version 4.4.4 (GCC)
#############################################################
Content of test.cpp
#include <iostream>
int main()
{
std::cout<< "hello world\n";
}
#############################################################
/******* 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 remove 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

#############################################################
Could anyone please help me figure out why I am seeing this behavior. I have literally pulled my hair so much that my forehead has started to ache. :frowning:

Thanks,
damz

gcc.gnu.org/bugzilla/show_bug.cgi?id=54155

1 Like

Thank you for following up. It's appreciated.

Regards,
Alister