* [PATCH] sparse, llvm: Don't fail the build if LLVM is too old
@ 2011-11-25 7:06 Pekka Enberg
2011-11-25 19:50 ` Christopher Li
0 siblings, 1 reply; 2+ messages in thread
From: Pekka Enberg @ 2011-11-25 7:06 UTC (permalink / raw)
To: linux-sparse; +Cc: Pekka Enberg, Linus Torvalds, Christopher Li, Jeff Garzik
Disable sparse-llvm compilation if LLVM version is too old.
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
Makefile | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index e508cae..2b5976d 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,8 @@ HAVE_GCC_DEP:=$(shell touch .gcc-test.c && \
echo 'yes'; rm -f .gcc-test.d .gcc-test.o .gcc-test.c)
HAVE_GTK2:=$(shell pkg-config --exists gtk+-2.0 2>/dev/null && echo 'yes')
HAVE_LLVM:=$(shell llvm-config --version >/dev/null 2>&1 && echo 'yes')
+HAVE_LLVM_VERSION:=$(shell llvm-config --version | grep "^[3-9].*" >/dev/null 2>&1 && echo yes)
+LLVM_VERSION=$(shell llvm-config --version)
GCC_BASE = $(shell $(CC) --print-file-name=)
BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\"
@@ -65,7 +67,13 @@ else
$(warning Your system does not have libgtk2, disabling test-inspect)
endif
-ifeq ($(HAVE_LLVM),yes)
+ifneq ($(HAVE_LLVM),yes)
+$(warning Your system does not have llvm, disabling sparse-llvm)
+else
+ifneq ($(HAVE_LLVM_VERSION),yes)
+$(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
+HAVE_LLVM=no
+else
LLVM_PROGS := sparse-llvm
$(LLVM_PROGS): LD := g++
LDFLAGS += $(shell llvm-config --ldflags)
@@ -76,8 +84,7 @@ INST_PROGRAMS += sparse-llvm sparsec
sparse-llvm_EXTRA_DEPS := sparse-llvm.o
sparse-llvm.o $(sparse-llvm_EXTRA_DEPS): BASIC_CFLAGS += $(LLVM_CFLAGS)
sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS)
-else
-$(warning Your system does not have llvm, disabling sparse-llvm)
+endif
endif
LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
--
1.7.6.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sparse, llvm: Don't fail the build if LLVM is too old
2011-11-25 7:06 [PATCH] sparse, llvm: Don't fail the build if LLVM is too old Pekka Enberg
@ 2011-11-25 19:50 ` Christopher Li
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Li @ 2011-11-25 19:50 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-sparse, Linus Torvalds, Jeff Garzik
First of all, I want to make the sparse-llvm works on release version as well,
if that is not too much trouble.
On Thu, Nov 24, 2011 at 11:06 PM, Pekka Enberg <penberg@kernel.org> wrote:
> HAVE_LLVM:=$(shell llvm-config --version >/dev/null 2>&1 && echo 'yes')
> +HAVE_LLVM_VERSION:=$(shell llvm-config --version | grep "^[3-9].*" >/dev/null 2>&1 && echo yes)
> +LLVM_VERSION=$(shell llvm-config --version)
>
> GCC_BASE = $(shell $(CC) --print-file-name=)
> BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\"
> @@ -65,7 +67,13 @@ else
> $(warning Your system does not have libgtk2, disabling test-inspect)
> endif
>
> -ifeq ($(HAVE_LLVM),yes)
> +ifneq ($(HAVE_LLVM),yes)
> +$(warning Your system does not have llvm, disabling sparse-llvm)
Notice you use recursive assign here. It will cause "shell llvm-config
--version"
being execute every time $(LLVM_VERSION) is expanded. That slow down
the makefile. Because LLVM_VERSION don't change during the compile.
Better make it non-recursive assign so the llvm-config only evaluate once.
I also don't want to put the sparse-llvm rules section in nested if.
That is makes it harder to read.
I am thinking some thing like this:
LLVM_VERSION := $(shell llvm-config --version 2>/dev/null)
LLVM_VERSION_LIST := $(subst ., ,$(LLVM_VERSION))
LLVM_VERSION_MAJOR := $(word 1, $(LLVM_VERSION_LIST))
HAVE_LLVM_V3 := $(shell [ "$(LLVM_VERSION_MAJOR)" -ge 3 ] > /dev/null
2>&1 && echo yes)
ifeq ($(HAVE_LLVM_V3),yes)
# rules to compile sparse-llvm
else
# warning of LLVM don't exist or too old
endif
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-25 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-25 7:06 [PATCH] sparse, llvm: Don't fail the build if LLVM is too old Pekka Enberg
2011-11-25 19:50 ` Christopher Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox