Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error (symbol relocation) when installing from source #522

Open
trbabb opened this issue Oct 10, 2019 · 13 comments
Open

Build error (symbol relocation) when installing from source #522

trbabb opened this issue Oct 10, 2019 · 13 comments
Labels
build needtriage Needs to be triaged further

Comments

@trbabb
Copy link
Contributor

trbabb commented Oct 10, 2019

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!

@stuartarchibald
Copy link
Contributor

Thanks for the report. Suspect this is related to #502 and #518. Are you building from the master branch?

FWIW 0.30.0 wheels will be out within the next few days.

@trbabb
Copy link
Contributor Author

trbabb commented Oct 10, 2019

Yes, building from master.

Just found #502 and am currently working around with CXXFLAGS.

@stuartarchibald
Copy link
Contributor

Yes, building from master.

Just found #502 and am currently working around with CXXFLAGS.

Great, if that doesn't work please shout. Also, wheels are up for 0.30.0.

@jvesely
Copy link
Contributor

jvesely commented Oct 28, 2019

It'd be nice if pip install llvmlite built a local wheel instead of just calling setup.py install (scipy does that), but I have no idea how pip decides for one or the other.

EDIT: nvm, pip does that automatically if wheel is installed.

@karolyi
Copy link

karolyi commented 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.

@karolyi
Copy link

karolyi commented Jul 21, 2020

Also tried to build with pip from master (CXXFLAGS='-fPIC' python -m pip install -U git+https://github.com/numba/llvmlite.git) but to avail.

can we pick up some speed on this, please?

@jvesely
Copy link
Contributor

jvesely commented Jul 21, 2020

Also tried to build with pip from master (CXXFLAGS='-fPIC' python -m pip install -U git+https://github.com/numba/llvmlite.git) but to avail.

can we pick up some speed on this, please?

the workaround is to install the wheel package. pip will automatically build local wheels and use them to install sdist packages.

nvm: the workaround only works for Linux sdist packages

@karolyi
Copy link

karolyi commented Jul 21, 2020

Also tried to build with pip from master (CXXFLAGS='-fPIC' python -m pip install -U git+https://github.com/numba/llvmlite.git) but to avail.
can we pick up some speed on this, please?

the workaround is to install the wheel package. pip will automatically build local wheels and use them to install sdist packages.

That is already done from the get-go. Whenever I install a venv, I start with python -m pip install -U pip wheel setuptools to avoid further errors.

Here's the output of CXXFLAGS='-fPIC' python -m pip install -U git+https://github.com/numba/llvmlite.git:

Collecting git+https://github.com/numba/llvmlite.git
  Cloning https://github.com/numba/llvmlite.git to /tmp/pip-req-build-8p1rnjsr
  Running command git clone -q https://github.com/numba/llvmlite.git /tmp/pip-req-build-8p1rnjsr
Building wheels for collected packages: llvmlite
  Building wheel for llvmlite (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/project-prod/project/root/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-dti8h52l
       cwd: /tmp/pip-req-build-8p1rnjsr/
  Complete output (125 lines):
  /home/project-prod/project/root/venv/lib/python3.7/site-packages/setuptools/dist.py:458: UserWarning: Normalizing '0.34.0dev0' to '0.34.0.dev0'
    warnings.warn(tmpl.format(**locals()))
  running bdist_wheel
  /home/project-prod/project/root/venv/bin/python /tmp/pip-req-build-8p1rnjsr/ffi/build.py
  LLVM version... clang++ -std=c++11 -stdlib=libc++ -shared -I/usr/local/llvm90/include -std=c++11 -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g 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/local/llvm90/lib -lLLVM-9
  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/assembly-f4c9d4.o
  >>> referenced by assembly.cpp:25
  >>>               /tmp/assembly-f4c9d4.o:(LLVMPY_ParseAssembly)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/assembly-f4c9d4.o
  >>> referenced by assembly.cpp:30
  >>>               /tmp/assembly-f4c9d4.o:(LLVMPY_ParseAssembly)

  ld: error: can't create dynamic relocation R_X86_64_64 against symbol: vtable for llvm::raw_string_ostream in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /usr/local/llvm90/lib/libLLVM-9.so
  >>> referenced by raw_ostream.h:493 (/usr/local/llvm90/include/llvm/Support/raw_ostream.h:493)
  >>>               /tmp/assembly-f4c9d4.o:(llvm::raw_string_ostream::raw_string_ostream(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&))

  ld: error: can't create dynamic relocation R_X86_64_64 against symbol: vtable for llvm::raw_ostream in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /usr/local/llvm90/lib/libLLVM-9.so
  >>> referenced by raw_ostream.h:88 (/usr/local/llvm90/include/llvm/Support/raw_ostream.h:88)
  >>>               /tmp/assembly-f4c9d4.o:(llvm::raw_ostream::raw_ostream(bool))

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/bitcode-d5b48d.o
  >>> referenced by bitcode.cpp:25
  >>>               /tmp/bitcode-d5b48d.o:(LLVMPY_ParseBitcode)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by module.cpp:117
  >>>               /tmp/module-299c33.o:(LLVMPY_PrintModuleToString)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
 >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
  >>>               /tmp/module-299c33.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >, llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >::initEmpty())

  ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in /tmp/module-299c33.o
  >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
  >>>               /tmp/module-299c33.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >, llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >::initEmpty())

  ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  *** Error code 1

  Stop.
  make: stopped in /tmp/pip-req-build-8p1rnjsr/ffi
  9.0.1

  SVML not detected
  Traceback (most recent call last):
    File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 191, in <module>
      main()
    File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 183, in main
      main_posix('freebsd', '.so')
    File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 173, in main_posix
      subprocess.check_call(['make', '-f', makefile])
    File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
      raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.freebsd']' returned non-zero exit status 1.
  error: command '/home/project-prod/project/root/venv/bin/python' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Failed to build llvmlite
Installing collected packages: llvmlite
    Running setup.py install for llvmlite ... error
    ERROR: Command errored out with exit status 1:
     command: /home/project-prod/project/root/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-guyjtleo/install-record.txt --single-version-externally-managed --compile --install-headers /home/project-prod/project/root/venv/include/site/python3.7/llvmlite
         cwd: /tmp/pip-req-build-8p1rnjsr/
    Complete output (128 lines):
    /home/project-prod/project/root/venv/lib/python3.7/site-packages/setuptools/dist.py:458: UserWarning: Normalizing '0.34.0dev0' to '0.34.0.dev0'
      warnings.warn(tmpl.format(**locals()))
    running install
    running build
    got version from VCS {'version': '0.34.0dev0', 'full': '118e993ff33ab240679595511e59b891900e972e'}
    running build_ext
    /home/project-prod/project/root/venv/bin/python /tmp/pip-req-build-8p1rnjsr/ffi/build.py
    LLVM version... clang++ -std=c++11 -stdlib=libc++ -shared -I/usr/local/llvm90/include -std=c++11 -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g 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/local/llvm90/lib -lLLVM-9
    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/assembly-8865e4.o
    >>> referenced by assembly.cpp:25
    >>>               /tmp/assembly-8865e4.o:(LLVMPY_ParseAssembly)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/assembly-8865e4.o
    >>> referenced by assembly.cpp:30
    >>>               /tmp/assembly-8865e4.o:(LLVMPY_ParseAssembly)

    ld: error: can't create dynamic relocation R_X86_64_64 against symbol: vtable for llvm::raw_string_ostream in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /usr/local/llvm90/lib/libLLVM-9.so
    >>> referenced by raw_ostream.h:493 (/usr/local/llvm90/include/llvm/Support/raw_ostream.h:493)
    >>>               /tmp/assembly-8865e4.o:(llvm::raw_string_ostream::raw_string_ostream(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&))

    ld: error: can't create dynamic relocation R_X86_64_64 against symbol: vtable for llvm::raw_ostream in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /usr/local/llvm90/lib/libLLVM-9.so
    >>> referenced by raw_ostream.h:88 (/usr/local/llvm90/include/llvm/Support/raw_ostream.h:88)
    >>>               /tmp/assembly-8865e4.o:(llvm::raw_ostream::raw_ostream(bool))

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/bitcode-28fc85.o
    >>> referenced by bitcode.cpp:25
    >>>               /tmp/bitcode-28fc85.o:(LLVMPY_ParseBitcode)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by module.cpp:117
    >>>               /tmp/module-350ca1.o:(LLVMPY_PrintModuleToString)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::GlobalVariable, false, false, void>, false, false>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by ilist_iterator.h:139 (/usr/local/llvm90/include/llvm/ADT/ilist_iterator.h:139)
    >>>               /tmp/module-350ca1.o:(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, true>::operator*() const)

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >, llvm::Value const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseSetPair<llvm::Value const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >, llvm::MDNode const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::MDNode const*>, llvm::detail::DenseSetPair<llvm::MDNode const*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >, llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >::initEmpty())

    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
    >>> defined in /tmp/module-350ca1.o
    >>> referenced by DenseMap.h:373 (/usr/local/llvm90/include/llvm/ADT/DenseMap.h:373)
    >>>               /tmp/module-350ca1.o:(llvm::DenseMapBase<llvm::DenseMap<llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >, llvm::Type*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::Type*>, llvm::detail::DenseSetPair<llvm::Type*> >::initEmpty())

    ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    *** Error code 1

    Stop.
    make: stopped in /tmp/pip-req-build-8p1rnjsr/ffi
    9.0.1

    SVML not detected
    Traceback (most recent call last):
      File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 191, in <module>
        main()
      File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 183, in main
        main_posix('freebsd', '.so')
      File "/tmp/pip-req-build-8p1rnjsr/ffi/build.py", line 173, in main_posix
        subprocess.check_call(['make', '-f', makefile])
      File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.freebsd']' returned non-zero exit status 1.
    error: command '/home/project-prod/project/root/venv/bin/python' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/project-prod/project/root/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-8p1rnjsr/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-guyjtleo/install-record.txt --single-version-externally-managed --compile --install-headers /home/project-prod/project/root/venv/include/site/python3.7/llvmlite Check the logs for full command output.

Sorry, didn't want to spam the issue with the entire output but it seems inevitable.

@jvesely
Copy link
Contributor

jvesely commented Jul 21, 2020

   LLVM version... clang++ -std=c++11 -stdlib=libc++ -shared -I/usr/local/llvm90/include -std=c++11 -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g 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/local/llvm90/lib -lLLVM-9
    ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

the above line needs -fPIC.

sorry got the issues mixed up. One is that setup.py only adds -fPIC when building wheel (that's what the workaround is for), the other one is that it only adds -fPIC on Linux.

@karolyi
Copy link

karolyi commented Jul 21, 2020

I realized this ... the problem is, it doesn't take the passed CXXFLAGS into account, not even with master. Hence me posting in here.

Exporting CXXFLAGS doesn't work either.

@esc
Copy link
Member

esc commented Jul 21, 2020

@karolyi thanks for following up on this issue. Are you able to build it from a source clone at least?

@karolyi
Copy link

karolyi commented Jul 21, 2020

@esc hey, long time no see :)
CXXFLAGS='-fPIC' python -m pip install -U git+https://github.com/numba/llvmlite.git builds from master, so the answer would be no.

@esc
Copy link
Member

esc commented 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.

@esc esc added needtriage Needs to be triaged further build labels Jul 21, 2020
gmarkall added a commit to gmarkall/llvmlite that referenced this issue Aug 21, 2020
On systems that do not build PIC by default, linking libllvmlite.so
fails. This commit adds an option to the `build_ext` command in setup.py
(`--pic`) to compile with `-fPIC`.

Related issues: numba#553, numba#542, numba#522 - this commit may address some of these
issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build needtriage Needs to be triaged further
Projects
None yet
Development

No branches or pull requests

5 participants