Work around LLVM C API limitations and handle foreign functions properly.