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.

Build error (symbol relocation) when installing from source

See original GitHub issue

I’ve attempted to build the llvmlite from source on an Ubuntu 18.04 instance. I’m building outside of Conda, following the directions in the docs— I’ve built llvm 8.0 with the supplied patches, which succeeded (but only after doing export RECIPE_DIR=/path/to/llvmlite/conda-recipes/llvmdev— that probably ought to be in the docs).

I’m avoiding Conda because I need to deploy to virtualenv (many of them per machine), and I’m not familiar enough with Conda to figure out how to make them play together (assuming it’s possible); the Conda docs seem to suggest that attempting this is brittle.

With export LLVM_CONFIG=/path/to/my/patched/llvm8/bin/llvm-config running either python3 setup.py build or pip3 install /path/to/local/llvmlite (the latter being the deploy path for virtualenv) will fail with:

g++  -shared   -I/usr/lib/llvm-numba/llvm8/include -std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g -DHAVE_SVML -flto assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp object_file.cpp -o libllvmlite.so  -L/usr/lib/llvm-numba/llvm8/lib -flto -Wl,--exclude-libs=ALL -lLLVMFuzzMutate -lLLVMCoverage -lLLVMDlltoolDriver -lLLVMOrcJIT -lLLVMMCA -lLLVMWindowsManifest -lLLVMTextAPI -lLLVMMCJIT -lLLVMCoroutines -lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMMIRParser -lLLVMTableGen -lLLVMIntelJITEvents -lLLVMDebugInfoDWARF -lLLVMXRay -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyAsmPrinter -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMAMDGPUDisassembler -lLLVMMCDisassembler -lLLVMAMDGPUCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMAsmPrinter -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUUtils -lLLVMObjectYAML -lLLVMOptRemarks -lLLVMLibDriver -lLLVMOption -lLLVMLineEditor -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lz -lrt -ldl -lpthread -lm

/usr/bin/ld: /tmp/ccmiOUve.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol `LLVMPY_CreateString' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile.linux:20: recipe for target 'libllvmlite.so' failed
make: *** [libllvmlite.so] Error 1
Traceback (most recent call last):
  File "/home/ubuntu/sandbox/blugger/llvmlite/ffi/build.py", line 168, in <module>
    main()
  File "/home/ubuntu/sandbox/blugger/llvmlite/ffi/build.py", line 158, in main
    main_posix('linux', '.so')
  File "/home/ubuntu/sandbox/blugger/llvmlite/ffi/build.py", line 150, in main_posix
    subprocess.check_call(['make', '-f', makefile])
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2.
error: command '/usr/bin/python3' failed with exit status 1

If I follow the error and add -fPIC to the LDFLAGS of llvmlite/ffi/Makefile.linux, the build succeeds and passes tests.

Is this something that should be patched or added to the docs, or am I bungling something? Is this the correct fix?

(Even better, if >=30.0 is expected to be available PyPI shortly, that would probably moot my problem).

thanks for any help!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
karolyicommented, Jul 21, 2020

I second this issue. llvmlite won’t build, not even when I run it with CXXFLAGS=-fPIC python -m pip install -U llvmlite.

I’m trying to build this on FreeBSD.

0reactions
esccommented, Jul 21, 2020

@karolyi 👋

My suggestion would be to obtain a clone and look at how setup.py bootstraps ffi/build.py which in turn shells out to make to figure out where your CXXFLAGS is being swallowed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build Error: Relocation R_X86_64_PC32 - Swift Forums
I have a daily build of Swift that I make on a Arch Linux box. On the morning of February 23rd the build...
Read more >
"relocation R_X86_64_32S against " linking Error
Relocation R_X86_64_PC32 against undefined symbol , usually happens when LDFLAGS are set with hardening and CFLAGS not . Maybe just user ...
Read more >
ld.so.1 problem - fatal: relocation error - "referenced symbol ...
Here's what I'm trying to do : I'm compieing one library to include another shared library whcih uses the "string" class (STL). The...
Read more >
ARM Compiler Errors and Warnings Reference Guide Version ...
The relocation is with respect to a symbol that is either: ... Re-compile the object or ensure that these libraries can be found...
Read more >
relocation truncated error - Google Groups
a Makefile and a linker script but no source files or object files. However, it looks like the problem is that you didn't...
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