4

I'm trying to use __cyg_profile_func_* with -finstrument-functions to do specific checks before and after functions run (eg, to check for Mach port leaks and such). This is on OS X.

The code is written and functional, but I have a ton of undefined references to, for example,

std::__1::basic_ios<wchar_t, std::__1::char_traits<wchar_t> >::init(std::__1::basic_streambuf<wchar_t, std::__1::char_traits<wchar_t> >*)

It seems like perhaps some sort of inlining is taking place, but the instrumentation is still trying to reference a non-inlined version of the function. Is it possible to exempt the standard C++ library from instrumentation? Or, possible to completely disable inlining in clang for this particular circumstance?

Cheers!

Matthew Iselin
  • 10,400
  • 4
  • 51
  • 62
  • I'm having the exactly same problem. It seems like enabling -finstrument-functions makes clang unable to link against libc++ :/ – gnzlbg Nov 11 '13 at 16:40

2 Answers2

0

In gcc,-finstrument-functions-exclude-file-list=stdlib/include would do what you want. However, it is not implemented in clang yet (at least trunk doesn't recognize this option).

gnzlbg
  • 7,135
  • 5
  • 53
  • 106
0

Clang has an option -finstrument-functions-after-inlining which will work in this case. yes it is unfortunate clang does not support disabling instrumentation on a file/directory basis. If instrumentation is too much trouble then changing the source code of standard C++ library to add attributes may help as well. See: https://stackoverflow.com/a/69474100/811335

A. K.
  • 34,395
  • 15
  • 52
  • 89