Failure in compiling 32 bit executables on 64 bit host
See original GitHub issueHello, I am using wllvm to compile various open source projects with LLVM bitcode embedded into the final executables.
I am currently working on a x86_64 machine and, whenever I target x86_64, wllvm works flawlessly. Now I am trying to output 32 bit binaries by using the standard -m32
flag but, unfortunately, I failed to get wllvm to work.
I have tried with the easiest example which is just a hello world program. This is the command I used:
wllvm -m32 helloworld.c -o helloworld
The error I get back is the following:
/usr/bin/ld: i386 architecture of input file `.helloworld.o' is incompatible with i386:x86-64 output
It has to be noted that I am able to compile 32 bits executables with my system’s clang with the same exact arguments. This is the debug log with the environmental flag WLLVM_OUTPUT_LEVEL set to DEBUG:
wllvm -m32 helloworld.c -o helloworld -v
INFO::compilers.wcompile() at compilers.py:29 ::Entering CC [-m32 helloworld.c -o helloworld]
DEBUG::compilers.getBuilder() at compilers.py:252 ::WLLVM compiler using clang
DEBUG::compilers.buildObject() at compilers.py:274 ::buildObject rc = 0
DEBUG::compilers.buildAndAttachBitcode() at compilers.py:305 ::Not compile only case: helloworld.c
DEBUG::compilers.buildObjectFile() at compilers.py:359 ::buildObjectFile: ['clang', '-m32', 'helloworld.c', '-c', '-o', '.helloworld.o']
DEBUG::compilers.buildAndAttachBitcode() at compilers.py:315 ::building and attaching .helloworld.o.bc to .helloworld.o
DEBUG::compilers.buildBitcodeFile() at compilers.py:346 ::buildBitcodeFile: ['clang', '-emit-llvm', '-m32', '-c', 'helloworld.c', '-o', '.helloworld.o.bc']
DEBUG::compilers.attachBitcodePathToObject() at compilers.py:106 ::attachBitcodePathToObject: .helloworld.o.bc ===> .helloworld.o [ext = .o]
DEBUG::compilers.attachBitcodePathToObject() at compilers.py:126 ::Wrote "/tmp/.helloworld.o.bc" to file "/tmp/tmpx86sst6v"
/usr/bin/ld: i386 architecture of input file `.helloworld.o' is incompatible with i386:x86-64 output
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
WARNING::compilers.linkFiles() at compilers.py:336 ::Failed to link "['clang', '.helloworld.o', '-o', 'helloworld']"
As a final note, I have tried to force the host target with the flag “-target i686-unknown-gnu-linux” but it seems that wllvm does not recognize the flag since I get back this warning when executing:
wllvm -m32 -target i686-unknown-linux-gnu helloworld.c -o helloworld
WARNING:Did not recognize the compiler flag "-target"
WARNING:Did not recognize the compiler flag "i686-unknown-linux-gnu"
The aforementioned command line works with my system’s clang.
Any ideas?
Thank you very much!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Thanks for reporting the bugs Guilio.
Hello Ian, my bad, I was using an outdated version of
wllvm
.I have just updated to
wllvm 1.2.7
and I was able to compile the hello world example.Thank you very much for your extremely prompt support and sorry for the disturb I may have caused.