spotify / XCRemoteCache

Other
835 stars 52 forks source link

XCLD Not Used When Project Contains C++ Code? #112

Closed jarbogast-salesforce closed 2 years ago

jarbogast-salesforce commented 2 years ago

I have a small project that uses some C++. When I try to consume artifacts with XCRemoteCache I get linker errors like

ld: file too small (length=0) file '/Users/jarbogast/Library/Developer/Xcode/DerivedData/Kalesforce-czluqcwegwrauabcgxjmhwbspjqn/Build/Intermediates.noindex/Kalesforce.build/Debug-iphonesimulator/Kalesforce.build/Objects-normal/x86_64/CppLogger.o'

And when I look at the command invoking the linker I expected to see xcld but instead I see

Ld /Users/jarbogast/Library/Developer/Xcode/DerivedData/Kalesforce-czluqcwegwrauabcgxjmhwbspjqn/Build/Products/Debug-iphonesimulator/Kalesforce.app/Kalesforce normal (in target 'Kalesforce' from project 'Kalesforce') cd /Users/jarbogast/Documents/Kalesforce-iOS /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++

Did I miss a configuration option to help with C++? Or is this a feature gap for XCRemoteCache? Hope it's the former, but I may be able to make a contribution if it's the latter!

polac24 commented 2 years ago

Hi! this is indeed a missing feature, bit should be simple to patch.

The dummies verification is to add a build setting LDPLUSPLUS = $(LD) (to the section steps here). It may work for the local cache-hit scenario but if a target is not taken from cache, local linking would use clang instead of clang++.

So we need a new binary that calls the appropriate underlying process (clang vs clang++) here. The simplest approach is to introduce xcldplusplus, almost identical to xcld and in the project integration add LDPLUSPLUS build setting. Feel free to make a contribution.