gcc -m31 does not work on an Z/Linux

Latest response

Is it possible to compile with -m31 on an Z/Linux System?

I find no way to install the missing files

Rüdiger

Linux hostname 5.14.0-160.el9.s390x #1 SMP Thu Aug 25 20:47:51 EDT 2022 s390x s390x s390x GNU/Linux

$ gcc -m31 test2.cpp
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/s390x-redhat-linux/11/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Responses

I think the compiler is trying to find the s390 version of libgcc but the last RHEL version where that architecture was supplied was RHEL 7.

From RHEL 8 onwards, RHEL for IBM Z is supplied only for 64-bit s390x. That seems to include the userspace packages too.

If you need to compile for s390 with then you could use RHEL 7. You could also try to run a RHEL 7 userspace container on your RHEL 9.

(PS: I removed the hostname from your uname output)