Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-2.1' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/acme/linux into perf/core

Pull perf/core improvements from Arnaldo Carvalho de Melo:

User visible changes:

  - Add record.build-id config option to 'perf record', to allow configuring
    in the ~/.perfconfig file if and how build-ids should be processed, allowing
    a permanent setting for options such as -B and -N: (Namhyung Kim)

    $ perf record -h -B -N

     Usage: perf record [<options>] [<command>]
        or: perf record [<options>] -- <command> [<options>]

        -B, --no-buildid       do not collect buildids in perf.data
        -N, --no-buildid-cache do not update the buildid cache

    $

Infrastructure changes:

  - Move code for options parsing and subcommand handling from tools/perf/
    to tools/lib/subcmd/, so that it can be used by other tools/ living
    utilities (Josh Poimboeuf)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Dec 18, 2015
2 parents 0d76ded + 1843b4e commit b21daae
Show file tree
Hide file tree
Showing 85 changed files with 1,103 additions and 582 deletions.
3 changes: 1 addition & 2 deletions tools/build/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif

feature_check = $(eval $(feature_check_code))
define feature_check_code
feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
endef

feature_set = $(eval $(feature_set_code))
Expand Down Expand Up @@ -101,7 +101,6 @@ ifeq ($(feature-all), 1)
#
$(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
else
$(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
$(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
endif

Expand Down
93 changes: 47 additions & 46 deletions tools/build/feature/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

FILES= \
test-all.bin \
test-backtrace.bin \
Expand Down Expand Up @@ -38,76 +37,78 @@ FILES= \
test-bpf.bin \
test-get_cpuid.bin

FILES := $(addprefix $(OUTPUT),$(FILES))

CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config

all: $(FILES)

__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1

###############################

test-all.bin:
$(OUTPUT)test-all.bin:
$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma

test-hello.bin:
$(OUTPUT)test-hello.bin:
$(BUILD)

test-pthread-attr-setaffinity-np.bin:
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
$(BUILD) -D_GNU_SOURCE -lpthread

test-stackprotector-all.bin:
$(OUTPUT)test-stackprotector-all.bin:
$(BUILD) -fstack-protector-all

test-fortify-source.bin:
$(OUTPUT)test-fortify-source.bin:
$(BUILD) -O2 -D_FORTIFY_SOURCE=2

test-bionic.bin:
$(OUTPUT)test-bionic.bin:
$(BUILD)

test-libelf.bin:
$(OUTPUT)test-libelf.bin:
$(BUILD) -lelf

test-glibc.bin:
$(OUTPUT)test-glibc.bin:
$(BUILD)

DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif

test-dwarf.bin:
$(OUTPUT)test-dwarf.bin:
$(BUILD) $(DWARFLIBS)

test-libelf-mmap.bin:
$(OUTPUT)test-libelf-mmap.bin:
$(BUILD) -lelf

test-libelf-getphdrnum.bin:
$(OUTPUT)test-libelf-getphdrnum.bin:
$(BUILD) -lelf

test-libnuma.bin:
$(OUTPUT)test-libnuma.bin:
$(BUILD) -lnuma

test-numa_num_possible_cpus.bin:
$(OUTPUT)test-numa_num_possible_cpus.bin:
$(BUILD) -lnuma

test-libunwind.bin:
$(OUTPUT)test-libunwind.bin:
$(BUILD) -lelf

test-libunwind-debug-frame.bin:
$(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -lelf

test-libaudit.bin:
$(OUTPUT)test-libaudit.bin:
$(BUILD) -laudit

test-libslang.bin:
$(OUTPUT)test-libslang.bin:
$(BUILD) -I/usr/include/slang -lslang

test-gtk2.bin:
$(OUTPUT)test-gtk2.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)

test-gtk2-infobar.bin:
$(OUTPUT)test-gtk2-infobar.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)

grep-libs = $(filter -l%,$(1))
Expand All @@ -119,63 +120,63 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)

test-libperl.bin:
$(OUTPUT)test-libperl.bin:
$(BUILD) $(FLAGS_PERL_EMBED)

test-libpython.bin:
$(OUTPUT)test-libpython.bin:
$(BUILD)

test-libpython-version.bin:
$(OUTPUT)test-libpython-version.bin:
$(BUILD)

test-libbfd.bin:
$(OUTPUT)test-libbfd.bin:
$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl

test-liberty.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
$(OUTPUT)test-liberty.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty

test-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
$(OUTPUT)test-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz

test-cplus-demangle.bin:
$(OUTPUT)test-cplus-demangle.bin:
$(BUILD) -liberty

test-backtrace.bin:
$(OUTPUT)test-backtrace.bin:
$(BUILD)

test-timerfd.bin:
$(OUTPUT)test-timerfd.bin:
$(BUILD)

test-libdw-dwarf-unwind.bin:
$(OUTPUT)test-libdw-dwarf-unwind.bin:
$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)

test-libbabeltrace.bin:
$(OUTPUT)test-libbabeltrace.bin:
$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)

test-sync-compare-and-swap.bin:
$(OUTPUT)test-sync-compare-and-swap.bin:
$(BUILD)

test-compile-32.bin:
$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
$(OUTPUT)test-compile-32.bin:
$(CC) -m32 -o $@ test-compile.c

test-compile-x32.bin:
$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
$(OUTPUT)test-compile-x32.bin:
$(CC) -mx32 -o $@ test-compile.c

test-zlib.bin:
$(OUTPUT)test-zlib.bin:
$(BUILD) -lz

test-lzma.bin:
$(OUTPUT)test-lzma.bin:
$(BUILD) -llzma

test-get_cpuid.bin:
$(OUTPUT)test-get_cpuid.bin:
$(BUILD)

test-bpf.bin:
$(OUTPUT)test-bpf.bin:
$(BUILD)

-include *.d
-include $(OUTPUT)*.d

###############################

clean:
rm -f $(FILES) *.d $(FILES:.bin=.make.output)
rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)
4 changes: 4 additions & 0 deletions tools/include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ void *memdup(const void *src, size_t len);

int strtobool(const char *s, bool *res);

#ifndef __UCLIBC__
extern size_t strlcpy(char *dest, const char *src, size_t size);
#endif

#endif /* _LINUX_STRING_H_ */
27 changes: 27 additions & 0 deletions tools/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>
#include <errno.h>
#include <linux/string.h>
#include <linux/compiler.h>

/**
* memdup - duplicate region of memory
Expand Down Expand Up @@ -60,3 +61,29 @@ int strtobool(const char *s, bool *res)
}
return 0;
}

/**
* strlcpy - Copy a C-string into a sized buffer
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @size: size of destination buffer
*
* Compatible with *BSD: the result is always a valid
* NUL-terminated string that fits in the buffer (unless,
* of course, the buffer size is zero). It does not pad
* out the result like strncpy() does.
*
* If libc has strlcpy() then that version will override this
* implementation:
*/
size_t __weak strlcpy(char *dest, const char *src, size_t size)
{
size_t ret = strlen(src);

if (size) {
size_t len = (ret >= size) ? size - 1 : ret;
memcpy(dest, src, len);
dest[len] = '\0';
}
return ret;
}
7 changes: 7 additions & 0 deletions tools/lib/subcmd/Build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libsubcmd-y += exec-cmd.o
libsubcmd-y += help.o
libsubcmd-y += pager.o
libsubcmd-y += parse-options.o
libsubcmd-y += run-command.o
libsubcmd-y += sigchain.o
libsubcmd-y += subcmd-config.o
48 changes: 48 additions & 0 deletions tools/lib/subcmd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include ../../scripts/Makefile.include
include ../../perf/config/utilities.mak # QUIET_CLEAN

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif

CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
RM = rm -f

MAKEFLAGS += --no-print-directory

LIBFILE = $(OUTPUT)libsubcmd.a

CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE

CFLAGS += -I$(srctree)/tools/include/
CFLAGS += -I$(srctree)/include/uapi
CFLAGS += -I$(srctree)/include

SUBCMD_IN := $(OUTPUT)libsubcmd-in.o

all:

export srctree OUTPUT CC LD CFLAGS V
include $(srctree)/tools/build/Makefile.include

all: fixdep $(LIBFILE)

$(SUBCMD_IN): FORCE
@$(MAKE) $(build)=libsubcmd

$(LIBFILE): $(SUBCMD_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)

clean:
$(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)

FORCE:

.PHONY: clean FORCE
Loading

0 comments on commit b21daae

Please sign in to comment.