使用 64 位 llvm-gcc 构建 32 位 [英] Build 32-bit with 64-bit llvm-gcc
问题描述
我有 64 位版本的 llvm-gcc,但我希望能够同时构建 32 位和 64 位二进制文件.有这方面的标志吗?我尝试传递 -m32(适用于常规 gcc),但收到如下错误消息:
I have a 64-bit version of llvm-gcc, but I want to be able to build both 32-bit and 64-bit binaries. Is there a flag for this? I tried passing -m32 (which works on the regular gcc), but I get an error message like this:
[jay@andesite]$ llvm-gcc -m32 test.c -o test
Warning: Generation of 64-bit code for a 32-bit processor requested.
Warning: 64-bit processors all have at least SSE2.
/tmp/cchzYo9t.s: Assembler messages:
/tmp/cchzYo9t.s:8: Error: bad register name `%rbp'
/tmp/cchzYo9t.s:9: Error: bad register name `%rsp'
...
这是倒退;我想为 64 位处理器生成 32 位代码!
This is backwards; I want to generate 32-bit code for a 64-bit processor!
我正在运行 llvm-gcc 4.2,这是 Ubuntu 9.04 x86-64 附带的.
I'm running llvm-gcc 4.2, the one that comes with Ubuntu 9.04 x86-64.
这是我使用 -v 标志运行 llvm-gcc 时输出的相关部分:
Here is the relevant part of the output when I run llvm-gcc with the -v flag:
[jay@andesite]$ llvm-gcc -v -m32 test.c -o test.bc
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../llvm-gcc4.2-2.2.source/configure --host=x86_64-linux-gnu --build=x86_64-linux-gnu --prefix=/usr/lib/llvm/gcc-4.2 --enable-languages=c,c++ --program-prefix=llvm- --enable-llvm=/usr/lib/llvm --enable-threads --disable-nls --disable-shared --disable-multilib --disable-bootstrap
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5546) (LLVM build)
/usr/lib/llvm/gcc-4.2/libexec/gcc/x86_64-linux-gnu/4.2.1/cc1 -quiet -v -imultilib . test.c -quiet -dumpbase test.c -m32 -mtune=generic -auxbase test -version -o /tmp/ccw6TZY6.s
我查看了/usr/lib/llvm/gcc-4.2/libexec/gcc 希望找到另一个二进制文件,但唯一的目录是 x86_64-linux-gnu.接下来我可能会考虑使用适当的选项从源代码编译 llvm-gcc.
I looked in /usr/lib/llvm/gcc-4.2/libexec/gcc hoping to find another binary, but the only directory there is x86_64-linux-gnu. I will probably look at compiling llvm-gcc from source with appropriate options next.
推荐答案
尝试设置:
export CFLAGS="-m32"
export LDFLAGS="-m32"
编译前...
这篇关于使用 64 位 llvm-gcc 构建 32 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!