[PATCH] D39114: [XRay] Initial XRay in Darwin Support

Dean Michael Berris via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 05:53:39 PST 2017


dberris added subscribers: pelikan, echristo.
dberris added a comment.

Got some good progress on finally being able to make this work... here's the current state:

- When linking the final binary, the XRay runtime can't seem to find the `__{start,stop}_xray_{fn_idx,instr_map}` symbols. I've marked them weak, but they seem to either not be resolved when statically linking the binary. The dynamic lib version of the XRay runtime isn't quite ready yet, but I'm willing to try some things there.

- There are also missing symbols from the sanitizer_common library that's linked to from the `libclang_rt.xray_osx.a` produced by the compiler-rt XRay build configuration.

For example, when we're building some of the tests, I see errors like:

  ********************
  FAIL: XRay-x86_64-darwin :: TestCases/func-id-utils.cc (18 of 18)
  ******************** TEST 'XRay-x86_64-darwin :: TestCases/func-id-utils.cc' FAILED ********************
  Script:
  --
  /Users/dberris/Source/llvm-project-build/./bin/clang --driver-mode=g++ -fxray-instrument -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.9 -isysroot /Applications/Xcode.
  app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk  -std=c++11 /Users/dberris/Source/llvm-project/compiler-rt/test/xray/TestCases/func-id-utils.
  cc -o /Users/dberris/Source/llvm-project-build/projects/compiler-rt/test/xray/X86_64DarwinConfig/TestCases/Output/func-id-utils.cc.tmp
  XRAY_OPTIONS="patch_premain=false xray_naive_log=false"  /Users/dberris/Source/llvm-project-build/projects/compiler-rt/test/xray/X86_64DarwinConfig/TestCases/Output/func-id-
  utils.cc.tmp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  Undefined symbols for architecture x86_64:
    "___sanitizer_symbolize_code", referenced from:
        __sanitizer::Symbolizer::PlatformInit() in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
        __sanitizer::InternalSymbolizer::SymbolizePC(unsigned long, __sanitizer::SymbolizedStack*) in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
    "___sanitizer_symbolize_data", referenced from:
        __sanitizer::Symbolizer::PlatformInit() in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
        __sanitizer::InternalSymbolizer::SymbolizeData(unsigned long, __sanitizer::DataInfo*) in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
    "___sanitizer_symbolize_demangle", referenced from:
        __sanitizer::InternalSymbolizer::Demangle(char const*) in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
    "___sanitizer_symbolize_flush", referenced from:
        __sanitizer::InternalSymbolizer::Flush() in libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
    "___start_xray_fn_idx", referenced from:
        ___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
    "___start_xray_instr_map", referenced from:
        ___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
    "___stop_xray_fn_idx", referenced from:
        ___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
    "___stop_xray_instr_map", referenced from:
        ___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
  ld: symbol(s) not found for architecture x86_64
  clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
  
  --

Any further hints/thoughts on this would be great, @kubamracek (cc @pelikan and @echristo)


https://reviews.llvm.org/D39114





More information about the cfe-commits mailing list