LLVM_CONFIG llvm_mode fix
MODIFY
docs/ChangeLog
docs/ChangeLog
@@ -22,6 +22,8 @@ Version ++2.54d (dev):
add AFL_CUSTOM_MUTATOR_ONLY (that will trigger the previous behaviour)
- no more unlinking the input file, this way the input file can also be a
FIFO or disk partition
+ - setting LLVM_CONFIG for llvm_mode will now again switch to the selected
+ llvm version. If you setup is correct.
- reducing duplicate code in afl-fuzz
- added "make help"
- removed compile warnings from python internal stuff

MODIFY
llvm_mode/Makefile
llvm_mode/Makefile
@@ -38,6 +38,7 @@ endif
LLVMVER = $(shell $(LLVM_CONFIG) --version)
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version | egrep -q '^[12]|^3\.0|^1[0-9]' && echo 1 || echo 0 )
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version | sed 's/\..*//')
+LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir)
ifeq "$(LLVM_UNSUPPORTED)" "1"
$(warn llvm_mode only supports versions 3.8.0 up to 9)
@@ -77,11 +78,18 @@ endif
# this seems to be busted on some distros, so using the one in $PATH is
# probably better.
-ifeq "$(origin CC)" "default"
- ifeq "$(shell uname)" "OpenBSD"
- CC = $(BIN_PATH)/clang
- CXX = $(BIN_PATH)/clang++
+CC = $(LLVM_BINDIR)/clang
+CXX = $(LLVM_BINDIR)/clang++
+
+ifeq "$(shell test -e $(CC) || echo 1 )" "1"
+ # llvm-config --bindir is not providing a valid path, so ...
+ ifeq "$(shell test -e "$(BIN_DIR)/clang" && echo 1)" "1"
+ # we found one in the local install directory, lets use these
+ CC = $(BIN_DIR)/clang
+ CXX = $(BIN_DIR)/clang++
else
+ # hope for the best
+ $(warn we have trouble finding clang/clang++ - llvm-config is not helping us)
CC = clang
CXX = clang++
endif

MODIFY
llvm_mode/README.md
llvm_mode/README.md
@@ -41,6 +41,10 @@ In order to leverage this mechanism, you need to have clang installed on your
system. You should also make sure that the llvm-config tool is in your path
(or pointed to via LLVM_CONFIG in the environment).
+Note that if you have several LLVM versions installed, pointing LLVM_CONFIG
+to the version you want to use will switch compiling to this specific
+version - if you installation is set up correctly :-)
+
Unfortunately, some systems that do have clang come without llvm-config or the
LLVM development headers; one example of this is FreeBSD. FreeBSD users will
also run into problems with clang being built statically and not being able to

LLVM_CONFIG llvm_mode fix