Thursday, October 28, 2021

[SOLVED] Install Crystal Linux Mint. Error: Could not locate compatible llvm-config

Issue

Following steps to install Crystal from source: https://crystal-lang.org/install/from_sources/

Need to run make command that raise error:

Makefile:65: *** Could not locate compatible llvm-config, make sure it is installed and in your PATH, or set LLVM_CONFIG. Compatible versions: 12.0 11.1 11.0 10.0 9.0 8.0 7.1 6.0 5.0 4.0 3.9 3.8.  Stop.

It's a known issue which can be solved this way:

heavy_check_mark from apt.llvm.org
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 11

Source: https://github.com/crystal-lang/crystal/issues/10557#issuecomment-810170295

But for Linux Mint 20:

lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description:    Linux Mint 20
Release:    20
Codename:   ulyana

It's raises the error:

 sudo ./llvm.sh 11
+ needed_binaries=(lsb_release wget add-apt-repository)
+ missing_binaries=()
+ for binary in "${needed_binaries[@]}"
+ which lsb_release
+ for binary in "${needed_binaries[@]}"
+ which wget
+ for binary in "${needed_binaries[@]}"
+ which add-apt-repository
+ [[ 0 -gt 0 ]]
+ LLVM_VERSION=13
+ '[' 1 -eq 1 ']'
+ LLVM_VERSION=11
++ lsb_release -is
+ DISTRO=Linuxmint
++ lsb_release -sr
+ VERSION=20
+ DIST_VERSION=Linuxmint_20
+ [[ 0 -ne 0 ]]
+ declare -A LLVM_VERSION_PATTERNS
+ LLVM_VERSION_PATTERNS[9]=-9
+ LLVM_VERSION_PATTERNS[10]=-10
+ LLVM_VERSION_PATTERNS[11]=-11
+ LLVM_VERSION_PATTERNS[12]=-12
+ LLVM_VERSION_PATTERNS[13]=-13
+ LLVM_VERSION_PATTERNS[14]=
+ '[' '!' _ ']'
+ LLVM_VERSION_STRING=-11
+ case "$DIST_VERSION" in
+ echo 'Distribution '\''Linuxmint'\'' in version '\''20'\'' is not supported by this script (Linuxmint_20).'
Distribution 'Linuxmint' in version '20' is not supported by this script (Linuxmint_20).
+ exit 2

Appreciate any advice to solve this issue?


Solution

According to the documentation source, it's better to use version 8.0 as the latest supported:

enter image description here

Even though use the proper version (8.0) is good, the script from https://apt.llvm.org/llvm.sh still raise an error:

sudo ./llvm.sh 8
+ needed_binaries=(lsb_release wget add-apt-repository)
+ missing_binaries=()
+ for binary in "${needed_binaries[@]}"
+ which lsb_release
+ for binary in "${needed_binaries[@]}"
+ which wget
+ for binary in "${needed_binaries[@]}"
+ which add-apt-repository
+ [[ 0 -gt 0 ]]
+ LLVM_VERSION=13
+ '[' 1 -eq 1 ']'
+ LLVM_VERSION=8
++ lsb_release -is
+ DISTRO=Linuxmint
++ lsb_release -sr
+ VERSION=20
+ DIST_VERSION=Linuxmint_20
+ [[ 0 -ne 0 ]]
+ declare -A LLVM_VERSION_PATTERNS
+ LLVM_VERSION_PATTERNS[9]=-9
+ LLVM_VERSION_PATTERNS[10]=-10
+ LLVM_VERSION_PATTERNS[11]=-11
+ LLVM_VERSION_PATTERNS[12]=-12
+ LLVM_VERSION_PATTERNS[13]=-13
+ LLVM_VERSION_PATTERNS[14]=
+ '[' '!' ']'
+ echo 'This script does not support LLVM version 8'
This script does not support LLVM version 8
+ exit 3

The solution is use native sudo apt-get install lldb-8 command to install the required lib.

Now make command passed:

 make
Using /usr/bin/llvm-config-8 [version=8.0.1]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm-8/include -std=c++11  -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
In file included from /usr/lib/llvm-8/include/llvm/IR/DIBuilder.h:18,
                 from src/llvm/ext/llvm_ext.cc:1:
/usr/lib/llvm-8/include/llvm/ADT/ArrayRef.h: In instantiation of ‘llvm::ArrayRef<T>::ArrayRef(const std::initializer_list<_Tp>&) [with T = long unsigned int]’:
/usr/lib/llvm-8/include/llvm/IR/DIBuilder.h:645:74:   required from here
/usr/lib/llvm-8/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing ‘llvm::ArrayRef<long unsigned int>::Data’ from ‘std::initializer_list<long unsigned int>::begin’ does not extend the lifetime of the underlying array [-Winit-list-lifetime]
  102 |     : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
CRYSTAL_CONFIG_BUILD_COMMIT="cc0b8d1f0" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1632497766" CRYSTAL_CONFIG_LIBRARY_PATH='$ORIGIN/../lib/crystal' ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib


Answered By - Aleksei Strizhak