xref: /OK3568_Linux_fs/kernel/arch/powerpc/tools/gcc-check-mprofile-kernel.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/bash
2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
3*4882a593Smuzhiyun
4*4882a593Smuzhiyunset -e
5*4882a593Smuzhiyunset -o pipefail
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun# To debug, uncomment the following line
8*4882a593Smuzhiyun# set -x
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun# -mprofile-kernel is only supported on 64le, so this should not be invoked
11*4882a593Smuzhiyun# for other targets. Therefore we can pass in -m64 and -mlittle-endian
12*4882a593Smuzhiyun# explicitly, to take care of toolchains defaulting to other targets.
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun# Test whether the compile option -mprofile-kernel exists and generates
15*4882a593Smuzhiyun# profiling code (ie. a call to _mcount()).
16*4882a593Smuzhiyunecho "int func() { return 0; }" | \
17*4882a593Smuzhiyun    $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
18*4882a593Smuzhiyun    2> /dev/null | grep -q "_mcount"
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun# Test whether the notrace attribute correctly suppresses calls to _mcount().
21*4882a593Smuzhiyun
22*4882a593Smuzhiyunecho -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
23*4882a593Smuzhiyun    $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
24*4882a593Smuzhiyun    2> /dev/null | grep -q "_mcount" && \
25*4882a593Smuzhiyun    exit 1
26*4882a593Smuzhiyun
27*4882a593Smuzhiyunexit 0
28