Skip to content

Commit

Permalink
perf python: Properly link with libtraceevent
Browse files Browse the repository at this point in the history
Namhyung Kim reported that the build fails with:

  GEN python/perf.so
  gcc: error: python_ext_build/tmp//../../libtraceevent.a: No such file or directory
  error: command 'gcc' failed with exit status 1
  cp: cannot stat `python_ext_build/lib/perf.so': No such file or directory
  make: *** [python/perf.so] Error 1

We need to propagate the TE_PATH variable to the setup.py file.

Reported-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/n/tip-8umiPbm4sxpknKivbjgykhut@git.kernel.org
[ Fixed superfluous variable build error. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Oct 20, 2012
1 parent a448a03 commit 45bff41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
24 changes: 13 additions & 11 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,22 @@ SCRIPT_SH += perf-archive.sh
grep-libs = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))

TRACE_EVENT_DIR = ../lib/traceevent/

ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
else
TE_PATH=$(TRACE_EVENT_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
TE_LIB := -L$(TE_PATH) -ltraceevent

PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py

export LIBTRACEEVENT

$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
--quiet build_ext; \
Expand All @@ -198,17 +211,6 @@ $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)

SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))

TRACE_EVENT_DIR = ../lib/traceevent/

ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
else
TE_PATH=$(TRACE_EVENT_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
TE_LIB := -L$(TE_PATH) -ltraceevent

#
# Single 'perf' binary right now:
#
Expand Down
2 changes: 0 additions & 2 deletions tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,6 @@ PyMODINIT_FUNC initperf(void)
pyrf_cpu_map__setup_types() < 0)
return;

page_size = sysconf(_SC_PAGE_SIZE);

Py_INCREF(&pyrf_evlist__type);
PyModule_AddObject(module, "evlist", (PyObject*)&pyrf_evlist__type);

Expand Down
3 changes: 2 additions & 1 deletion tools/perf/util/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def finalize_options(self):

build_lib = getenv('PYTHON_EXTBUILD_LIB')
build_tmp = getenv('PYTHON_EXTBUILD_TMP')
libtraceevent = getenv('LIBTRACEEVENT')

ext_sources = [f.strip() for f in file('util/python-ext-sources')
if len(f.strip()) > 0 and f[0] != '#']
Expand All @@ -31,7 +32,7 @@ def finalize_options(self):
sources = ext_sources,
include_dirs = ['util/include'],
extra_compile_args = cflags,
extra_objects = [build_tmp + '/../../libtraceevent.a'],
extra_objects = [libtraceevent],
)

setup(name='perf',
Expand Down

0 comments on commit 45bff41

Please sign in to comment.