test/autobuild: Update llvm_precompile function to handle newer CLANG versions

The llvm_precompile function checks for the CLANG version available on the machine
using bash regex and searches for fuzzer libraries in a path based on the full CLANG
version number. (e.g. /usr/lib64/clang/15.0.3/...)

However, on the newest Fedora distribution, the path has changed and fuzzer libraries
couldn't be found. Currently, CLANG libraries path contains only major version number
(/usr/lib64/clang/16)

To address this issue, the function has been updated to search only for the major
CLANG version number instead of the full version number. Instead of using clang_version,
the function now uses clang_num because in every Fedora distribution there is directory
or symlink that points to the right CLANG version.

e.g. symlinks
/usr/lib64/clang/13 -> /usr/lib64/clang/13.0.1
/usr/lib64/clang/15 -> /usr/lib64/clang/15.0.3

or directory:
/usr/lib64/clang/16

Fixes #3000

Signed-off-by: Kamil Godzwon <kamilx.godzwon@intel.com>
Change-Id: Iaf0dedc2bb3956cf06796e2eb60a5fa6f492b780
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17907
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Kamil Godzwon 2023-05-02 07:10:19 -04:00 committed by David Ko
parent 6be9d04cb5
commit d117053679

View File

@ -30,13 +30,12 @@ _ocf_precompile() {
# Find matching llvm fuzzer library and clang compiler version # Find matching llvm fuzzer library and clang compiler version
_llvm_precompile() { _llvm_precompile() {
[[ $(clang --version) =~ "version "(([0-9]+).([0-9]+).([0-9]+)) ]] [[ $(clang --version) =~ "version "(([0-9]+).([0-9]+).([0-9]+)) ]]
clang_version=${BASH_REMATCH[1]}
clang_num=${BASH_REMATCH[2]} clang_num=${BASH_REMATCH[2]}
export CC=clang-$clang_num export CC=clang-$clang_num
export CXX=clang++-$clang_num export CXX=clang++-$clang_num
fuzzer_libs=(/usr/lib*/clang/"$clang_version"/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a) fuzzer_libs=(/usr/lib*/clang/"$clang_num"/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a)
fuzzer_lib=${fuzzer_libs[0]} fuzzer_lib=${fuzzer_libs[0]}
[[ -e $fuzzer_lib ]] [[ -e $fuzzer_lib ]]