elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
424 stars 21 forks source link

Compilation of Crystalline failed on Mac M1 #49

Closed serge-hulne closed 1 year ago

serge-hulne commented 1 year ago

command issued:

shards build crystalline --release --no-debug --progress -Dpreview_mt

Resulting error message

Resolving dependencies
Fetching https://github.com/hugopl/version_from_shard.git
Fetching https://github.com/spider-gazelle/priority-queue.git
Fetching https://github.com/samueleaton/sentry.git
Fetching https://github.com/spider-gazelle/bisect.git
Installing version_from_shard (1.2.4)
Installing bisect (1.2.1)
Installing priority-queue (1.0.1)
Installing sentry (0.3.2 at cd86128)
Building: crystalline
[13/13] [0/1] Codegen (bc+obj)                  
Error target crystalline failed to compile:     
Undefined symbols for architecture arm64:
  "llvm::DIBuilder::createFunction(llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, unsigned int, llvm::DINode::DIFlags, llvm::DISubprogram::DISPFlags, llvm::MDTupleTypedArrayWrapper<llvm::DITemplateParameter>, llvm::DISubprogram*, llvm::MDTupleTypedArrayWrapper<llvm::DIType>, llvm::MDTupleTypedArrayWrapper<llvm::DINode>)", referenced from:
      _LLVMExtDIBuilderCreateFunction in llvm_ext.o
  "llvm::DIBuilder::createMemberType(llvm::DIScope*, llvm::StringRef, llvm::DIFile*, unsigned int, unsigned long long, unsigned int, unsigned long long, llvm::DINode::DIFlags, llvm::DIType*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>)", referenced from:
      _LLVMExtDIBuilderCreateMemberType in llvm_ext.o
  "llvm::DIBuilder::createPointerType(llvm::DIType*, unsigned long long, unsigned int, llvm::Optional<unsigned int>, llvm::StringRef, llvm::MDTupleTypedArrayWrapper<llvm::DINode>)", referenced from:
      _LLVMExtDIBuilderCreatePointerType in llvm_ext.o
  "llvm::DIBuilder::createParameterVariable(llvm::DIScope*, llvm::StringRef, unsigned int, llvm::DIFile*, unsigned int, llvm::DIType*, bool, llvm::DINode::DIFlags, llvm::MDTupleTypedArrayWrapper<llvm::DINode>)", referenced from:
      _LLVMExtDIBuilderCreateParameterVariable in llvm_ext.o
  "llvm::DIBuilder::createReplaceableCompositeType(unsigned int, llvm::StringRef, llvm::DIScope*, llvm::DIFile*, unsigned int, unsigned int, unsigned long long, unsigned int, llvm::DINode::DIFlags, llvm::StringRef, llvm::MDTupleTypedArrayWrapper<llvm::DINode>)", referenced from:
      _LLVMExtDIBuilderCreateReplaceableCompositeType in llvm_ext.o
  "llvm::AttributeList::addAttributeAtIndex(llvm::LLVMContext&, unsigned int, llvm::Attribute::AttrKind) const", referenced from:
      llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&, llvm::MDNode*) in llvm_ext.o
      llvm::IRBuilderBase::CreateInvoke(llvm::FunctionType*, llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) in llvm_ext.o
  "llvm::AttributeList::addAttributeAtIndex(llvm::LLVMContext&, unsigned int, llvm::StringRef, llvm::StringRef) const", referenced from:
      _LLVMExtCreateMCJITCompilerForModule in llvm_ext.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o /Users/sergehulne/Documents/code/Crystal/crystalline/bin/crystalline  -rdynamic -L/opt/homebrew/Cellar/crystal/1.6.0/libexec/../../../../lib -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml /opt/homebrew/Cellar/crystal/1.6.0/share/crystal/src/llvm/ext/llvm_ext.o `"/opt/homebrew/opt/llvm/bin/llvm-config" --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lgc -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent_pthreads -levent -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv`
elbywan commented 1 year ago

Please use llvm 14 and define LLVM_CONFIG if needed.

See: https://github.com/elbywan/crystalline/blob/master/.github/workflows/build.yml#L21 And: https://github.com/elbywan/crystalline/issues/46#issuecomment-1272425408

serge-hulne commented 1 year ago

Thank you!

serge-hulne commented 1 year ago

Here is how I installed llvm@14 (just in case somebody else has the same problem):

installation:

brew install llvm@14

To add to env vars:

export LLVM_CONFIG=/opt/homebrew/Cellar/llvm@14/14.0.6/bin/llvm-config 

checking:

echo $LLVM_CONFIG