Skip to content

veracode/gen-ir


Gen IR 🧞‍♂️

Generate LLVM IR from an Xcode Build Log

Badge showing status of the build pipelines Badge showing the current release version of Gen IR

This tool was heavily inspired by a DigitalRickshaw blog post ❤️

Prerequisites

To build the tool, you'll need Xcode 14 and macOS 12.5 or greater.

To install and run the tool, you'll need Homebrew, Xcode, and macOS 12 or greater.

Install

if ! command -v brew >/dev/null 2>&1; then
  echo "Homebrew is not installed. Visit https://brew.sh/ to install it."
  return 1 2>/dev/null || true
else
  echo "Installing gen-ir using Homebrew" &&
  brew tap veracode/tap &&
  brew install gen-ir &&

  echo "gen-ir installed successfully."
  echo "For usage instructions, see:"
  echo "  https://github.com/veracode/gen-ir#readme"
fi

Update (if previously installed)

brew upgrade gen-ir

🎉 Done

All installed! You can now use gen-ir on your system - be sure to run gen-ir --help to check the available commands and options.

Usage

⚠️ Before you use

It's important to know that gen-ir requires that a full build log is provided.

This means a clean, fresh build of a project.

The compiler will not make a call for an object that doesn't need to be rebuilt, and we will not be able to parse what doesn't exist. Ensure you do a clean before your build otherwise gen-ir may miss some modules.

Due to a bug in Xcode you must run the clean and archive commands separately. This means you need to do a xcodebuild clean and then an xcodebuild archive and not xcodebuild clean archive.

gen-ir takes a Xcode build log by two means, a path to a file or stdin:

# Path to build log (you can export from inside of Xcode too)
xcodebuild clean && \
xcodebuild archive -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive > build_log.txt

gen-ir build_log.txt TestProject.xcarchive

# Stdin (you may need to redirect stderr to stdout here, Xcode is weird about writing to it sometimes)
xcodebuild clean && \
xcodebuild archive -project TestProject.xcodeproj -scheme TestProject -configuration Debug -destination generic/platform=iOS -archivePath TestProject.xcarchive | gen-ir - TestProject.xcarchive

Building

gen-ir is implemented as a Swift Package, so you can either open Package.swift in an IDE or build via the command line:

# Debug output: ./.build/debug/gen-ir
swift build

# Release output: ./.build/release/gen-ir
swift build -c release

Remove older version

If you previously installed the test version during early access testing, run the following commands to remove the test version from your system before installing:

brew uninstall gen-ir &&
brew untap NinjaLikesCheez/tap

About

Generates LLVM IR for Xcode Projects

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 6