<div>Hi,<br></div><div><br></div><div>I'm trying to use LLVM Xray on MacOs, with LLVM 11 (Also tried on LLVM 12 mainline) build.<br></div><div><br></div><div>I face the following error on all of attempts:<br></div><div><br></div><div>```</div><div>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<br></div><div>clang-11: error: linker command failed with exit code 1 (use -v to see invocation)<br></div><div>```<br></div><div>This did not change, whether I use "/usr/bin/ld" or "../_install/llvm_11/bin/ld64.lld".<br></div><div><br></div><div>The verbose command and output of the procedure is as following:<br></div><div><br></div><div>```<br></div><div>../_install/llvm_11/bin/clang++ -fxray-instrument -fxray-instruction-threshold=1 ./seq_vector.cpp -o seq_vector -v<br></div><div>clang version 11.0.1 (<a href="mailto:git@github.com">git@github.com</a>:mycppfeed/llvm-mirror.git 1cd7c2551b6604020aef86f6a0c6ad0ca8d87641)<br></div><div>Target: x86_64-apple-darwin19.6.0<br></div><div>Thread model: posix<br></div><div>InstalledDir: /Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin<br></div><div>"/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/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</a> -stdlib=libc++ -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin/../include/c++/v1 -internal-isystem /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1</a> -internal-isystem /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include</a> -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/include -internal-externc-isystem /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include</a> -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<br></div><div>clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-apple-darwin19.6.0<br></div><div>ignoring nonexistent directory "/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1</a>"<br></div><div>ignoring nonexistent directory "/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include</a>"<br></div><div>ignoring nonexistent directory "/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks</a>"<br></div><div>#include "..." search starts here:<br></div><div>#include <...> search starts here:<br></div><div>/Users/user/workspace/github/clang_build/manual/llvm-11/example/../_install/llvm_11/bin/../include/c++/v1<br></div><div>/Users/user/workspace/github/clang_build/manual/llvm-11/_install/llvm_11/lib/clang/11.0.1/include<br></div><div>/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include</a><br></div><div>/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks</a> (framework directory)<br></div><div>End of search list.<br></div><div><br></div><div><br></div><div>"/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/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</a> -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<br></div><div>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<br></div><div>clang-11: error: linker command failed with exit code 1 (use -v to see invocation)<br></div><div>```<br></div><div><br></div><div><br></div><div><br></div><div>```<br></div><div>"/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/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</a> -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<br></div><div>@(#)PROGRAM:ld  PROJECT:ld64-609<br></div><div>BUILD 07:59:13 Aug 25 2020<br></div><div>configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em<br></div><div>Library search paths:<br></div><div>/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib</a><br></div><div>Framework search paths:<br></div><div>/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/</a><br></div><div>ld: file not found: /var/folders/7y/nr8fcfv946vgt_z4ql6vhpz00000gn/T/seq_vector-017d1f.o<br></div><div>```</div><div><br></div><div>Further, I found that XRay instrumentation is disabled in LLVM Test suit in commit : <a href="https://github.com/llvm/llvm-test-suite/commit/2c3c4a6286d453f763c0245c6536ddd368f0db99">https://github.com/llvm/llvm-test-suite/commit/2c3c4a6286d453f763c0245c6536ddd368f0db99</a><br></div><div><br></div><div>So, Is there any workaround I can use to run clang with X-ray instrumentation?<br></div><div><br></div><div>Thanks!</div><div>Rakur.</div>