[LLVMbugs] [Bug 17879] New: using libc++ with -finstrument-functions produces a linker error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 11 09:23:22 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=17879

            Bug ID: 17879
           Summary: using libc++ with -finstrument-functions produces a
                    linker error
           Product: libc++
           Version: 3.2
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: gonzalobg88 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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>
>::operator<<(int) in traces-3d984c.o
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"?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131111/4cd1e283/attachment.html>


More information about the llvm-bugs mailing list