-
-
Save NotsOverflow/23b83a4f32b855476533c1600b3183ea to your computer and use it in GitHub Desktop.
Example showing how to compile pony executables via LLVM and clang from LLVM IR produced by 'ponyc -rir ...'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LLVM_HOME=/usr/local/Cellar/llvm/3.6.2/bin | |
PONY_HOME=/path/to/pony/repo | |
PONY_LIBS=${PONY_HOME}/build/debug | |
TARGET_ARCH=x86-64 | |
OUT_LL="$1.ll" | |
OUT_BC="$1.bc" | |
OUT_S="$1.s" | |
OUT_O="$1.o" | |
OUT="fony_$1" | |
# Compile pony in debug mode and generate LLVM IR human readable forms | |
${PONY_HOME}/build/debug/ponyc --debug -rir $1 | |
# Translate LLVM IR human readable forms into LLVM bitcode | |
${LLVM_HOME}/llvm-as ${OUT_LL} | |
# Compile bitcode into assembly listing | |
${LLVM_HOME}/llc -march ${TARGET_ARCH} ${OUT_BC} -o ${OUT_S} | |
# Compile bitcode into object | |
${LLVM_HOME}/llc -march ${TARGET_ARCH} ${OUT_BC} -filetype=obj -o ${OUT_O} | |
# Link into executable | |
clang ${OUT_O} -o ${OUT} -L ${PONY_LIBS} -lponyrt -lSystem.B -e _main | |
# Run executable | |
./${OUT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment