summaryrefslogtreecommitdiff
path: root/arch/powerpc/scripts
diff options
context:
space:
mode:
authorTorsten Duwe <duwe@lst.de>2016-03-03 04:27:00 (GMT)
committerMichael Ellerman <mpe@ellerman.id.au>2016-03-07 03:53:56 (GMT)
commit8c50b72a3b4f1f7cdfdfebd233b1cbd121262e65 (patch)
treee705558f3855d60ef389e651ad204e5c1f3f3f9d /arch/powerpc/scripts
parent153086644fd1fb07fb3af84d9f11542a19b1e8b6 (diff)
downloadlinux-8c50b72a3b4f1f7cdfdfebd233b1cbd121262e65.tar.xz
powerpc/ftrace: Add Kconfig & Make glue for mprofile-kernel
Firstly we add logic to Kconfig to allow a user to choose if they want mprofile-kernel. This has to be user-selectable because only some current toolchains support it. If we enabled it unconditionally we would prevent some users from building the kernel entirely. Arguably it would be nice if we could detect if mprofile-kernel was available, and use it then. However that would violate the principle of least surprise because a user having choosen options such as live patching, would then see them quietly disabled at build time. We also make the user selectable option negative, ie. it disables when selected, so that allyesconfig continues to build on old toolchains. Once we've decided we do want to use mprofile-kernel, we then add a script which checks it actually works. That is because there are versions of gcc that accept the flag but don't generate correct code. Due to the way kconfig works, we can't error out when we detect a non-working toolchain. If we did a user would never be able to modify their config and run oldconfig - because the check would block oldconfig from running. Instead we emit a warning and add a bogus flag to CFLAGS so that the build will fail. Signed-off-by: Torsten Duwe <duwe@suse.de> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/scripts')
-rwxr-xr-xarch/powerpc/scripts/gcc-check-mprofile-kernel.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh b/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh
new file mode 100755
index 0000000..c658d8c
--- /dev/null
+++ b/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+# To debug, uncomment the following line
+# set -x
+
+# Test whether the compile option -mprofile-kernel exists and generates
+# profiling code (ie. a call to _mcount()).
+echo "int func() { return 0; }" | \
+ $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
+ grep -q "_mcount"
+
+# Test whether the notrace attribute correctly suppresses calls to _mcount().
+
+echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
+ $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
+ grep -q "_mcount" && \
+ exit 1
+
+echo "OK"
+exit 0