<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - using libc++ with -finstrument-functions produces a linker error"
   href="http://llvm.org/bugs/show_bug.cgi?id=17879">17879</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>using libc++ with -finstrument-functions produces a linker error
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gonzalobg88@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm trying to compile a basic "clang -finstrument-functions" example using ToT
clang and libc++.

#include <iostream>
int depth = -1;

extern "C" {
  void __cyg_profile_func_enter (void *, void *)
      __attribute__((no_instrument_function));
  void __cyg_profile_func_enter (void *, void *) { depth++; }
  void __cyg_profile_func_exit (void *, void *)
      __attribute__((no_instrument_function));
  void __cyg_profile_func_exit (void *, void *) { depth--; }
}

struct Foo { void bar() { std::cout << "bar: " << depth << std::endl; } };

int main() {
  Foo f;
  f.bar();
  return 0;
}

Removing iostream and std::cout/std::endl compiles as expected, but with the
code above i get the following linker error (verbose output):

clang version 3.4 
Target: x86_64-apple-darwin12.5.0
Thread model: posix
 "/usr/local/Cellar/llvm34/HEAD/lib/llvm-3.4/bin/clang" -cc1 -triple
x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name traces.cpp -mrelocation-model pic
-pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 224.1 -v -finstrument-functions -nostdinc++
-resource-dir /usr/local/Cellar/llvm34/HEAD/lib/llvm-3.4/bin/../lib/clang/3.4
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/
-I /Users/gnzlbg/src/libcxx/libcxx/include -c-isystem /usr/local/include
-c-isystem /Users/gnzlbg/pool/mpllibs -c-isystem /Users/gnzlbg/src/thrust
-cxx-isystem /usr/local/include -cxx-isystem /Users/gnzlbg/pool/mpllibs
-cxx-isystem /Users/gnzlbg/src/thrust -stdlib=libc++ -std=c++1y
-fdeprecated-macro -fdebug-compilation-dir
/Users/gnzlbg/projects/sideprojects/cpp11 -ferror-limit 19 -fmessage-length 199
-stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0
-fencode-extended-block-signature -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o
/var/folders/mm/y444qqwd0kn52fycyz6nsph40000gn/T/traces-3d984c.o -x c++
traces.cpp
clang -cc1 version 3.4 based upon LLVM 3.4svn default target
x86_64-apple-darwin12.5.0
ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk//usr/local/include"
ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk//Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/gnzlbg/src/libcxx/libcxx/include
 /usr/local/include
 /Users/gnzlbg/pool/mpllibs
 /Users/gnzlbg/src/thrust
 /usr/local/Cellar/llvm34/HEAD/lib/llvm-3.4/bin/../lib/clang/3.4/include

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk//usr/include

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk//System/Library/Frameworks
(framework directory)
End of search list.
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0
-syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/
-o a.out -L/usr/local/lib/llvm-3.4/usr/lib
/var/folders/mm/y444qqwd0kn52fycyz6nsph40000gn/T/traces-3d984c.o -lc++ -lSystem
/usr/local/Cellar/llvm34/HEAD/lib/llvm-3.4/bin/../lib/clang/3.4/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "std::__1::num_put<char, std::__1::ostreambuf_iterator<char,
std::__1::char_traits<char> > >::put(std::__1::ostreambuf_iterator<char,
std::__1::char_traits<char> >, std::__1::ios_base&, char, long) const",
referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char>
<span class="quote">>::operator<<(int) in traces-3d984c.o</span >
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do I need to do something specific to use libc++ with "-finstrument-functions"?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>