question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failure in compiling 32 bit executables on 64 bit host

See original GitHub issue

Hello, 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ianamasoncommented, Jun 18, 2019

Thanks for reporting the bugs Guilio.

0reactions
peperunascommented, Jun 18, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Application- how to compile 32-bit app on 64 bit host?
How to Compile 32-bit Apps on 64-bit Ubuntu? I tried to install the dependency as mentioned in the post. sudo apt-get install lib32gcc-4.8-dev....
Read more >
Overview of the compatibility considerations for 32-bit ...
This article discusses the compatibility considerations and limitations for 32-bit programs that are running on 64-bit versions of Windows.
Read more >
Cannot remotely cross-compile for Linux 32-bit on 64-bit host
Cross-compilation of a 32-bit Linux application still isn't possible on a 64-bit host Linux system - the target is built as 64-bit binary....
Read more >
Cross compiling 32 bit application from a 64 bit Windows
On a 64bit host, we have both 32 and 64 bit python and pyinstaller installed. Using the 32 bit version, we compiled our...
Read more >
LabVIEW 32-Bit vs. 64-Bit Development Environments FAQ - NI
Can I build a 32-bit version of an executable from the LabVIEW 64-bit application builder? How much memory does LabVIEW have access to?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found