gcc-check-mprofile-kernel.sh 885 B

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