MacOS latest command-line tools (CLT) crashes build for metal

Latest CLT 13.2 or 13.3 or with latest XCode app seems to break TVM build with USE_METAL=ON. CLT 13 does work but there will be warnings with other libs in MacOS 12.3.

Update Solution for CLT 13.2/13.3, latest xcode, MacOS 12.3: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91 change at the beginning (NSAttributedString *) to (NSString *)

seems an Apple bug to me ;-(

Hi @mikeseven

Didn’t fully cache your issue report. Did you mean that compiler from latest CLT crashes or reports a compilation error? In case of compilation error could you please provide example of error message? Please provide more info how to reproduce crash.

Meanwhile I’ve just locally check build with latestCLT and it was success. I was using CLT 13.3, macOS 12.0.1, SDK MacOSX12.3.sdk, TVM commit_id 47ab54538fb83.

More over in TVM CI we check MacOS build and it’s OK. Currently it uses Xcode 13.2.1 which is equivalent of CLT 13.2.

Sorry for the delay. I thought I might have my system messed up somehow. However, after installing the latest xcode update this week and recompiling TVM master today, the same issue appears again.

I’m on MacOS 12.3.1, Xcode CLT version: 13.3.1.0.1.1648687083.

The solution is again to edit NSBundle.h line 91. The culprit is NSAttributedString instead of NSString. It might be an Apple bug because on CLT 13, it’s correct. It would seem the issue appeared with CLT 13.2

// - (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
- (NSString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));

Here is the build error:

> [29/558] Building CXX object CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_device_api.mm.o
> FAILED: CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_device_api.mm.o
> /usr/local/Caskroom/miniconda/base/envs/sima2-3.9/bin/x86_64-apple-darwin13.4.0-clang++ -DDMLC_USE_FOPEN64=0 -DDMLC_USE_LOGGING_LIBRARY="<tvm/runtime/logging.h>" -DNDEBUG -DNDEBUG=1 -DTVM_INDEX_DEFAULT_I64=1 -DTVM_LLVM_VERSION=120 -DTVM_THREADPOOL_USE_OPENMP=1 -DTVM_USE_LIBBACKTRACE=0 -DUSE_DNNL=1 -DUSE_FALLBACK_STL_MAP=0 -DUSE_JSON_RUNTIME=1 -DUSE_MICRO_STANDALONE_RUNTIME=1 -DUSE_MKL_BLAS=1 -DUSE_PROFILER=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/mikael/code/tvm/include -I/Users/mikael/code/tvm/3rdparty/libcrc/include -isystem /Users/mikael/code/tvm/3rdparty/dlpack/include -isystem /Users/mikael/code/tvm/3rdparty/dmlc-core/include -isystem /Users/mikael/code/tvm/3rdparty/rang/include -isystem /Users/mikael/code/tvm/3rdparty/compiler-rt -isystem /Users/mikael/code/tvm/3rdparty/picojson -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers -std=c++14 -O2 -Wall -fPIC -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /usr/local/Caskroom/miniconda/base/envs/sima2-3.9/include -fopenmp=libomp -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Wno-c++98-compat -Wno-c++98-compat-extra-semi -Wno-c++98-compat-pedantic -Wno-padded -Wno-extra-semi -Wno-extra-semi-stmt -Wno-unused-parameter -Wno-sign-conversion -Wno-weak-vtables -Wno-deprecated-copy-dtor -Wno-global-constructors -Wno-double-promotion -Wno-float-equal -Wno-missing-prototypes -Wno-implicit-int-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-conversion -Wno-float-conversion -Wno-shorten-64-to-32 -Wno-covered-switch-default -Wno-unused-exception-parameter -Wno-return-std-move -Wno-over-aligned -Wno-undef -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-deprecated-copy -Wno-implicit-fallthrough -Wno-unreachable-code-return -Wno-non-virtual-dtor -Wreserved-id-macro -Wused-but-marked-unused -Wdocumentation-unknown-command -Wcast-qual -Wzero-as-null-pointer-constant -Wno-documentation -Wno-shadow-uncaptured-local -Wno-shadow-field-in-constructor -Wno-shadow -Wno-shadow-field -Wno-exit-time-destructors -Wno-switch-enum -Wno-old-style-cast -Wno-gnu-anonymous-struct -Wno-nested-anon-types -MD -MT CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_device_api.mm.o -MF CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_device_api.mm.o.d -o CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_device_api.mm.o -c /Users/mikael/code/tvm/src/runtime/metal/metal_device_api.mm
> In file included from /Users/mikael/code/tvm/src/runtime/metal/metal_device_api.mm:25:
> In file included from /Users/mikael/code/tvm/src/runtime/metal/metal_common.h:27:
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLBlitCommandEncoder.h:8:
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
> - (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
>                                                          ~~~~~~~~~~~~~~                                                                       ^                  ~
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
>         #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
>                                                       ^          ~
> 1 error generated.
> [33/558] Building CXX object CMakeFiles/tvm_runtime_objs.dir/src/runtime/metal/metal_module.mm.o