mirror of
https://github.com/torvalds/linux.git
synced 2024-11-29 23:51:37 +00:00
d42f55e8ae
Toolchains don't always default to the ELFv2 ABI. This is true with at least the kernel.org toolchains. As such, pass -mabi=elfv2 explicitly to ensure that we are testing against the correct compiler output. Signed-off-by: Naveen N Rao <naveen@kernel.org> [mpe: Tweak comment wording] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230530093821.298590-1-naveen@kernel.org
28 lines
880 B
Bash
Executable File
28 lines
880 B
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
set -e
|
|
set -o pipefail
|
|
|
|
# To debug, uncomment the following line
|
|
# set -x
|
|
|
|
# -mprofile-kernel is only supported on 64-bit with ELFv2, so this should not
|
|
# be invoked for other targets. Therefore we can pass in -m64 and -mabi
|
|
# explicitly, to take care of toolchains defaulting to other targets.
|
|
|
|
# Test whether the compile option -mprofile-kernel exists and generates
|
|
# profiling code (ie. a call to _mcount()).
|
|
echo "int func() { return 0; }" | \
|
|
$* -m64 -mabi=elfv2 -S -x c -O2 -p -mprofile-kernel - -o - \
|
|
2> /dev/null | grep -q "_mcount"
|
|
|
|
# Test whether the notrace attribute correctly suppresses calls to _mcount().
|
|
|
|
echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
|
|
$* -m64 -mabi=elfv2 -S -x c -O2 -p -mprofile-kernel - -o - \
|
|
2> /dev/null | grep -q "_mcount" && \
|
|
exit 1
|
|
|
|
exit 0
|