Build fails with address sanitizer feature enabled and custom CC

Originator:eyal.keren81
Number:rdar://21374780 Date Originated:14-Jun-2015 12:18 PM
Status:Open Resolved:
Product:xcode (Developer Tools) Product Version:Version 7.0 beta (7A120f)
Classification: Reproducible:Always
 
Summary:
When using Xcode 7 new address sanitizer feature, xcode runs ditto command with the wrong path for  libclang_rt.asan_iossim_dynamic.dylib file.

The path the xcode provides ditto command is relative to the CC environment variable, which is wrong because the file is located under the Toolchain and not relative to the custom CC command which can be anywhere.

Steps to Reproduce:
1. Create a project with Xcode 7
2. Create a link to clang (e.g. /tmp/cusom_clang) 
3. Set the CC user defined variable to point to the custom clang path (CC=/tmp/cusom_clang)
4. Enable address sanitizer in the schema
5. Build the project

Expected Results:
Build successful 

Actual Results:
Build fail with the following error: 

            Ditto /Users/sergey/Library/Developer/Xcode/DerivedData/SanitizerAndCC-cpkpilypgjjrbveuebtzugjkcszm/Build/Products/Debug-iphonesimulator/SanitizerAndCC.app/Frameworks/libclang_rt.asan_iossim_dynamic.dylib /tmp/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
    cd /tmp/SanitizerAndCC
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /usr/bin/ditto -rsrc /tmp/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib /Users/sergey/Library/Developer/Xcode/DerivedData/SanitizerAndCC-cpkpilypgjjrbveuebtzugjkcszm/Build/Products/Debug-iphonesimulator/SanitizerAndCC.app/Frameworks/libclang_rt.asan_iossim_dynamic.dylib

ditto: can't get real path for source '/tmp/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib'
Command /usr/bin/ditto failed with exit code 1

Version:
Version 7.0 beta (7A120f)

Notes:
Attached xcode project that reproduce the issue

Configuration:


Attachments:
'SanitizerAndCC.zip' was successfully uploaded.

Comments

Workaround

A poor man's workaround for this issue would be to create a symbolic link (inside cusom_clang directory - /tep in the above case).

ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib lib


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!