diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2018-06-03 06:24:15 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-06-03 06:24:15 -0400 |
commit | b5240b14396dd9c781b5c759830560cdcf1b7a10 (patch) | |
tree | d957cb1ac7546e8cf0c653549de2eb061fe55739 | |
parent | 481c63acba2559139d0b46db0d83caca05c3cf63 (diff) | |
parent | 1421dc6d48296a9e91702743b31458d337610aa6 (diff) |
Merge branch 'topic/kbuild' into next
Merge in some commits we're sharing with the kbuild tree.
-rw-r--r-- | arch/powerpc/Makefile | 31 | ||||
-rw-r--r-- | arch/powerpc/boot/Makefile | 16 | ||||
-rw-r--r-- | arch/powerpc/kernel/vdso32/Makefile | 15 | ||||
-rwxr-xr-x | arch/powerpc/tools/gcc-check-mprofile-kernel.sh | 12 | ||||
-rwxr-xr-x | scripts/recordmcount.pl | 18 |
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 |
18 | CROSS32_COMPILE ?= | 18 | CROSS32_COMPILE ?= |
19 | 19 | ||
20 | CROSS32CC := $(CROSS32_COMPILE)gcc | ||
21 | CROSS32AR := $(CROSS32_COMPILE)ar | ||
22 | |||
23 | ifeq ($(HAS_BIARCH),y) | 20 | ifeq ($(HAS_BIARCH),y) |
24 | ifeq ($(CROSS32_COMPILE),) | 21 | ifeq ($(CROSS32_COMPILE),) |
25 | CROSS32CC := $(CC) -m32 | 22 | ifdef CONFIG_PPC32 |
26 | KBUILD_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. | ||
27 | KBUILD_CFLAGS += -mcpu=powerpc | ||
28 | KBUILD_AFLAGS += -mcpu=powerpc | ||
29 | endif | ||
27 | endif | 30 | endif |
28 | endif | 31 | endif |
29 | |||
30 | export CROSS32CC CROSS32AR | ||
31 | 32 | ||
32 | ifeq ($(CROSS_COMPILE),) | 33 | ifeq ($(CROSS_COMPILE),) |
33 | KBUILD_DEFCONFIG := $(shell uname -m)_defconfig | 34 | KBUILD_DEFCONFIG := $(shell uname -m)_defconfig |
@@ -74,13 +75,15 @@ endif | |||
74 | endif | 75 | endif |
75 | 76 | ||
76 | ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) | 77 | ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) |
77 | override LD += -EL | 78 | KBUILD_CFLAGS += -mlittle-endian |
79 | LDFLAGS += -EL | ||
78 | LDEMULATION := lppc | 80 | LDEMULATION := lppc |
79 | GNUTARGET := powerpcle | 81 | GNUTARGET := powerpcle |
80 | MULTIPLEWORD := -mno-multiple | 82 | MULTIPLEWORD := -mno-multiple |
81 | KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) | 83 | KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) |
82 | else | 84 | else |
83 | override LD += -EB | 85 | KBUILD_CFLAGS += $(call cc-option,-mbig-endian) |
86 | LDFLAGS += -EB | ||
84 | LDEMULATION := ppc | 87 | LDEMULATION := ppc |
85 | GNUTARGET := powerpc | 88 | GNUTARGET := powerpc |
86 | MULTIPLEWORD := -mmultiple | 89 | MULTIPLEWORD := -mmultiple |
@@ -93,19 +96,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) | |||
93 | aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 | 96 | aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 |
94 | endif | 97 | endif |
95 | 98 | ||
96 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian | ||
97 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) | ||
98 | ifneq ($(cc-name),clang) | 99 | ifneq ($(cc-name),clang) |
99 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align | 100 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align |
100 | endif | 101 | endif |
101 | 102 | ||
103 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) | ||
104 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian | ||
102 | aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) | 105 | aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) |
103 | aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian | 106 | aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian |
104 | 107 | ||
105 | ifeq ($(HAS_BIARCH),y) | 108 | ifeq ($(HAS_BIARCH),y) |
106 | override AS += -a$(BITS) | 109 | KBUILD_CFLAGS += -m$(BITS) |
107 | override LD += -m elf$(BITS)$(LDEMULATION) | 110 | KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) |
108 | override CC += -m$(BITS) | 111 | LDFLAGS += -m elf$(BITS)$(LDEMULATION) |
109 | KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) | 112 | KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) |
110 | endif | 113 | endif |
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 | |||
23 | compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP | 23 | compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP |
24 | compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ | 24 | compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ |
25 | 25 | ||
26 | ifdef CROSS32_COMPILE | ||
27 | BOOTCC := $(CROSS32_COMPILE)gcc | ||
28 | BOOTAR := $(CROSS32_COMPILE)ar | ||
29 | else | ||
30 | BOOTCC := $(CC) | ||
31 | BOOTAR := $(AR) | ||
32 | endif | ||
33 | |||
26 | BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | 34 | BOOTCFLAGS := -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 | ||
31 | BOOTCC := $(CC) | ||
32 | ifdef CONFIG_PPC64_BOOT_WRAPPER | 39 | ifdef CONFIG_PPC64_BOOT_WRAPPER |
33 | BOOTCFLAGS += -m64 | 40 | BOOTCFLAGS += -m64 |
34 | else | 41 | else |
35 | BOOTCFLAGS += -m32 | 42 | BOOTCFLAGS += -m32 |
36 | ifdef CROSS32_COMPILE | ||
37 | BOOTCC := $(CROSS32_COMPILE)gcc | ||
38 | endif | ||
39 | endif | 43 | endif |
40 | 44 | ||
41 | BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) | 45 | BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) |
@@ -49,6 +53,8 @@ endif | |||
49 | 53 | ||
50 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc | 54 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc |
51 | 55 | ||
56 | BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) | ||
57 | |||
52 | ifdef CONFIG_DEBUG_INFO | 58 | ifdef CONFIG_DEBUG_INFO |
53 | BOOTCFLAGS += -g | 59 | BOOTCFLAGS += -g |
54 | endif | 60 | endif |
@@ -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 | ||
204 | quiet_cmd_bootar = BOOTAR $@ | 210 | quiet_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 | ||
11 | ifeq ($(CONFIG_PPC32),y) | 11 | ifdef CROSS32_COMPILE |
12 | CROSS32CC := $(CC) | 12 | VDSOCC := $(CROSS32_COMPILE)gcc |
13 | else | ||
14 | VDSOCC := $(CC) | ||
15 | endif | ||
16 | |||
17 | CC32FLAGS := | ||
18 | ifdef CONFIG_PPC64 | ||
19 | CC32FLAGS += -m32 | ||
13 | endif | 20 | endif |
14 | 21 | ||
15 | targets := $(obj-vdso32) vdso32.so vdso32.so.dbg | 22 | targets := $(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 |
47 | quiet_cmd_vdso32ld = VDSO32L $@ | 54 | quiet_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,$^) |
49 | quiet_cmd_vdso32as = VDSO32A $@ | 56 | quiet_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 |
53 | quiet_cmd_vdso_install = INSTALL $@ | 60 | quiet_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()). |
12 | echo "int func() { return 0; }" | \ | 16 | echo "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 | ||
18 | echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \ | 22 | echo -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 | ||
23 | echo "OK" | 27 | echo "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") { |