Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 1 | #!/bin/bash |
Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0 |
Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | # To debug, uncomment the following line |
| 8 | # set -x |
| 9 | |
Nicholas Piggin | 1421dc6 | 2018-05-30 22:19:21 +1000 | [diff] [blame] | 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 | |
Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 14 | # Test whether the compile option -mprofile-kernel exists and generates |
| 15 | # profiling code (ie. a call to _mcount()). |
| 16 | echo "int func() { return 0; }" | \ |
Nicholas Piggin | 1421dc6 | 2018-05-30 22:19:21 +1000 | [diff] [blame] | 17 | $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ |
| 18 | 2> /dev/null | grep -q "_mcount" |
Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 19 | |
| 20 | # Test whether the notrace attribute correctly suppresses calls to _mcount(). |
| 21 | |
| 22 | echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \ |
Nicholas Piggin | 1421dc6 | 2018-05-30 22:19:21 +1000 | [diff] [blame] | 23 | $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ |
| 24 | 2> /dev/null | grep -q "_mcount" && \ |
Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 25 | exit 1 |
| 26 | |
Torsten Duwe | 8c50b72 | 2016-03-03 15:27:00 +1100 | [diff] [blame] | 27 | exit 0 |