Giter VIP home page Giter VIP logo

iree-template-cpp's People

Contributors

marbre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

iree-template-cpp's Issues

Cannot link C static libraries through cgo after building IREE from source

What happened?

I'm using the C API from golang, using the cgo library. I have build IREE from source with the following command:

	mkdir -p iree_bridge/build
	cd iree_bridge/build && \
	cmake -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. && \
	ninja

This generates a series of .a files and I have included all of them in my .go file:

// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build -liree_bridge
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/runtime -liree_runtime_impl
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers -liree_hal_drivers_drivers
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/elf -liree_hal_local_elf_elf_module -liree_hal_local_elf_arch -liree_hal_local_elf_platform
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_arena
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/task -liree_task_api -liree_task_task
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_wait_handle -liree_base_internal_atomic_slist
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_threading
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/loaders -liree_hal_local_loaders_vmvx_module_loader
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local -liree_hal_local_local
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/modules/vmvx -liree_modules_vmvx_vmvx
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_flags -liree_base_internal_file_io
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal -liree_modules_hal_hal
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal -liree_hal_hal
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_synchronization
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/vm -liree_vm_bytecode_module -liree_vm_impl
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base -liree_base_base
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/build_tools/third_party/flatcc -lflatcc_parsing
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/third_party/cpuinfo/deps/clog -lclog
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/third_party/cpuinfo -lcpuinfo
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/third_party/llvm-project/llvm/lib -lLLVMSupport
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/third_party/llvm-project/llvm/lib -lLLVMDemangle
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/third_party/llvm-project/llvm/lib -lLLVMFileCheck
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_arena
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_path
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_cpu
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_wait_handle
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_event_pool
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_threading
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_dynamic_library
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_synchronization
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_fpu_state
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_atomic_slist
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_file_io
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base/internal -liree_base_internal_flags
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/base -liree_base_base
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/elf -liree_hal_local_elf_arch
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/elf -liree_hal_local_elf_platform
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/elf -liree_hal_local_elf_elf_module
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/loaders/registration -liree_hal_local_loaders_registration_registration
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/loaders -liree_hal_local_loaders_vmvx_module_loader
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/loaders -liree_hal_local_loaders_system_library_loader
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local/loaders -liree_hal_local_loaders_embedded_elf_loader
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local -liree_hal_local_local
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local -liree_hal_local_executable_environment
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/local -liree_hal_local_executable_loader
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/registration -liree_hal_drivers_local_sync_registration_registration
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync -liree_hal_drivers_local_sync_sync_driver
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_task/registration -liree_hal_drivers_local_task_registration_registration
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_task -liree_hal_drivers_local_task_task_driver
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers -liree_hal_drivers_drivers
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/utils -liree_hal_utils_semaphore_base
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/utils -liree_hal_utils_buffer_transfer
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/utils -liree_hal_utils_resource_set
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal/utils -liree_hal_utils_deferred_command_buffer
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/hal -liree_hal_hal
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/vm -liree_vm_bytecode_module
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/vm -liree_vm_impl
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/builtins/ukernel/arch -liree_builtins_ukernel_arch_ukernel_arch
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/builtins/ukernel -liree_builtins_ukernel_ukernel
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/builtins/ukernel -liree_builtins_ukernel_elementwise
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/builtins/ukernel -liree_builtins_ukernel_generic
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/task -liree_task_task
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/task -liree_task_api
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal/utils -liree_modules_hal_utils_buffer_diagnostics
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal -liree_modules_hal_types
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal -liree_modules_hal_hal
// #cgo LDFLAGS: -L${SRCDIR}/iree_bridge/build
// #cgo LDFLAGS: -lm -lpthread -ldl -lstdc++ -pthread
// #include <stdlib.h>
// #include "iree_bridge/iree_bridge.h"

My problem is that building the go file that uses the C functions from the IREE interface crashes with a load of errors. Pasting truncated output

# command-line-arguments
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/libiree_hal_drivers_drivers.a(init.c.o): In function `iree_hal_register_all_available_drivers':
init.c:(.text+0x20): undefined reference to `iree_hal_vulkan_driver_module_register'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/registration/libiree_hal_drivers_local_sync_registration_registration.a(driver_module.c.o): In function `iree_hal_local_sync_driver_factory_try_create':
driver_module.c:(.text+0x9d): undefined reference to `iree_hal_executable_import_provider_default'
driver_module.c:(.text+0xc0): undefined reference to `iree_hal_create_all_available_executable_loaders'
driver_module.c:(.text+0x156): undefined reference to `iree_hal_executable_loader_release'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/libiree_hal_drivers_local_sync_sync_driver.a(sync_device.c.o): In function `iree_hal_sync_device_create':
sync_device.c:(.text+0x14b): undefined reference to `iree_arena_block_pool_initialize'
sync_device.c:(.text+0x170): undefined reference to `iree_hal_executable_loader_retain'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/libiree_hal_drivers_local_sync_sync_driver.a(sync_device.c.o): In function `iree_hal_sync_device_destroy':
sync_device.c:(.text+0x1f9): undefined reference to `iree_hal_executable_loader_release'
sync_device.c:(.text+0x218): undefined reference to `iree_arena_block_pool_deinitialize'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/libiree_hal_drivers_local_sync_sync_driver.a(sync_device.c.o): In function `iree_hal_sync_device_query_i64':
sync_device.c:(.text+0x2d4): undefined reference to `iree_hal_query_any_executable_loader_support'
sync_device.c:(.text+0x375): undefined reference to `iree_cpu_lookup_data_by_key'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/hal/drivers/local_sync/libiree_hal_drivers_local_sync_sync_driver.a(sync_device.c.o): In function `iree_hal_sync_device_create_command_buffer':
...
...
...
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/task/libiree_task_api.a(api.c.o): In function `iree_flag_register_task_topology_max_group_count':
api.c:(.text+0x250): undefined reference to `iree_flag_register'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/task/libiree_task_api.a(api.c.o): In function `iree_task_topology_initialize_from_flags':
api.c:(.text+0x2d8): undefined reference to `iree_task_topology_initialize_from_physical_cores'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/task/libiree_task_api.a(api.c.o): In function `iree_task_executor_create_from_flags':
api.c:(.text+0x39f): undefined reference to `iree_task_topology_initialize_from_physical_cores'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal/libiree_modules_hal_types.a(types.c.o): In function `iree_hal_module_register_loader_types':
types.c:(.text+0x17b): undefined reference to `iree_hal_executable_destroy'
src/metric_service/iree/iree_bridge/build/third_party/iree/runtime/src/iree/modules/hal/libiree_modules_hal_types.a(types.c.o): In function `iree_hal_module_register_all_types':
types.c:(.text+0x28d): undefined reference to `iree_hal_executable_destroy'
types.c:(.text+0x3e3): undefined reference to `iree_hal_event_destroy'
collect2: error: ld returned 1 exit status
Makefile:389: recipe for target 'iree' failed
make: *** [iree] Error 2

What could I possibly be missing? I have included all of the .a files generated when building IREE from source, i.e. everything under iree_bridge/build/ in my case

Version information

-f https://github.com/iree-org/iree/releases/expanded_assets/candidate-20220930.282
--extra-index-url https://github.com/iree-org/iree/releases/expanded_assets/candidate-20220930.282
iree-compiler
iree-runtime
iree-tools-tf
iree-tools-tflite
iree-tools-xla
cmake version 3.24.1

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Additional context

I only need this to work with dylib-llvm-aot, which I think is now called llvm-cpu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.