aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-05-30 08:19:21 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2018-06-01 09:08:09 -0400
commit1421dc6d48296a9e91702743b31458d337610aa6 (patch)
tree3341d1a4b9765ca7f523a52498b0563d14e758b0
parentaf3901cbbd3de182aafb8ee553c825c0074df6a2 (diff)
powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
The powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g., `CC -m64 -mbig-endian` To be the C compiler for the purpose of invoking it to build target artifacts. So overriding the CC variable to include these flags works for this purpose. Unfortunately that is not compatible with the way the proposed new Kconfig macro language will work. After previous patches in this series, these flags can be carefully passed in using flags instead. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/Makefile16
-rwxr-xr-xarch/powerpc/tools/gcc-check-mprofile-kernel.sh12
-rwxr-xr-xscripts/recordmcount.pl18
3 files changed, 34 insertions, 12 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 167b26a0780c..6faf1d6ad9dd 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -75,13 +75,15 @@ endif
75endif 75endif
76 76
77ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) 77ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
78override LD += -EL 78KBUILD_CFLAGS += -mlittle-endian
79LDFLAGS += -EL
79LDEMULATION := lppc 80LDEMULATION := lppc
80GNUTARGET := powerpcle 81GNUTARGET := powerpcle
81MULTIPLEWORD := -mno-multiple 82MULTIPLEWORD := -mno-multiple
82KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) 83KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
83else 84else
84override LD += -EB 85KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
86LDFLAGS += -EB
85LDEMULATION := ppc 87LDEMULATION := ppc
86GNUTARGET := powerpc 88GNUTARGET := powerpc
87MULTIPLEWORD := -mmultiple 89MULTIPLEWORD := -mmultiple
@@ -94,19 +96,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
94aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 96aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
95endif 97endif
96 98
97cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
98cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
99ifneq ($(cc-name),clang) 99ifneq ($(cc-name),clang)
100 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align 100 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
101endif 101endif
102 102
103cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
104cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
103aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) 105aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
104aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian 106aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
105 107
106ifeq ($(HAS_BIARCH),y) 108ifeq ($(HAS_BIARCH),y)
107override AS += -a$(BITS) 109KBUILD_CFLAGS += -m$(BITS)
108override LD += -m elf$(BITS)$(LDEMULATION) 110KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
109override CC += -m$(BITS) 111LDFLAGS += -m elf$(BITS)$(LDEMULATION)
110KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) 112KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
111endif 113endif
112 114
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") {