Build 32-bit with 64-bit llvm-gcc

好久不见. 提交于 2019-12-03 06:19:45

Try setting:

export CFLAGS="-m32"
export LDFLAGS="-m32"

before compiling...

Could you try this series of commands and see if it works? Theoretically if you provided llvm-gcc with the -m32 option these steps should be taken by llvm-gcc, but maybe it's not working correctly, so let's make all the steps explicit:

llvm-gcc -m32 -emit-llvm test.c -c -o test.bc
llc test.bc -march=x86 -o test.S
gcc test.S -m32 -o test

This should be the sequence of steps (or something similar) that llvm-gcc performs implicitly, but it looks like in your case it's emitting 64bit assembly for some reason, then trying to assemble and link it for 32bit.

I had the same problem, llvm-gcc ignores the flags, the only solution that worked was to switch from llvm-gcc to clang which does respect the -m32. That or switch to a 32 bit operating system for llvm-gcc work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!