1b71c9ffbSNicholas Piggin#!/bin/bash
2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
3b71c9ffbSNicholas Piggin
4b71c9ffbSNicholas Pigginset -e
5b71c9ffbSNicholas Pigginset -o pipefail
6b71c9ffbSNicholas Piggin
7b71c9ffbSNicholas Piggin# To debug, uncomment the following line
8b71c9ffbSNicholas Piggin# set -x
9b71c9ffbSNicholas Piggin
10b71c9ffbSNicholas Piggin# Test whether the compile option -mprofile-kernel exists and generates
11b71c9ffbSNicholas Piggin# profiling code (ie. a call to _mcount()).
12b71c9ffbSNicholas Pigginecho "int func() { return 0; }" | \
13b71c9ffbSNicholas Piggin    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
14b71c9ffbSNicholas Piggin    grep -q "_mcount"
15b71c9ffbSNicholas Piggin
16b71c9ffbSNicholas Piggin# Test whether the notrace attribute correctly suppresses calls to _mcount().
17b71c9ffbSNicholas Piggin
18b71c9ffbSNicholas Pigginecho -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
19b71c9ffbSNicholas Piggin    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
20b71c9ffbSNicholas Piggin    grep -q "_mcount" && \
21b71c9ffbSNicholas Piggin    exit 1
22b71c9ffbSNicholas Piggin
23b71c9ffbSNicholas Pigginecho "OK"
24b71c9ffbSNicholas Pigginexit 0
25