Generating 32-bit Code on 64-bit Linux System

Dear All,

I'm trying to compile a "Hello, world!" C++ program on a 64-bit Linux machine into a 32-bit ELF program using Clang as follows:

clang++ -o test -m32 test.cpp

Unfortunately, I get the following error:

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux6E/4.4.4/libstdc++_nonshared.a when searching for -lstdc++_nonshared
/usr/bin/ld: cannot find -lstdc++_nonshared

Am I using the correct flags to get clang++ to generate 32-bit code? If so, does anyone know what the problem might be? Omitting the -m32 generates a 64-bit executable correctly.

On a related note, is there an LLVM configure option that will generate a clang executable that always generates 32-bit code?

-- John T.

Dear All,

I'm trying to compile a "Hello, world!" C++ program on a 64-bit Linux
machine into a 32-bit ELF program using Clang as follows:

clang++ -o test -m32 test.cpp

Unfortunately, I get the following error:

/usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-redhat-linux6E/4.4.4/libstdc++_nonshared.a when
searching for -lstdc++_nonshared
/usr/bin/ld: cannot find -lstdc++_nonshared

Am I using the correct flags to get clang++ to generate 32-bit code?
If
so, does anyone know what the problem might be? Omitting the -m32
generates a 64-bit executable correctly.

On a related note, is there an LLVM configure option that will generate

a clang executable that always generates 32-bit code?

You probably dont have the 32bit version of the standard lib installed

I think I do:

% yum list libstdc++
...
Installed Packages
libstdc++.i386 4.1.2-50.el5 installed
libstdc++.x86_64 4.1.2-50.el5 installed

Is it possible that the Clang build isn't finding this library? Does anyone know how Clang finds the standard C++ library?

-- John T.

Hardcoded paths at the moment.

-eric

See lib/Driver/ToolChains.cpp in clang. It's messy.

-Eli