Skip to content

"cannot determine Numba type" when calling AOT-compiled function from AOT-compiled function #3823

Description

If you take the AOT example file from the documentation and add another function to it,

@cc.export('runall', '()')
def runall():
    square(4)

you get this traceback when attempting to compile it. From this I conclude that numba does not support nesting AOT-compiled functions. True? If not I would like to see a working example in your docs.

Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    ext_modules=[cc.distutils_extension()])
  File "tenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "tenv/local/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 192, in run
    self.run_command('build')
  File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
    self.run_command(cmd_name)
  File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "tenv/local/lib/python2.7/site-packages/setuptools/command/build_ext.py", line 78, in run
    _build_ext.run(self)
  File "/usr/lib/python2.7/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/usr/lib/python2.7/distutils/command/build_ext.py", line 448, in build_extensions
    self.build_extension(ext)
  File "tenv/local/lib/python2.7/site-packages/setuptools/command/build_ext.py", line 199, in build_extension
    _build_ext.build_extension(self, ext)
  File "tenv/local/lib/python2.7/site-packages/numba/pycc/cc.py", line 293, in build_extension
    ext._prepare_object_files(self)
  File "tenv/local/lib/python2.7/site-packages/numba/pycc/cc.py", line 274, in _prepare_object_files
    objects, _ = cc._compile_object_files(build_ext.build_temp)
  File "tenv/local/lib/python2.7/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "tenv/local/lib/python2.7/site-packages/numba/pycc/cc.py", line 200, in _compile_object_files
    compiler.write_native_object(temp_obj, wrap=True)
  File "tenv/local/lib/python2.7/site-packages/numba/pycc/compiler.py", line 198, in write_native_object
    library = self._cull_exports()
  File "tenv/local/lib/python2.7/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "tenv/local/lib/python2.7/site-packages/numba/pycc/compiler.py", line 157, in _cull_exports
    locals={}, library=library)
  File "tenv/local/lib/python2.7/site-packages/numba/compiler.py", line 926, in compile_extra
    return pipeline.compile_extra(func)
  File "tenv/local/lib/python2.7/site-packages/numba/compiler.py", line 374, in compile_extra
    return self._compile_bytecode()
  File "tenv/local/lib/python2.7/site-packages/numba/compiler.py", line 857, in _compile_bytecode
    return self._compile_core()
  File "tenv/local/lib/python2.7/site-packages/numba/compiler.py", line 844, in _compile_core
    res = pm.run(self.status)
  File "tenv/local/lib/python2.7/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "tenv/local/lib/python2.7/site-packages/numba/compiler.py", line 255, in run
    raise patched_exception
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'square': cannot determine Numba type of <type 'function'>

File "numbatest/multsquare.py", line 26:
def runall():
    square(4)
    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    AOTahead of time compilation issuebugdocgood first issueA good issue for a first time contributor

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions