llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

llvm-related build errors on OSX

Open aldanor opened this issue 8 years ago • 8 comments

With LLVM v3.6.2 installed via Homebrew (default options, --with-clang --with-python --with-rtti) and latest llvmlite from git:

$ which clang++
/usr/local/bin/clang++

$ clang++ --version
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

$ echo $LLVM_CONFIG
/usr/local/opt/llvm/bin/llvm-config

$ cd ffi

$ make -f Makefile.osx
MACOSX_DEPLOYMENT_TARGET=10.7 clang++ -std=c++11 -stdlib=libc++ -dynamiclib `/usr/local/opt/llvm/bin/llvm-config --cxxflags` 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.dylib `/usr/local/opt/llvm/bin/llvm-config --ldflags` `/usr/local/opt/llvm/bin/llvm-config --system-libs --libs all`
Undefined symbols for architecture x86_64:
  "std::terminate()", referenced from:
      ___clang_call_terminate in assembly-4f17ef.o
      ___clang_call_terminate in executionengine-aaf4ed.o
      ___clang_call_terminate in targets-724292.o
      ___clang_call_terminate in dylib-64e9d1.o
      ___clang_call_terminate in linker-ec6d13.o
ld: symbol(s) not found for architecture x86_64
clang-3.6: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

This looks like like a libc++/libstdc++ issue if I use LLVM <= 3.6.2... Is there anything specific about how LLVM has to be installed or anything magical environment variables to be configured for it to work?

aldanor avatar Jul 28 '15 20:07 aldanor

An update: killed all previous llvm installations, reinstalled from brew with --HEAD, now libc++/libstdc++ seems to be resolve but there's this:

$ make -f Makefile.osx
MACOSX_DEPLOYMENT_TARGET=10.7 clang++ -std=c++11 -stdlib=libc++ -dynamiclib `/usr/local/opt/llvm/bin/llvm-config --cxxflags` 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.dylib `/usr/local/opt/llvm/bin/llvm-config --ldflags` `/usr/local/opt/llvm/bin/llvm-config --system-libs --libs all`
targets.cpp:7:10: fatal error: 'llvm/Target/TargetLibraryInfo.h' file not found
#include "llvm/Target/TargetLibraryInfo.h"
         ^
1 error generated.
make: *** [all] Error 1

Apparently, according to http://reviews.llvm.org/rL226078, TargetLibraryInfo.h has been moved over to llvm/Analysis (iiuc, that's for all LLVM versions past 3.6).

aldanor avatar Jul 28 '15 22:07 aldanor

You definitely need LLVM 3.6.x, a later version won't do. As for the first error you've got, I can't comment on it, as I don't use OS X. This seems similar but I don't understand what the fix should look like: http://stackoverflow.com/questions/31152499/undefined-symbols-for-architecture-x86-64-stdterminate-when-building-kal

pitrou avatar Jul 29 '15 10:07 pitrou

Same issue. And adding -stdlib=libc++ doesn't work.

Congee avatar Sep 05 '15 05:09 Congee

Same error in Archlinux with llvm==3.7.0

avances123 avatar Nov 30 '15 12:11 avances123

@avances123: See above comments. Because of constant API changes in LLVM, we only support one minor release of LLVM at a time. Currently, that is 3.6.x. The linking issue on some platforms is still a mystery, though.

seibert avatar Nov 30 '15 14:11 seibert

same problem on Centos 7.1.1503 installed LLVM 3.6.2 from source with cmake, installed llvmlite with pip, also tried fresh version from git (0.9.0.dev+4.g133746e) with setup.py import llvmlite works, import llvmlite.binding produces : /home/blackbird/opt/lib/python3.5/ctypes/init.py in init(self, name, mode, handle, use_errno, use_last_error) 346 if handle is None: --> 347 self._handle = _dlopen(self._name, mode) 348 else:

OSError: /home/blackbird/opt/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi

undertherain avatar Dec 03 '15 14:12 undertherain

To this point, I have no idea how to build it on OS X. Has anyone succeeded with the homebrew's llvm?

Also, MACOSX_DEPLOYMENT_TARGET=10.7 hardcoded in the OSX makefile doesn't seem to be right since it causes warnings like this (with llvm 3.6.2 from homebrew)

    ld: warning: object file (/usr/local/Cellar/llvm/3.6.2/lib/libLLVMSupport.a(regstrlcpy.c.o)) 
was built for newer OSX version (10.11) than being linked (10.7)

TL;DR:

not buildable with -stdlib=libc++ due to

Undefined symbols for architecture x86_64:
  "std::terminate()", referenced from:
      ___clang_call_terminate in assembly-8801e6.o
      ___clang_call_terminate in module-17dbf6.o
      ___clang_call_terminate in executionengine-cf11f9.o
      ___clang_call_terminate in targets-ab69e9.o
      ___clang_call_terminate in dylib-c450e0.o
      ___clang_call_terminate in linker-ddf752.o
ld: symbol(s) not found for architecture x86_64

and not buildable with -stdlib=libstdc++ quite obviously because llvm won't build with it.

aldanor avatar Dec 06 '15 20:12 aldanor

I had exactly same issue just now on arm machine running CentOS 7.6.1810, with numba 0.40.1, llvmlite 0.27.1 and llvm 7.0.1. My llvm was built using system gcc 4.8.5, however I installed gcc 7.4.0 and used that to build Python 3.7.2 and lots of packages for it. So, my first choice was to also build numba with gcc7. I got the

libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi

error. Then, I tried to build numba with llvm 7.0.1. Also the same error. Finally, I followed advice from issue #8 i.e.

I would recommend against using two different compilers -- one for LLVM, one for llvmlite.

And when I built numba with gcc4 (the same which I used to build llvm), the error is gone.

mbdevpl avatar May 25 '19 08:05 mbdevpl