Can the 64 bit RHEL gcc be change to build 32 bit binaries instead of 64 bit binaries without -m32?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 5 and 6
  • gcc-4.4.6-4.el6.x86_64
  • gcc-4.1.2-52.el5.x86_64
  • glibc-devel.i386

Issue

  • Is it possible to change the 64 bit RHEL gcc to build 32 bit binaries instead of 64 bit binaries without specifying -m32 on the gcc command line every time?

Resolution

Currently, this can not be accomplished by modifying the SPEC files for the default gcc versions of RHEL 5 and RHEL 6. Some alternatives are below:

  • Use a wrapper shell script (glibc-devel.i386 rpm is required)
#!/bin/sh
exec /usr/bin/gcc -m32 "$@"
  • Use the mock tool to set up a 32-bit environment for compiles

  • Install 32-bit RHEL in a virtual machine and send build jobs to it

  • Component
  • gcc

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments