Static library build fails on macOS

Hi all, I managed to compile libtorch as a static lib for m1 recently, but need to get it running on x86_64 as well, which has proven to be… challenging.

I’m trying to compile using rosetta, seeing as I don’t have an intel Mac, so I’m configuring with:

cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DPYTHON_EXECUTABLE:PATH=/Users/sylmorrison/miniforge3/bin/python3 -DCMAKE_INSTALL_PREFIX:PATH=../intel_install ..

which seems to succeed, but when I go to actually compile it, with
cmake --build . --target install

it throws a bunch of errors seemingly related to asmjit, around 70% into the build

Any help here would be super appreciated, not really sure what to do about it! (also let me know if this is better posted as a github issue as opposed to here)

Okay a git submodule update --recursive fixed that, buuuut, at the very end I now get linker errors relating to what appears to be metal, despite the config saying USE_METAL=OFF, the same thing happened on an actual intel machine

Undefined symbols for architecture x86_64:
“_MTLCopyAllDevices”, referenced from:
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)
“_NSClassFromString”, referenced from:
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)
OBJC_CLASS$_MPSCommandBuffer”, referenced from:
objc-class-ref in libtorch_cpu.a(MPSStream.mm.o)
OBJC_CLASS$_MPSGraph”, referenced from:
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)
"OBJC_CLASS$MPSGraphConvolution2DOpDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(Convolution.mm.o)
"OBJC_CLASS$MPSGraphExecutionDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(MPSStream.mm.o)
"OBJC_CLASS$MPSGraphLSTMDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(RnnOps.mm.o)
"OBJC_CLASS$MPSGraphPooling2DOpDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(Pooling.mm.o)
"OBJC_CLASS$MPSGraphRandomOpDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(Distributions.mm.o)
"OBJC_CLASS$MPSGraphTensorData", referenced from:
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)
objc-class-ref in libtorch_cpu.a(Copy.mm.o)
objc-class-ref in libtorch_cpu.a(View.mm.o)
"OBJC_CLASS$MPSNDArray", referenced from:
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)
"OBJC_CLASS$MPSNDArrayDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)
"OBJC_CLASS$MTLCompileOptions", referenced from:
objc-class-ref in libtorch_cpu.a(MPSDevice.mm.o)
"OBJC_CLASS$MTLFunctionConstantValues", referenced from:
objc-class-ref in libtorch_cpu.a(Indexing.mm.o)
"OBJC_CLASS$MTLHeapDescriptor", referenced from:
objc-class-ref in libtorch_cpu.a(MPSAllocator.mm.o)
"OBJC_CLASS$NSArray", referenced from:
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)
objc-class-ref in libtorch_cpu.a(Convolution.mm.o)
objc-class-ref in libtorch_cpu.a(Normalization.mm.o)
objc-class-ref in libtorch_cpu.a(ScatterGather.mm.o)
objc-class-ref in libtorch_cpu.a(Shape.mm.o)
objc-class-ref in libtorch_cpu.a(SoftMax.mm.o)
objc-class-ref in libtorch_cpu.a(View.mm.o)

"OBJC_CLASS$NSConstantArray", referenced from:
l__unnamed_nsarray
in libtorch_cpu.a(OperationUtils.mm.o)
l__unnamed_nsarray
.66 in libtorch_cpu.a(OperationUtils.mm.o)
l__unnamed_nsarray
in libtorch_cpu.a(Activation.mm.o)
l__unnamed_nsarray
.19 in libtorch_cpu.a(Activation.mm.o)
l__unnamed_nsarray
.21 in libtorch_cpu.a(Activation.mm.o)
l__unnamed_nsarray
.45 in libtorch_cpu.a(Activation.mm.o)
l__unnamed_nsarray
.48 in libtorch_cpu.a(Activation.mm.o)

"OBJC_CLASS$NSConstantIntegerNumber", referenced from:
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(OperationUtils.mm.o)
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(Activation.mm.o)
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(BinaryOps.mm.o)
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(Indexing.mm.o)
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(LossOps.mm.o)
l__unnamed_nsconstantintegernumber
in libtorch_cpu.a(Normalization.mm.o)
l__unnamed_nsconstantintegernumber
.3 in libtorch_cpu.a(Normalization.mm.o)