Static library build fails on macOS

username: MeijisIrlnd
cooked: <p>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.</p>
<p>I’m trying to compile using rosetta, seeing as I don’t have an intel Mac, so I’m configuring with:</p>
<p><code>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 ..</code></p>
<p>which seems to succeed, but when I go to actually compile it, with<br>
<code>cmake --build . --target install</code></p>
<p>it throws a bunch of errors seemingly related to <strong>asmjit</strong>, around 70% into the build</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/5/e599d53d4d2458a7979f0da08ef3c7414b693b43.png" data-download-href="https://discuss.pytorch.org/uploads/default/e599d53d4d2458a7979f0da08ef3c7414b693b43" title="Screenshot 2022-08-19 at 15.14.57"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/5/e599d53d4d2458a7979f0da08ef3c7414b693b43_2_690x237.png" alt="Screenshot 2022-08-19 at 15.14.57" data-base62-sha1="wL8VqRFrXkcGtt7MxLwiYqmnyq7" width="690" height="237" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/5/e599d53d4d2458a7979f0da08ef3c7414b693b43_2_690x237.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/5/e599d53d4d2458a7979f0da08ef3c7414b693b43_2_1035x355.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/5/e599d53d4d2458a7979f0da08ef3c7414b693b43.png 2x" data-dominant-color="2C2D2C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2022-08-19 at 15.14.57</span><span class="informations">1126×388 68.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>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)</p>

username: MeijisIrlnd
cooked: <p>Okay a <code>git submodule update --recursive</code> fixed that, buuuut, at the very end I now get linker errors relating to what appears to be metal, despite the config saying <code>USE_METAL=OFF</code>, the same thing happened on an actual intel machine</p>
<blockquote>
<p>Undefined symbols for architecture x86_64:<br>
“_MTLCopyAllDevices”, referenced from:<br>
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)<br>
“_NSClassFromString”, referenced from:<br>
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)<br>
“<em>OBJC_CLASS</em>$_MPSCommandBuffer”, referenced from:<br>
objc-class-ref in libtorch_cpu.a(MPSStream.mm.o)<br>
“<em>OBJC_CLASS</em>$_MPSGraph”, referenced from:<br>
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphConvolution2DOpDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(Convolution.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphExecutionDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(MPSStream.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphLSTMDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(RnnOps.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphPooling2DOpDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(Pooling.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphRandomOpDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(Distributions.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSGraphTensorData", referenced from:<br>
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)<br>
objc-class-ref in libtorch_cpu.a(Copy.mm.o)<br>
objc-class-ref in libtorch_cpu.a(View.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSNDArray", referenced from:<br>
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MPSNDArrayDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MTLCompileOptions", referenced from:<br>
objc-class-ref in libtorch_cpu.a(MPSDevice.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MTLFunctionConstantValues", referenced from:<br>
objc-class-ref in libtorch_cpu.a(Indexing.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>MTLHeapDescriptor", referenced from:<br>
objc-class-ref in libtorch_cpu.a(MPSAllocator.mm.o)<br>
"<em>OBJC_CLASS</em>$<em>NSArray", referenced from:<br>
objc-class-ref in libtorch_cpu.a(OperationUtils.mm.o)<br>
objc-class-ref in libtorch_cpu.a(Convolution.mm.o)<br>
objc-class-ref in libtorch_cpu.a(Normalization.mm.o)<br>
objc-class-ref in libtorch_cpu.a(ScatterGather.mm.o)<br>
objc-class-ref in libtorch_cpu.a(Shape.mm.o)<br>
objc-class-ref in libtorch_cpu.a(SoftMax.mm.o)<br>
objc-class-ref in libtorch_cpu.a(View.mm.o)<br>
…<br>
"<em>OBJC_CLASS</em>$<em>NSConstantArray", referenced from:<br>
l__unnamed_nsarray</em> in libtorch_cpu.a(OperationUtils.mm.o)<br>
l__unnamed_nsarray</em>.66 in libtorch_cpu.a(OperationUtils.mm.o)<br>
l__unnamed_nsarray</em> in libtorch_cpu.a(Activation.mm.o)<br>
l__unnamed_nsarray</em>.19 in libtorch_cpu.a(Activation.mm.o)<br>
l__unnamed_nsarray</em>.21 in libtorch_cpu.a(Activation.mm.o)<br>
l__unnamed_nsarray</em>.45 in libtorch_cpu.a(Activation.mm.o)<br>
l__unnamed_nsarray</em>.48 in libtorch_cpu.a(Activation.mm.o)<br>
…<br>
"<em>OBJC_CLASS</em>$<em>NSConstantIntegerNumber", referenced from:<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(OperationUtils.mm.o)<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(Activation.mm.o)<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(BinaryOps.mm.o)<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(Indexing.mm.o)<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(LossOps.mm.o)<br>
l__unnamed_nsconstantintegernumber</em> in libtorch_cpu.a(Normalization.mm.o)<br>
l__unnamed_nsconstantintegernumber</em>.3 in libtorch_cpu.a(Normalization.mm.o)<br>
…</p>
</blockquote>