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 10*aec0ba74SNicholas Piggin# -mprofile-kernel is only supported on 64-bit, so this should not be invoked 11*aec0ba74SNicholas Piggin# for 32-bit. We pass in -m64 explicitly, and -mbig-endian and -mlittle-endian 12*aec0ba74SNicholas Piggin# are passed in from Kconfig, which takes care of toolchains defaulting to 13*aec0ba74SNicholas Piggin# other targets. 141421dc6dSNicholas Piggin 15b71c9ffbSNicholas Piggin# Test whether the compile option -mprofile-kernel exists and generates 16b71c9ffbSNicholas Piggin# profiling code (ie. a call to _mcount()). 17b71c9ffbSNicholas Pigginecho "int func() { return 0; }" | \ 18*aec0ba74SNicholas Piggin $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - \ 191421dc6dSNicholas Piggin 2> /dev/null | grep -q "_mcount" 20b71c9ffbSNicholas Piggin 21b71c9ffbSNicholas Piggin# Test whether the notrace attribute correctly suppresses calls to _mcount(). 22b71c9ffbSNicholas Piggin 23b71c9ffbSNicholas Pigginecho -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \ 24*aec0ba74SNicholas Piggin $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - \ 251421dc6dSNicholas Piggin 2> /dev/null | grep -q "_mcount" && \ 26b71c9ffbSNicholas Piggin exit 1 27b71c9ffbSNicholas Piggin 28b71c9ffbSNicholas Pigginexit 0 29