# Buggy code
def serialize_using_object_code(self):
    """
    Serialize this library using its object code as the cached
    representation.
    """
    self._ensure_finalized()
    ll_module = self._final_module
    return (self._name, "object", self._get_compiled_object())


# Traceback (RuntimeError)
$ python app.py
Traceback (most recent call last):
File "app.py", line 21, in <module>
run(N)
File "app.py", line 15, in run
res = fcalc(x)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/dispatcher.py", line 172, in _compile_for_args
return self.compile(sig)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/dispatcher.py", line 350, in compile
flags=flags, locals=self.locals)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 644, in compile_extra
return pipeline.compile_extra(func)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 361, in compile_extra
return self.compile_bytecode(bc, func_attr=self.func_attr)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 370, in compile_bytecode
return self._compile_bytecode()
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 631, in _compile_bytecode
return pm.run(self.status)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 251, in run
raise patched_exception
RuntimeError: Caused By:
Traceback (most recent call last):
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 243, in run
res = stage()
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 587, in stage_nopython_backend
return self._backend(lowerfn, objectmode=False)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 540, in _backend
lowered = lowerfn()
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 527, in backend_nopython_mode
self.flags)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 786, in native_lowering_stage
cfunc = targetctx.get_executable(library, fndesc, env)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/targets/cpu.py", line 147, in get_executable
baseptr = library.get_pointer_to_function(fndesc.llvm_func_name)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/targets/codegen.py", line 377, in get_pointer_to_function
self._ensure_finalized()
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/targets/codegen.py", line 67, in _ensure_finalized
self.finalize()
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/targets/codegen.py", line 170, in finalize
library._get_module_for_linking(), preserve=True)
File "/Users/userx/anaconda/lib/python2.7/site-packages/numba/targets/codegen.py", line 113, in _get_module_for_linking
% (self,))
RuntimeError: library unfit for linking: no available functions in <Library 'func' at 0x10b73ef10>

Failed at nopython (nopython mode backend)
library unfit for linking: no available functions in <Library 'func' at 0x10b73ef10>

# Fixed code
def serialize_using_object_code(self):
    """
    Serialize this library using its object code as the cached
    representation.  We also include its bitcode for further inlining
    with other libraries.
    """
    self._ensure_finalized()
    data = (self._get_compiled_object(), self._get_module_for_linking().as_bitcode())
    return (self._name, "object", data)