Commit e236311e authored by Kamil Godzwon's avatar Kamil Godzwon Committed by Konrad Sztyber
Browse files

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: default avatarKamil Godzwon <kamilx.godzwon@intel.com>
Change-Id: Iaf0dedc2bb3956cf06796e2eb60a5fa6f492b780
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17907


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 72e058bb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -30,13 +30,12 @@ _ocf_precompile() {
# Find matching llvm fuzzer library and clang compiler version
_llvm_precompile() {
	[[ $(clang --version) =~ "version "(([0-9]+).([0-9]+).([0-9]+)) ]]
	clang_version=${BASH_REMATCH[1]}
	clang_num=${BASH_REMATCH[2]}

	export CC=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]}
	[[ -e $fuzzer_lib ]]