Skip to content

Commit 1925459

Browse files
jpoimboeacmel
authored andcommitted
tools build: Fix feature Makefile issues with 'O='
When building perf binaries outside the source tree with 'make O=<dir>', the auto-detected features get re-tested for every build, which is unnecessary and inconsistent with the behavior seen when building directly in the source tree. Another issue is that 'make O=<dir> clean' doesn't remove the feature files from the object tree. Fix these problems by looking for the binaries in the $(OUTPUT) directory. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/113bd01530e9761778c60a75a96c65fc59860f68.1450193761.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7a29c08 commit 1925459

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

tools/build/Makefile.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
feature_check = $(eval $(feature_check_code))
99
define feature_check_code
10-
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)
10+
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)
1111
endef
1212

1313
feature_set = $(eval $(feature_set_code))

tools/build/feature/Makefile

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
FILES= \
32
test-all.bin \
43
test-backtrace.bin \
@@ -38,76 +37,78 @@ FILES= \
3837
test-bpf.bin \
3938
test-get_cpuid.bin
4039

40+
FILES := $(addprefix $(OUTPUT),$(FILES))
41+
4142
CC := $(CROSS_COMPILE)gcc -MD
4243
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
4344

4445
all: $(FILES)
4546

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

4950
###############################
5051

51-
test-all.bin:
52+
$(OUTPUT)test-all.bin:
5253
$(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
5354

54-
test-hello.bin:
55+
$(OUTPUT)test-hello.bin:
5556
$(BUILD)
5657

57-
test-pthread-attr-setaffinity-np.bin:
58+
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
5859
$(BUILD) -D_GNU_SOURCE -lpthread
5960

60-
test-stackprotector-all.bin:
61+
$(OUTPUT)test-stackprotector-all.bin:
6162
$(BUILD) -fstack-protector-all
6263

63-
test-fortify-source.bin:
64+
$(OUTPUT)test-fortify-source.bin:
6465
$(BUILD) -O2 -D_FORTIFY_SOURCE=2
6566

66-
test-bionic.bin:
67+
$(OUTPUT)test-bionic.bin:
6768
$(BUILD)
6869

69-
test-libelf.bin:
70+
$(OUTPUT)test-libelf.bin:
7071
$(BUILD) -lelf
7172

72-
test-glibc.bin:
73+
$(OUTPUT)test-glibc.bin:
7374
$(BUILD)
7475

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

80-
test-dwarf.bin:
81+
$(OUTPUT)test-dwarf.bin:
8182
$(BUILD) $(DWARFLIBS)
8283

83-
test-libelf-mmap.bin:
84+
$(OUTPUT)test-libelf-mmap.bin:
8485
$(BUILD) -lelf
8586

86-
test-libelf-getphdrnum.bin:
87+
$(OUTPUT)test-libelf-getphdrnum.bin:
8788
$(BUILD) -lelf
8889

89-
test-libnuma.bin:
90+
$(OUTPUT)test-libnuma.bin:
9091
$(BUILD) -lnuma
9192

92-
test-numa_num_possible_cpus.bin:
93+
$(OUTPUT)test-numa_num_possible_cpus.bin:
9394
$(BUILD) -lnuma
9495

95-
test-libunwind.bin:
96+
$(OUTPUT)test-libunwind.bin:
9697
$(BUILD) -lelf
9798

98-
test-libunwind-debug-frame.bin:
99+
$(OUTPUT)test-libunwind-debug-frame.bin:
99100
$(BUILD) -lelf
100101

101-
test-libaudit.bin:
102+
$(OUTPUT)test-libaudit.bin:
102103
$(BUILD) -laudit
103104

104-
test-libslang.bin:
105+
$(OUTPUT)test-libslang.bin:
105106
$(BUILD) -I/usr/include/slang -lslang
106107

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

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

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

122-
test-libperl.bin:
123+
$(OUTPUT)test-libperl.bin:
123124
$(BUILD) $(FLAGS_PERL_EMBED)
124125

125-
test-libpython.bin:
126+
$(OUTPUT)test-libpython.bin:
126127
$(BUILD)
127128

128-
test-libpython-version.bin:
129+
$(OUTPUT)test-libpython-version.bin:
129130
$(BUILD)
130131

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

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

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

140-
test-cplus-demangle.bin:
141+
$(OUTPUT)test-cplus-demangle.bin:
141142
$(BUILD) -liberty
142143

143-
test-backtrace.bin:
144+
$(OUTPUT)test-backtrace.bin:
144145
$(BUILD)
145146

146-
test-timerfd.bin:
147+
$(OUTPUT)test-timerfd.bin:
147148
$(BUILD)
148149

149-
test-libdw-dwarf-unwind.bin:
150+
$(OUTPUT)test-libdw-dwarf-unwind.bin:
150151
$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
151152

152-
test-libbabeltrace.bin:
153+
$(OUTPUT)test-libbabeltrace.bin:
153154
$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
154155

155-
test-sync-compare-and-swap.bin:
156+
$(OUTPUT)test-sync-compare-and-swap.bin:
156157
$(BUILD)
157158

158-
test-compile-32.bin:
159-
$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
159+
$(OUTPUT)test-compile-32.bin:
160+
$(CC) -m32 -o $@ test-compile.c
160161

161-
test-compile-x32.bin:
162-
$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
162+
$(OUTPUT)test-compile-x32.bin:
163+
$(CC) -mx32 -o $@ test-compile.c
163164

164-
test-zlib.bin:
165+
$(OUTPUT)test-zlib.bin:
165166
$(BUILD) -lz
166167

167-
test-lzma.bin:
168+
$(OUTPUT)test-lzma.bin:
168169
$(BUILD) -llzma
169170

170-
test-get_cpuid.bin:
171+
$(OUTPUT)test-get_cpuid.bin:
171172
$(BUILD)
172173

173-
test-bpf.bin:
174+
$(OUTPUT)test-bpf.bin:
174175
$(BUILD)
175176

176-
-include *.d
177+
-include $(OUTPUT)*.d
177178

178179
###############################
179180

180181
clean:
181-
rm -f $(FILES) *.d $(FILES:.bin=.make.output)
182+
rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)

0 commit comments

Comments
 (0)