2

I am new to x64_86, but forced to use it because RedHat dropped its 32-bit OS support in RHEL 7.x. I have to complile a lot of code, and am not ready to jump to x64 yet (because I do not need 64-bit addresses and do not want to face all related porting issues). So I have considered using -m32 and -mx32, and decided that -mx32 is the best route for me. However, while -m32 works fine on my build machine, when I use -mx32, I get this error:

In file included from /usr/include/features.h:399:0,
                 from /usr/include/string.h:25,
                 from zz.cpp:1:
/usr/include/gnu/stubs.h:13:28: fatal error: gnu/stubs-x32.h: No such file or directory
 # include <gnu/stubs-x32.h>
                            ^
compilation terminated.

I searched the web for solutions and some links indicate that I have to install some mysterious "multilib" rpms for g++ and gcc, however, I cannot find these anywhere. Others suggest that I have to install Linux in the x32 mode and build libgcc for x32, which sound extreme. Any ideas or leads? Did someone actually try g++ -mx32? Maybe it is not even supported on the RH platform... Thanks!

P.S. In order to get the "-m32" option to work I had to install:

yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686

This one fails (yum cannot find these RPMs) - allegedly these are required for -mx32 to work:

yum install gcc-multilib g++-multilib

:(

Michael P.
  • 21
  • 3
  • i would you use -mx32? I do not think it is widely adopted. Just use -m32, I do not think 64bit registers are important to you? – SergeyA Aug 25 '16 at 16:03
  • 1
    Perhaps you are right, but I did not want to use any kind of emulation or backward compatibility mode. In other words, I wanted the code to run in the native x64 environment without the 64bit address overhead. However, if -mx32 is more obscure and not widely used, I would likely shy away from it and use -m32 as you suggested. Thanks! Other opinions, anyone? – Michael P. Aug 25 '16 at 16:42
  • In general, whether it is a good idea or not to use -mx32, what does one need to install in order to be able to compile, link (with -mx32), and run x32 executables on RH 7.2? Does anyone know? I saw some posts where people reported successful compilation and execution of 64-bit, 32-bit, and x32 programs on one machine, like this one: http://stackoverflow.com/questions/21525610/64-bit-executable-runs-slower-than-32-bit-version – Michael P. Aug 26 '16 at 04:41

1 Answers1

0

Multilib is indeed your answer, but do not know why your repo does not support it. I installed mine via apt-get:

sudo apt-get install gcc-multilib

Although it uses 64-bit instructions, it uses the 32-bit ABI so annoyingly will not run under WSL (Windows Linux subsystem), which only supports the 64-bit one.

MikeW
  • 5,504
  • 1
  • 34
  • 29