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

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

按照以下步骤从源安装 Crystal: https://crystal-lang.org/install/from_sources/

需要运行 make 引发错误的命令:

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.

这是一个可以通过这种方式解决的已知问题:

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

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

但对于 Linux Mint 20:

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

它引发了错误:

 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

感谢任何解决此问题的建议?

根据文档来源,最好使用8.0版本作为最新支持:

即使使用正确的版本 (8.0) 很好,来自 https://apt.llvm.org/llvm.sh 的脚本仍然会引发错误:

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

解决方案是使用本机 sudo apt-get install lldb-8 命令安装所需的库。

现在 make 命令已通过:

 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