Martijn van Beurden
2022-Sep-17 15:45 UTC
[flac-dev] Enabling universal building of libFLAC
Hi all, As is being discussed here: https://github.com/xiph/flac/issues/453 libFLAC has some issues building on MacOS. More specifically, building for aarch64 and x86_64 at the same time. The problem here is that autotools and CMake expect to configure for one architecture at a time. Also, code is dependent on that configuration, and not on runtime variables. It seems a challenge to me: we need both configuration and building to be aware of stuff being built in parallel for two architectures. Also, it is important not to break anything on other architectures, so we might need both approaches: relying on either run-time arch for MacOS and on static configuration for other systems. I do not have Apple hardware nor any experience with this. I can't seem to find much documentation on porting autotools or CMake scripts for Apple's universal builds. If there is anyone here up for this challenge, do not hesitate to let me know :) Kind regards, Martijn van Beurden -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/flac-dev/attachments/20220917/a2348183/attachment.htm>
Hi, Building with CMake for both x86_64 and aarch64 for MacOS is as easy as setting the CMake configuration variable: "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" when configuring the project. See How do I build cmake from source as universal(arm64 and x86_64) binary on Mac? - Usage - CMake Discourse <https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/3> for a similar case. Cheers, Cristian. On Sat, Sep 17, 2022 at 5:46 PM Martijn van Beurden <mvanb1 at gmail.com> wrote:> Hi all, > > As is being discussed here: https://github.com/xiph/flac/issues/453 > libFLAC has some issues building on MacOS. More specifically, building for > aarch64 and x86_64 at the same time. > > The problem here is that autotools and CMake expect to configure for one > architecture at a time. Also, code is dependent on that configuration, and > not on runtime variables. > > It seems a challenge to me: we need both configuration and building to be > aware of stuff being built in parallel for two architectures. Also, it is > important not to break anything on other architectures, so we might need > both approaches: relying on either run-time arch for MacOS and on static > configuration for other systems. > > I do not have Apple hardware nor any experience with this. I can't seem to > find much documentation on porting autotools or CMake scripts for Apple's > universal builds. If there is anyone here up for this challenge, do not > hesitate to let me know :) > > Kind regards, Martijn van Beurden > _______________________________________________ > flac-dev mailing list > flac-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/flac-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/flac-dev/attachments/20220918/43243004/attachment.htm>
When you refer to "runtime variables," do you really mean build time? It's not really an option to wait until flac runs to determine the runtime architecture. I suspect you mean make variables that are used at build time. I would assume that the source code does not need to change in order to support multiple architectures on macOS, but the compiler and/or make options may need to change. I have not dug into the details yet. If someone does not find a solution before I get back from vacation, I'll take a look. Usually, Xcode makes this easy, and Xcode even produces a Makefile that works outside of the GUI Xcode.app (i.e. it supports command-line building), so that might be a reasonably quick option. However, I admit that keeping Xcode files up to date - like any other GUI build environment - might not be worth the effort, but at least the Makefile could be useful. Brian Willoughby On Sep 17, 2022, at 5:45 PM, Martijn van Beurden <mvanb1 at gmail.com> wrote:> As is being discussed here: https://github.com/xiph/flac/issues/453 libFLAC has some issues building on MacOS. More specifically, building for aarch64 and x86_64 at the same time. > > The problem here is that autotools and CMake expect to configure for one architecture at a time. Also, code is dependent on that configuration, and not on runtime variables. > > It seems a challenge to me: we need both configuration and building to be aware of stuff being built in parallel for two architectures. Also, it is important not to break anything on other architectures, so we might need both approaches: relying on either run-time arch for MacOS and on static configuration for other systems. > > I do not have Apple hardware nor any experience with this. I can't seem to find much documentation on porting autotools or CMake scripts for Apple's universal builds. If there is anyone here up for this challenge, do not hesitate to let me know :)