How to compile glibc 32bit on an x86_64 machine
I edited the question, but then I realized the proper way is to add an answer. Here's what finally worked:
$ ../../src/glibc-2.6/configure --prefix=$HOME/glibc32-2.6 \
--host=i686-linux-gnu \
--build=i686-linux-gnu \
CC="gcc -m32" CXX="g++ -m32" \
CFLAGS="-O2 -march=i686" \
CXXFLAGS="-O2 -march=i686"
I think putting -m32
in CC and CXX instead of CFLAGS and CXXFLAGS was important because there was at least one compile operation during the make which didn't use CFLAGS or CXXFLAGS, and -m32
absolutely has to always be there. Not sure why -march=i686
was necessary (given the -m32
parts and the --host/build
options), but it was.
newlib: Compiler gets confused when building 32-bit compatibility
I fixed it. I simply disabled multilib, because I can just simply build another compiler for 32-bit.
Force gcc to compile 32 bit programs on 64 bit platform
You need to make GCC use the -m32
flag.
You could try writing a simple shell script to your $PATH
and call it gcc (make sure you don't overwrite the original gcc, and make sure the new script comes earlier in $PATH
, and that it uses the full path to GCC.
I think the code you need is just something like /bin/gcc -m32 $*
depending on your shell (the $*
is there to include all arguments, although it might be something else – very important!)
How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake
export CFLAGS=-m32
Build 32bit on 64 bit Linux using an automake configure script?
Passing the following argument to configure script allowed me to build the 32bit library on 64bit Linux
./configure --build=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32
Related Topics
Can Ptrace Tell If an X86 System Call Used the 64-Bit or 32-Bit Abi
How to Make Binary Distribution of Qt Application for Linux
How Much Does Using Htaccess Files Slow Down Website Performance (Especially with Solid State Disks)
Shell Function to Tail a Log File for a Specific String for a Specific Time
Deceive the Jvm About the Number of Available Cores (On Linux)
Sort by Third Column Leaving First and Second Column Intact in Linux
Cross Compile from Linux to Arm-Elf (Arm926Ej-S/Mt7108)
What Is the Use of "Echo || True"
Redirect Stderr and Stdout to Separate Files in Bash
How to Execute Parallel "For" Loops in Bash
Linux Kernel - Add System Call Dynamically Through Module
Force Gnu Linker to Generate 32 Bit Elf Executables
Postgresql on Elastic Beanstalk (Amazon Linux 2)
How to Do Runtime Binding Based on CPU Capabilities on Linux