Exploring the M1 (Getting started with Conan)

As described in part 1, I have access to an Apple Silicon device in the cloud.

The final goal is to run conan on the M1, use it to build some dependencies, and compile some software. But first, some configurations and useful tools.

Some more configuration

In addition to what was covered in part 1, since this is something I will for sure forget until the next time I need it. To improve the screen experience, these lines in .screenrc

# Enable a proper PROMPT / PS1 display
shell -$SHELL
# Enable mouse scrolling and scroll bar history scrolling
termcapinfo xterm* ti@:te@

Install Xcode, remote without GUI

Installing Xcode without GUI is interesting. I used a ruby gem for that. It is called xcode-install and provides a command xcversion.

For the installation of xcode-install I created a Gemfile

source "https://rubygems.org"
gem 'fastlane', '2.174.0'
gem 'xcode-install'

The easiest way to install that as a user is bundle, and install the gems into the current working directory.

bundle install --path vendor/bundle

Now, xcversion (that’s the command xcode-install provides) is ready to use.

bundle exec xcversion list
bundle exec xcversion install 12.4
bundle exec xcversion install-cli-tools

You will be asked for Apple ID credentials, since those are required to get access to the Xcode downloads. The credentials can be provided via environment variables.

While this is a great way to automate the setup of Xcode, even multiple versions, I cannot recommend doing that at scale. The download from the Apple site is way too slow. If you do that on more than 1 machine, get your Xcode app .xip and share that.

Homebrew

Since the beginning of the month of writing this post, brew exists for M1. And there are a lot of packages available. Basically, everything I need.

I do not need a lot, but things like direnv make developer’s life more flexible. And some build requirements, of course, the usual ones, like autoconf, automake, …​ to cmake. Even if I will build some of them with conan.

So the only difference I see to the x86_64 version is that on M1 I add /opt/homebrew/bin to PATH.

Python

Python3 is already available. Not sure if this is also the case on a clean macOS Big Sur installation, my cloud installation might have some additional packages by default.

I installed Python via asdf. Brew also offers some versions. So there are plenty of options.

Get started with conan

Now with everything needed in place, I can start using conan

Installing conan is a pip command, like on other architectures as well

pip install conan

For compiling packages, you need a profile. conan can create one for you.

With the current Conan version 1.33.1 , I encountered a tiny, but confusing issue.

conan profile new --detect default
ERROR: Your ARM 'arm64' architecture is probably not defined in settings.yml
Please check your conan.conf and settings.yml files
Found apple-clang 12.0
Profile created with detected settings: /Users/a4z/.conan/profiles/default

With the help of the Conan channel on cpplang the reason for this problem was quickly identified. This will be fixed in the next version.

For now, I had to replace the detected arm64 entries in the profile with armv8.

It feels strange to use settings I used so far only for embedded devices and phones for developer machines. But this is also very interesting. In theory, all the packages I already compiled for the iPhone should exist for this Mac mini. This will be interesting to find out!

Let’s compile a package ..

Now, with the basic setup in place, let’s do a quick test.

conan install zlib/1.2.11@ --build missing --profile default
...
...
zlib/1.2.11 package(): Packaged 1 file: LICENSE
zlib/1.2.11 package(): Packaged 2 '.h' files: zlib.h, zconf.h
zlib/1.2.11 package(): Packaged 1 '.a' file: libz.a
zlib/1.2.11: Package '8fafab5ebfba468fd21a497cfee65cafe294bd9e' created
zlib/1.2.11: Created package revision 508b853fcab09a9a21a67732e996e577

That’s a positive beginning!

Now I am curious to see how this will continue …​ maybe there will be a part 3.