Exploring the M1 (Getting started with Conan)

As described in part 1, I have access to a Mac 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 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 popper 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 commnad xcversion.

For the installation of xcode-install I created a Gemfile

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

The most easy 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 can not recommend doing that on scale. The download from the Apple site is way too slow. If you do that on more than 1 machine, get your XCode app xpi and share that.

Homebrew

Since the begin 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 live 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 on a clean BigSur installation also the case, my could installation might have some additional packages per default.

I installed Python via asdf. Brew offers also 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 archs also

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 exists for this Mac mini. This will be interesting to find out!

Let’s compile a package ..

Now, with the basic setup is 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 begin!

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