Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib traceevent: Detect build environment changes

Cross compiling perf requires setting ARCH and CROSS_COMPILE variables,
but libtraceevent couldn't detect the changes so it ends up believing no
recompiling is required. Thus the linker failed like:

LINK perf
../lib/traceevent//libtraceevent.a: member ../lib/traceevent//libtraceevent.a(event-parse.o) in archive is not an object
collect2: ld returned 1 exit status
make: *** [perf] Error 1

This patch fixes this by adding TRACEEVENT-CFLAGS file like
PERF-CFLAGS to track those changes.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1341559297-25725-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
52b5c0d4 043d1a5c

+12 -2
+12 -2
tools/lib/traceevent/Makefile
··· 207 207 libtraceevent.a: $(PEVENT_LIB_OBJS) 208 208 $(Q)$(do_build_static_lib) 209 209 210 - $(PEVENT_LIB_OBJS): %.o: $(src)/%.c 210 + $(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS 211 211 $(Q)$(do_fpic_compile) 212 212 213 213 define make_version.h ··· 272 272 include $(dep_includes) 273 273 endif 274 274 275 + ### Detect environment changes 276 + TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE) 277 + 278 + TRACEEVENT-CFLAGS: force 279 + @FLAGS='$(TRACK_CFLAGS)'; \ 280 + if test x"$$FLAGS" != x"`cat TRACEEVENT-CFLAGS 2>/dev/null`" ; then \ 281 + echo 1>&2 " * new build flags or cross compiler"; \ 282 + echo "$$FLAGS" >TRACEEVENT-CFLAGS; \ 283 + fi 284 + 275 285 tags: force 276 286 $(RM) tags 277 287 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ ··· 307 297 308 298 clean: 309 299 $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d 310 - $(RM) tags TAGS 300 + $(RM) TRACEEVENT-CFLAGS tags TAGS 311 301 312 302 endif # skip-makefile 313 303