Skip to content

Commit a8a5cd8

Browse files
mrutland-armacmel
authored andcommitted
perf: tools: Fix cross building
Currently the feature-checks Makefile does not inherit $(CC), and calls cc rather than $(CROSS_COMPILE)gcc. Thus the feature checks invoke the native toolchain rather than the cross toolchain, and can identify features as available when they are not. This can break the build. Additionally the native pkg-config is always called as opposed to $(CROSS_COMPILE)pkg-config, so the wrong flags and paths may be passed to the cross compiler. This patch passes CROSS_COMPILE down to the feature-checks Makefile, and forces its use. Additionally pkg-config is replaced with $(CROSS_COMPILE)pkg-config via a new $(PKG_CONFIG) variable. This patch has been build tested on x86_64 and arm. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Will Deacon <will.deacon@arm.com> Link: http://lkml.kernel.org/r/1389782648-4417-4-git-send-email-mark.rutland@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 8d0c222 commit a8a5cd8

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎tools/perf/Makefile.perf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
7676

7777
CC = $(CROSS_COMPILE)gcc
7878
AR = $(CROSS_COMPILE)ar
79+
PKG_CONFIG = $(CROSS_COMPILE)pkg-config
7980

8081
RM = rm -f
8182
LN = ln -f

‎tools/perf/config/Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ ifndef NO_SLANG
372372
endif
373373

374374
ifndef NO_GTK2
375-
FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
375+
FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
376376
ifneq ($(feature-gtk2), 1)
377377
msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
378378
NO_GTK2 := 1
@@ -381,8 +381,8 @@ ifndef NO_GTK2
381381
GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
382382
endif
383383
CFLAGS += -DHAVE_GTK2_SUPPORT
384-
GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
385-
GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
384+
GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
385+
GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
386386
EXTLIBS += -ldl
387387
endif
388388
endif

‎tools/perf/config/feature-checks/Makefile‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ FILES= \
2828
test-stackprotector-all.bin \
2929
test-timerfd.bin
3030

31-
CC := $(CC) -MD
31+
CC := $(CROSS_COMPILE)gcc -MD
32+
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
3233

3334
all: $(FILES)
3435

@@ -37,7 +38,7 @@ BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
3738
###############################
3839

3940
test-all.bin:
40-
$(BUILD) -Werror -fstack-protector-all -O2 -Werror -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
41+
$(BUILD) -Werror -fstack-protector-all -O2 -Werror -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
4142

4243
test-hello.bin:
4344
$(BUILD)
@@ -82,10 +83,10 @@ test-libslang.bin:
8283
$(BUILD) -I/usr/include/slang -lslang
8384

8485
test-gtk2.bin:
85-
$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
86+
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
8687

8788
test-gtk2-infobar.bin:
88-
$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
89+
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
8990

9091
grep-libs = $(filter -l%,$(1))
9192
strip-libs = $(filter-out -l%,$(1))

0 commit comments

Comments
 (0)