aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2018-06-03 06:24:15 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2018-06-03 06:24:15 -0400
commitb5240b14396dd9c781b5c759830560cdcf1b7a10 (patch)
treed957cb1ac7546e8cf0c653549de2eb061fe55739
parent481c63acba2559139d0b46db0d83caca05c3cf63 (diff)
parent1421dc6d48296a9e91702743b31458d337610aa6 (diff)
Merge branch 'topic/kbuild' into next
Merge in some commits we're sharing with the kbuild tree.
-rw-r--r--arch/powerpc/Makefile31
-rw-r--r--arch/powerpc/boot/Makefile16
-rw-r--r--arch/powerpc/kernel/vdso32/Makefile15
-rwxr-xr-xarch/powerpc/tools/gcc-check-mprofile-kernel.sh12
-rwxr-xr-xscripts/recordmcount.pl18
5 files changed, 64 insertions, 28 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 95813df90801..6faf1d6ad9dd 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -17,17 +17,18 @@ HAS_BIARCH := $(call cc-option-yn, -m32)
17# Set default 32 bits cross compilers for vdso and boot wrapper 17# Set default 32 bits cross compilers for vdso and boot wrapper
18CROSS32_COMPILE ?= 18CROSS32_COMPILE ?=
19 19
20CROSS32CC := $(CROSS32_COMPILE)gcc
21CROSS32AR := $(CROSS32_COMPILE)ar
22
23ifeq ($(HAS_BIARCH),y) 20ifeq ($(HAS_BIARCH),y)
24ifeq ($(CROSS32_COMPILE),) 21ifeq ($(CROSS32_COMPILE),)
25CROSS32CC := $(CC) -m32 22ifdef CONFIG_PPC32
26KBUILD_ARFLAGS += --target=elf32-powerpc 23# These options will be overridden by any -mcpu option that the CPU
24# or platform code sets later on the command line, but they are needed
25# to set a sane 32-bit cpu target for the 64-bit cross compiler which
26# may default to the wrong ISA.
27KBUILD_CFLAGS += -mcpu=powerpc
28KBUILD_AFLAGS += -mcpu=powerpc
29endif
27endif 30endif
28endif 31endif
29
30export CROSS32CC CROSS32AR
31 32
32ifeq ($(CROSS_COMPILE),) 33ifeq ($(CROSS_COMPILE),)
33KBUILD_DEFCONFIG := $(shell uname -m)_defconfig 34KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
@@ -74,13 +75,15 @@ endif
74endif 75endif
75 76
76ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) 77ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
77override LD += -EL 78KBUILD_CFLAGS += -mlittle-endian
79LDFLAGS += -EL
78LDEMULATION := lppc 80LDEMULATION := lppc
79GNUTARGET := powerpcle 81GNUTARGET := powerpcle
80MULTIPLEWORD := -mno-multiple 82MULTIPLEWORD := -mno-multiple
81KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) 83KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
82else 84else
83override LD += -EB 85KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
86LDFLAGS += -EB
84LDEMULATION := ppc 87LDEMULATION := ppc
85GNUTARGET := powerpc 88GNUTARGET := powerpc
86MULTIPLEWORD := -mmultiple 89MULTIPLEWORD := -mmultiple
@@ -93,19 +96,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
93aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 96aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
94endif 97endif
95 98
96cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
97cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
98ifneq ($(cc-name),clang) 99ifneq ($(cc-name),clang)
99 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align 100 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
100endif 101endif
101 102
103cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
104cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
102aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) 105aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
103aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian 106aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
104 107
105ifeq ($(HAS_BIARCH),y) 108ifeq ($(HAS_BIARCH),y)
106override AS += -a$(BITS) 109KBUILD_CFLAGS += -m$(BITS)
107override LD += -m elf$(BITS)$(LDEMULATION) 110KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
108override CC += -m$(BITS) 111LDFLAGS += -m elf$(BITS)$(LDEMULATION)
109KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) 112KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
110endif 113endif
111 114
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 26d5d2a5b8e9..49767e06202c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -23,19 +23,23 @@ all: $(obj)/zImage
23compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP 23compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
24compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ 24compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ
25 25
26ifdef CROSS32_COMPILE
27 BOOTCC := $(CROSS32_COMPILE)gcc
28 BOOTAR := $(CROSS32_COMPILE)ar
29else
30 BOOTCC := $(CC)
31 BOOTAR := $(AR)
32endif
33
26BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 34BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
27 -fno-strict-aliasing -Os -msoft-float -pipe \ 35 -fno-strict-aliasing -Os -msoft-float -pipe \
28 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ 36 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
29 -D$(compress-y) 37 -D$(compress-y)
30 38
31BOOTCC := $(CC)
32ifdef CONFIG_PPC64_BOOT_WRAPPER 39ifdef CONFIG_PPC64_BOOT_WRAPPER
33BOOTCFLAGS += -m64 40BOOTCFLAGS += -m64
34else 41else
35BOOTCFLAGS += -m32 42BOOTCFLAGS += -m32
36ifdef CROSS32_COMPILE
37 BOOTCC := $(CROSS32_COMPILE)gcc
38endif
39endif 43endif
40 44
41BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) 45BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
@@ -49,6 +53,8 @@ endif
49 53
50BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc 54BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
51 55
56BOOTARFLAGS := -cr$(KBUILD_ARFLAGS)
57
52ifdef CONFIG_DEBUG_INFO 58ifdef CONFIG_DEBUG_INFO
53BOOTCFLAGS += -g 59BOOTCFLAGS += -g
54endif 60endif
@@ -202,7 +208,7 @@ quiet_cmd_bootas = BOOTAS $@
202 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 208 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
203 209
204quiet_cmd_bootar = BOOTAR $@ 210quiet_cmd_bootar = BOOTAR $@
205 cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ 211 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
206 212
207$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE 213$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
208 $(call if_changed_dep,bootcc) 214 $(call if_changed_dep,bootcc)
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index b8c434d1d459..50112d4473bb 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -8,8 +8,15 @@ obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \
8 8
9# Build rules 9# Build rules
10 10
11ifeq ($(CONFIG_PPC32),y) 11ifdef CROSS32_COMPILE
12CROSS32CC := $(CC) 12 VDSOCC := $(CROSS32_COMPILE)gcc
13else
14 VDSOCC := $(CC)
15endif
16
17CC32FLAGS :=
18ifdef CONFIG_PPC64
19CC32FLAGS += -m32
13endif 20endif
14 21
15targets := $(obj-vdso32) vdso32.so vdso32.so.dbg 22targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
@@ -45,9 +52,9 @@ $(obj-vdso32): %.o: %.S FORCE
45 52
46# actual build commands 53# actual build commands
47quiet_cmd_vdso32ld = VDSO32L $@ 54quiet_cmd_vdso32ld = VDSO32L $@
48 cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) 55 cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
49quiet_cmd_vdso32as = VDSO32A $@ 56quiet_cmd_vdso32as = VDSO32A $@
50 cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $< 57 cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
51 58
52# install commands for the unstripped file 59# install commands for the unstripped file
53quiet_cmd_vdso_install = INSTALL $@ 60quiet_cmd_vdso_install = INSTALL $@
diff --git a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
index 061f8035bdbe..a7dd0e5d9f98 100755
--- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
+++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
@@ -7,17 +7,21 @@ set -o pipefail
7# To debug, uncomment the following line 7# To debug, uncomment the following line
8# set -x 8# set -x
9 9
10# -mprofile-kernel is only supported on 64le, so this should not be invoked
11# for other targets. Therefore we can pass in -m64 and -mlittle-endian
12# explicitly, to take care of toolchains defaulting to other targets.
13
10# Test whether the compile option -mprofile-kernel exists and generates 14# Test whether the compile option -mprofile-kernel exists and generates
11# profiling code (ie. a call to _mcount()). 15# profiling code (ie. a call to _mcount()).
12echo "int func() { return 0; }" | \ 16echo "int func() { return 0; }" | \
13 $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ 17 $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
14 grep -q "_mcount" 18 2> /dev/null | grep -q "_mcount"
15 19
16# Test whether the notrace attribute correctly suppresses calls to _mcount(). 20# Test whether the notrace attribute correctly suppresses calls to _mcount().
17 21
18echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \ 22echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
19 $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ 23 $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
20 grep -q "_mcount" && \ 24 2> /dev/null | grep -q "_mcount" && \
21 exit 1 25 exit 1
22 26
23echo "OK" 27echo "OK"
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 191eb949d52c..fe06e77c15eb 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -266,13 +266,29 @@ if ($arch eq "x86_64") {
266 $objcopy .= " -O elf32-sh-linux"; 266 $objcopy .= " -O elf32-sh-linux";
267 267
268} elsif ($arch eq "powerpc") { 268} elsif ($arch eq "powerpc") {
269 my $ldemulation;
270
269 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; 271 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
270 # See comment in the sparc64 section for why we use '\w'. 272 # See comment in the sparc64 section for why we use '\w'.
271 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:"; 273 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
272 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; 274 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
273 275
276 if ($endian eq "big") {
277 $cc .= " -mbig-endian ";
278 $ld .= " -EB ";
279 $ldemulation = "ppc"
280 } else {
281 $cc .= " -mlittle-endian ";
282 $ld .= " -EL ";
283 $ldemulation = "lppc"
284 }
274 if ($bits == 64) { 285 if ($bits == 64) {
275 $type = ".quad"; 286 $type = ".quad";
287 $cc .= " -m64 ";
288 $ld .= " -m elf64".$ldemulation." ";
289 } else {
290 $cc .= " -m32 ";
291 $ld .= " -m elf32".$ldemulation." ";
276 } 292 }
277 293
278} elsif ($arch eq "arm") { 294} elsif ($arch eq "arm") {