Skip to content

Instantly share code, notes, and snippets.

@cchandler
Created April 13, 2019 19:24
Show Gist options
  • Save cchandler/2418f65d15ac670d6e31d6aee8bd6212 to your computer and use it in GitHub Desktop.
Save cchandler/2418f65d15ac670d6e31d6aee8bd6212 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
OUTPUT_DIR=`pwd`
LLVM_HOME=/usr/local/Cellar/llvm/8.0.0/
RUSTUP_TOOLCHAIN_LIB=/Users/chris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib
cargo rustc --verbose -- -v -C save-temps --emit=llvm-ir
cd target/debug/deps
rm *no-opt*
# The LLVM version that rustc was built against requires a fixup against
# LLVM 8 (running from homebrew).
# You can pretend this line isn't here if using an older LLVM.
find . -name '*.ll' | xargs -n 1 sed -i '' 's/DIFlagFixedEnum/DIFlagEnumClass/g'
find . -name '*.ll' | xargs -n 1 $LLVM_HOME/bin/llvm-as
find . -name '*.ll' | rev | cut -c 3- | rev | \
xargs -n 1 -I {} $LLVM_HOME/bin/opt \
-load ~/Development/clutter/target/lib/libclutter.so -o {}bc {}bc
find . -name '*.ll' | xargs -n 1 $LLVM_HOME/bin/llc -filetype=obj
cc -m64 -L $RUSTUP_TOOLCHAIN_LIB \
*.o \
$(ls | grep '\.rlib$' | sed 's/lib/ \.\/lib/') \
$(find $RUSTUP_TOOLCHAIN_LIB -name '*rlib') \
-L ~/.rustup/toolchains/stable-x86_64-apple-darwin/lib/ \
-Wl,-dead_strip -nodefaultlibs -lSystem -lresolv -lc -lm \
-o $OUTPUT_DIR/complicated_app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment