Compiling kaleidoscope tutorial code fails with clang++ -g -O3 toy.cpp $(llvm-config --cxxflags) -std=c++17 (as the example goes) and outputs the following error:
Undefined symbols for architecture x86_64:
"llvm::DisableABIBreakingChecks", referenced from:
llvm::VerifyDisableABIBreakingChecks in toy-e1a114.o
ld: symbol(s) not found for architecture x86_64
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
LLVM were installed with brew install llvm (version 10 when this question is posted), later changed to brew install llvm@8.
Interesting thing is, removing header llvm/ADT/STLExtras.h actually solves this. But I'm afraid removing this will not be a general solution.
I think the problem might be that
$(llvm-config --cxxflags)doesn't work properly in macOS. I don't know exactly what it is with--cxxflags, but I personally experienced a problem that$(llvm-config --libfiles)didn't return the correct path to the shared librarylibLLVMin macOS (that command worked in Linux anyway).However, I suggest to use CMake, which you will need anyway when working with LLVM. Below is a sample CMake code copied from the LLVM website. I followed this CMake code and can compile my project in macOS.