Skip to content

Using FUNCTION_NAME on add_halide_library breaks Python shared objects #6216

Open
@mihai-mc

Description

@mihai-mc

Issue Description

The following CMake configuration compiles, but the resulting shared object is not usable in Python!

Not using FUNCTION_NAME in add_halide_library results in usable shared objects being created.

. . .
add_halide_library(
    dummy_library
    FROM DummyGenerators
    GENERATOR Dummy
    FUNCTION_NAME myDummyFunction
    AUTOSCHEDULER "Halide::Adams2019"
    PARAMS auto_schedule=true
    SCHEDULE OUTVAR
    TARGETS ${Halide_CMAKE_TARGET}
    PYTHON_EXTENSION dummy_library_PYEXT
)

Python3_add_library(
    dummy_library_py
    MODULE
        ${CMAKE_BINARY_DIR}/dummy_library.py.cpp
        ${CMAKE_BINARY_DIR}/dummy_library.runtime.o
        ${CMAKE_BINARY_DIR}/dummy_library.o
)
. . .

Python Error message

    import dummy_library_py
ImportError: dynamic module does not define module export function (PyInit_dummy_library)

System Information

  • OS: macOS 11.5.2
  • CMake: 3.21.1
  • Python: 3.9.6
  • Halide: 12.0.1

Metadata

Metadata

Assignees

Labels

buildIssues related to building Halide and with CI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions