# Buggy code
def _unserialize(cls, codegen, state):
    name, kind, data = state
    self = codegen.create_library(name)
    assert isinstance(self, cls)
    if kind == "bitcode":
        # No need to re-run optimizations, just make the module ready
        self._final_module = ll.parse_bitcode(data)
        self._finalize_final_module()
        return self
    elif kind == "object":
        self.enable_object_caching()
        self._set_compiled_object(data)
        self._finalize_final_module()
        return self
    else:
        raise ValueError("unsupported serialization kind %r" % (kind,))


# 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 _unserialize(cls, codegen, state):
    name, kind, data = state
    self = codegen.create_library(name)
    assert isinstance(self, cls)
    if kind == "bitcode":
        # No need to re-run optimizations, just make the module ready
        self._final_module = ll.parse_bitcode(data)
        self._finalize_final_module()
        return self
    elif kind == "object":
        object_code, shared_bitcode = data
        self.enable_object_caching()
        self._set_compiled_object(object_code)
        self._shared_module = ll.parse_bitcode(shared_bitcode)
        self._finalize_final_module()
        return self
    else:
        raise ValueError("unsupported serialization kind %r" % (kind,))