blob: 137f3376ac2bb05a3debbcdbe913594dbd7f54a8 [file] [log] [blame]
Torsten Duwe8c50b722016-03-03 15:27:00 +11001#!/bin/bash
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Torsten Duwe8c50b722016-03-03 15:27:00 +11003
4set -e
5set -o pipefail
6
7# To debug, uncomment the following line
8# set -x
9
Nicholas Piggin1421dc62018-05-30 22:19:21 +100010# -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 Duwe8c50b722016-03-03 15:27:00 +110014# Test whether the compile option -mprofile-kernel exists and generates
15# profiling code (ie. a call to _mcount()).
16echo "int func() { return 0; }" | \
Nicholas Piggin1421dc62018-05-30 22:19:21 +100017 $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
18 2> /dev/null | grep -q "_mcount"
Torsten Duwe8c50b722016-03-03 15:27:00 +110019
20# Test whether the notrace attribute correctly suppresses calls to _mcount().
21
22echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
Nicholas Piggin1421dc62018-05-30 22:19:21 +100023 $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
24 2> /dev/null | grep -q "_mcount" && \
Torsten Duwe8c50b722016-03-03 15:27:00 +110025 exit 1
26
Torsten Duwe8c50b722016-03-03 15:27:00 +110027exit 0