[llvm-dev] [XRay] Error: X86_64_RELOC_SUBTRACTOR must have r_extern=1

Rakur Moski via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 20 21:46:31 PST 2020


Hi,

I'm trying to use LLVM Xray on MacOs, with LLVM 11 (Also tried on LLVM 12 mainline) build.

I face the following error on all of attempts:

```
ld: in section __DATA,xray_instr_map reloc 0: X86_64_RELOC_SUBTRACTOR must have r_extern=1 file 'CMakeFiles/seq_vector.dir/seq_vector.cpp.o' for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
```
This did not change, whether I use "/usr/bin/ld" or "../_install/llvm_11/bin/ld64.lld".

The verbose command and output of the procedure is as following:

```
../_install/llvm_11/bin/clang++ -fxray-instrument -fxray-instruction-threshold=1 ./seq_vector.cpp -o seq_vector -v
clang version 11.0.1 (git at github.com:mycppfeed/llvm-mirror.git 1cd7c2551b6604020aef86f6a0c6ad0ca8d87641)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin
"/Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/bin/clang-11" -cc1 -triple x86_64-apple-macosx10.15.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name seq_vector.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-rounding-math -munwind-tables -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -debugger-tuning=lldb -target-linker-version 609 -v -resource-dir /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -stdlib=libc++ -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir /Users/user/workspace/github/clang_build/manual/llvm-11/example -ferror-limit 19 -fxray-instrument -fxray-instruction-threshold=1 -fxray-modes=xray-basic -fxray-modes=xray-fdr -fxray-instrumentation-bundle=all -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics -o /var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o -x c++ ./seq_vector.cpp
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-apple-darwin19.6.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin/../include/c++/v1
/Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.

"/usr/bin/ld" -demangle -lto_library /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.15.0 0.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o seq_vector /var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o -lc++ /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray_osx.a /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray-basic_osx.a /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray-fdr_osx.a -lSystem /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.osx.a
ld: in section __DATA,xray_instr_map reloc 0: X86_64_RELOC_SUBTRACTOR must have r_extern=1 file '/var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o' for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
```

```
"/usr/bin/ld" -demangle -lto_library /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.15.0 0.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o seq_vector /var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o -lc++ /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray_osx.a /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray-basic_osx.a /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.xray-fdr_osx.a -lSystem /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/lib/darwin/libclang_rt.osx.a -v
@(#)PROGRAM:ld PROJECT:ld64-609
BUILD 07:59:13 Aug 25 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/
ld: file not found: /var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o
```

Further, I found that XRay instrumentation is disabled in LLVM Test suit in commit : https://github.com/llvm/llvm-test-suite/commit/2c3c4a6286d453f763c0245c6536ddd368f0db99

So, Is there any workaround I can use to run clang with X-ray instrumentation?

Thanks!
Rakur.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201121/165432c3/attachment.html>


More information about the llvm-dev mailing list