llvmlite
llvmlite copied to clipboard
llvm linker command failed - _File format not recognized_
Can't build llvmlite. Linker failed: File format not recognized
Platform: LInux 3.16.7, OpenSUSE 13.2, gcc 4.8.3, llvm 3.5
Using CXX=clang++
(with g++
v4.8.3 the build fails earlier: g++: error: unrecognized command line option ‘-Wcovered-switch-default’)
running build
got version from file /home/robert/Downloads/llvmlite-0.4.0/llvmlite/_version.py {'version': '0.4.0', 'full': '8a681a2726ae79b640b4147b13cdd5e309a5c74f'}
running build_ext
/usr/bin/python ffi/build.py
LLVM version... 3.5.0svn
# static-libstdc++ avoids runtime dependencies on a
# particular libstdc++ version.
clang++ -static-libstdc++ -shared -flto `llvm-config --cxxflags` -fno-rtti assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp -o libllvmlite.so -flto `llvm-config --ldflags` -Wl,--exclude-libs=ALL `llvm-config --system-libs --libs all`
/tmp/assembly-bab5e8.o: file not recognized: File format not recognized
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile.linux:19: recipe for target 'libllvmlite.so' failed
make: *** [libllvmlite.so] Error 1
Traceback (most recent call last):
File "ffi/build.py", line 112, in <module>
main()
File "ffi/build.py", line 104, in main
main_posix('linux', '.so')
File "ffi/build.py", line 96, in main_posix
subprocess.check_call(['make', '-f', makefile])
File "/usr/lib64/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2
error: command '/usr/bin/python' failed with exit status 1
Is your /tmp running out of free space perhaps?
No, already checked.
It's a problem related to binutils gold and the plugin LLVMgold.so. Remove -flto
and it might work.
I hit that all the time (this is a standard problem if you build LLVM with Clang); fortunately, with master avoiding it as simple as CXX_FLTO_FLAGS= LD_FLTO_FLAGS= python3.5 setup.py build
etc.
@whitequark Thank you! Worked a charm =)
Another possibility far better is to have the LLVMgold.so and changed your linker to use it.
So in my case I needed to build the ld.gold as described:
http://llvm.org/docs/GoldPlugin.html#lto-how-to-build
Then build the LLVMgold using the LLVM source code.
sudo alternatives --config ld
...
- 1 /usr/bin/ld.bfd
- 2 /usr/bin/ld.gold ...
Then it worked like a charm.
What? What do you mean @darreal44
@isaacaddis I mean you just have to build llvmgold plugin and use alternatives to select the classical linker or the gold linker. The gold linker will be working with the needed option.But of course you’ll need to rename ld to ld.bfd and the gold linker to ld.gold and make it selected by alternatives(which behind the scene will change a ld link to one of the two possibilities)