ditto fails with UB sanitiser when CC is overridden

Originator:macmade
Number:rdar://32743163 Date Originated:June 13 2017, 8:05 PM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Crash Reproducible:Always
 
Summary:
In order to use ccache with Xcode, a project needs to define the `CC` user-defined setting, so ccache can be used instead of the regular compiler.

When the new undefined behaviour sanitiser is enabled, the build will fail with an error from ditto.
Attached is a project that reproduced the issue.

Actual error is:

    Ditto /Users/macmade/Library/Developer/Xcode/DerivedData/Test-dilnecswjeixotbbtidvnpthgoti/Build/Products/Debug/Test.app/Contents/Frameworks/libclang_rt.ubsan_osx_dynamic.dylib lib/clang/9.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib
        cd /Users/macmade/Desktop/Test
        /usr/bin/ditto -rsrc /Users/macmade/Desktop/Test/lib/clang/9.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib /Users/macmade/Library/Developer/Xcode/DerivedData/Test-dilnecswjeixotbbtidvnpthgoti/Build/Products/Debug/Test.app/Contents/Frameworks/libclang_rt.ubsan_osx_dynamic.dylib
    
    ditto: can't get real path for source '/Users/macmade/Desktop/Test/lib/clang/9.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib'
    Command /usr/bin/ditto failed with exit code 1

----------

Steps to Reproduce:
Override the `CC` user-defined setting in Xcode build settings, and enable the UB sanitiser in the current scheme.

----------

Expected Results:
Target should build fine. It does without the UB sanitiser.

----------

Observed Results:
Target fails with ditto error.

----------

Version:
Xcode Version 9.0 beta (9M136h)
macOS Version 10.13 beta (17A264c)

Comments


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!