⑨ lab ≡ who cares?!

Darwin/Build Notes

Random notes on how to build random pieces of software for esoteric use cases on Darwin…


The notes on this page are for building LLVM and GenSim on Darwin in such a way that I can use them to implement a JIT for a dynamic binary translator. You are probably lost and should hit the return button in your browser. Seriously, this stuff here is specialised for my use case only, go away…!


Get Xcode, install brew and get the following:

 % brew install cmake
 % brew install ccache
 % brew install ninja

The rest of these notes assume you use plan9port, the closest thing to Plan9 on Darwin. Note that this plan9port is my custom version, not the official one…


 % cat $home/lib/entitlements.xcet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
 % codesign \
	--sign \
	- \
	--force \
	--preserve-metadata=entitlements,requirements,flags,runtime \
	--entitlements $home/lib/entitlements.xcet \

To disable code-signing verification (e.g. during regression testing) run the following in a Terminal:

 % spctl developer-mode enable-terminal

Next, go to System Preferences -> Security & Privacy -> Privacy, and scroll down till you see an entry for Developer Tools. Authenticate, and tick the checkbox next to Terminal.

Build LLVM for Apple Silicon

LLVM 12.0.1

The following build was tested on an M1 Mac Mini running MacOS Big Sur:

 % mkdir -p src/llvm/12.0.1
 % curl -L -o clang-12.0.1.src.tar.xz \
 % curl -L -o llvm-12.0.1.src.tar.xz \
 % tar xf clang-12.0.1.src.tar.xz
 % tar xf llvm-12.0.1.src.tar.xz
 % ln -s clang-12.0.1.src clang
 % ln -s llvm-12.0.1.src llvm
 % mkdir build && cd build
 % cmake ../llvm \
      -GNinja \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=$HOME/lib/work/llvm/clang+llvm-12.0.1-arm64-apple-darwin \

 % ninja
 % ninja install

LLVM 9.0.1

The following build was tested on an M1 Mac Mini running MacOS Big Sur:

 % mkdir -p src/llvm/9.0.1
 % curl -L -o clang-9.0.1.src.tar.xz \
 % curl -L -o llvm-9.0.1.src.tar.xz \
 % tar xf clang-9.0.1.src.tar.xz
 % tar xf llvm-9.0.1.src.tar.xz
 % ln -s clang-9.0.1.src clang
 % ln -s llvm-9.0.1.src llvm
 % mkdir build && cd build
 % cmake ../llvm \
      -GNinja \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=$HOME/lib/work/llvm/clang+llvm-9.0.1-arm64-apple-darwin \

 % ninja
 % ninja install

Build GenSim

 % brew install libantlr3c
 % brew install openjdk
 % path=(/opt/homebrew/opt/openjdk/bin $path)
 … checkout GenSim repository …
 % mkdir build && cd build
 % cmake .. -DANTLR_INCLUDE_DIR=/opt/homebrew/include \
 % make gensim
 % file dist/bin/gensim
dist/bin/gensim: Mach-O 64-bit executable arm64
 % cp dist/bin/gensim $home/bin/gensim

#Dev #Darwin #Work #SNPS