libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

macOS universal build of x86_64 and arm64

Open weswhet opened this issue 4 years ago • 3 comments

Issue description

Hey all, I'm looking for some help on making a universal build for macOS supporting both x86_64 and arm64.

When I try to specify both architecures at the same time the build completes but most libs are just x86_64 More below..

I can get each one to build just fine on their own systems but I can't get an arm64 to build on an x86_64 system or vice versa, I've tried specifying CFLAGS of "-arch arm64" as well as setting the --target and --host to the correct system. Let me know if you have any recommendations.

Ideally buliding universal in one go would be nice. I'm also happy to build both architecures seperately and then lipo them together.

Environment

  • libzmq version (commit hash if unreleased): 4.3.4 release tarball
  • OS: macOS 11.6 on an x86_64 machine. Xcode 12.5.1

Minimal test code / Steps to reproduce the issue

Attempt at making a universal arch. On an Intel Mac.

  1. env CFLAGS="-arch arm64 -arch x86_64" ./configure --prefix=/Users/wes/build/uni/
  2. make
  3. make install

What's the actual result? (include assertion message & call stack if applicable)

# arch check on the dylib comes back as just x86_64
lipo -archs /Users/wes/build/uni/lib/libzmq.dylib
x86_64

# curve_keygen is x86_64 only as well.
lipo -archs /Users/wes/build/uni/bin/curve_keygen
x86_64

# interestingly enough libzmq.a comes out as both x64_64 and arm64
lipo -archs /Users/wes/build/uni/lib/libzmq.a
x86_64 arm64

What's the expected result?

all build pieces should be x86_64 and arm64 compatible.

weswhet avatar Sep 17 '21 19:09 weswhet

Do you have any luck on this one? @weswhet

kakyoism avatar Mar 24 '22 12:03 kakyoism

@kakyoism I believe I had to use cmake to get this working. But haven't looked at this in a while. I'm waiting for a different upstream change in another repo and then I'll probably have another look at this.

weswhet avatar Mar 25 '22 18:03 weswhet

@kakyoism I believe I had to use cmake to get this working. But haven't looked at this in a while. I'm waiting for a different upstream change in another repo and then I'll probably have another look at this.

Thanks. Will try cmake. My current workaround with Autotools is to build the x86_64 using a Rosetta-enabled Terminal copy, and arm64 with the default Terminal. Finally, I build them into a universal ...

kakyoism avatar Mar 25 '22 23:03 kakyoism