Build fails with address sanitizer feature enabled and custom CC

Number:rdar://24972653 Date Originated:04-Mar-2016 10:17 AM
Status:Open Resolved:
Product:iOS Product Version:Version 7.2.1
Classification:Other Bug Reproducible:Always
This is a duplicate of rdar://21374780 - Example is attached in the original radar.

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/ /tmp/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
    cd /tmp/SanitizerAndCC
    export PATH="/Applications/"
    /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/

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


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!