Я попытался настроить трехслойный конвейер генератора свертки.Сбой сборки на этапе компоновки.Пример, приведенный в apps/wavelet
при запуске make
в каталоге сборки, приводит к следующей ошибке:
[ 87%] Linking CXX executable conv-3
CMakeFiles/conv-3.dir/main.cpp.o: In function `Halide::Internal::check_introspection(void const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text+0xa6): undefined reference to `Halide::Internal::Introspection::get_source_location[abi:cxx11]()'
main.cpp:(.text+0xc3): undefined reference to `Halide::Internal::Introspection::get_variable_name(void const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/conv-3.dir/main.cpp.o: In function `HalideIntrospectionCanary::(anonymous namespace)::TestCompilationUnit::TestCompilationUnit()':
main.cpp:(.text+0xa6a): undefined reference to `Halide::Internal::Introspection::test_compilation_unit(bool (*)(bool (*)(void const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)), bool (*)(void
const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), void (*)())'
./genfiles/halide_rt_host/halide_rt_host.a(halide_rt_host.a.o): In function `halide_spawn_thread':
posix_allocator.cpp:(.text.halide_spawn_thread+0x3d): undefined reference to `pthread_create'
./genfiles/halide_rt_host/halide_rt_host.a(halide_rt_host.a.o): In function `halide_join_thread':
posix_allocator.cpp:(.text.halide_join_thread+0x1a): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
CMakeFiles/conv-3.dir/build.make:96: recipe for target 'conv-3' failed
make[2]: *** [conv-3] Error 1
CMakeFiles/Makefile2:230: recipe for target 'CMakeFiles/conv-3.dir/all' failed
make[1]: *** [CMakeFiles/conv-3.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
CMakeLists.txt
project(three_layer_conv)
cmake_minimum_required(VERSION 3.1.3)
set(HALIDE_DISTRIB_DIR "/home/user/workspace/Halide/distrib")
include(/home/user/workspace/Halide/distrib/halide.cmake)
# Define the wavelet app
add_executable(conv-3 "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
set_target_properties(conv-3 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
target_include_directories(conv-3 PRIVATE "${HALIDE_INCLUDE_DIR}" "${HALIDE_TOOLS_DIR}")
# Define a halide_library() for each generator we have, and link each one into wavelet
#halide_library("conv_3" SRCS "conv_3_generator.cpp")
#file(GLOB GENS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*_generator.cpp")
#foreach(GEN_SRC ${GENS})
# string(REPLACE "_generator.cpp" "" GEN_NAME "${GEN_SRC}")
# halide_library("${GEN_NAME}" SRCS ${GEN_SRC})
# target_link_libraries(conv-3 "${GEN_NAME}" )
#endforeach()
#target_link_libraries(conv-3 PUBLIC "conv_3" pthread)
halide_generator(conv_3.generator SRCS conv_3_generator.cpp)
set(LIB conv_3)
halide_library_from_generator(${LIB} GENERATOR conv_3.generator)
target_link_libraries(conv-3 PRIVATE ${LIB} pthread)
make VERBOSE=1
приводит к
/usr/bin/c++ -rdynamic CMakeFiles/conv-3.dir/main.cpp.o -o conv-3 ./genfiles/conv_3/conv_3.a -lpthread ./genfiles/halide_rt_host/halide_rt_host.a -ldl
PS: Ручное добавление -lpthread
в конец команды приводит к устранению ошибки связывания pthread.
Нужно ли менять свой файл CMake?
Редактировать: Halide.cmake
файл можно найти здесь
halide_library, halide_library_from_generator, halide_generator
функции определены в Halide.cmake
Редактировать 2
ОС: Ubuntu 18.04.3 LTS
компилятор: cc / c ++ (Ubuntu 7.4.0-1ubuntu1 ~ 18.04.1) 7.4.0
компоновщик: GNU ld (GNUBinutils для Ubuntu) 2.30
LLVM: LLVM версия 8.0.0 Оптимизированная сборка
Параметры LLVM: нет
Цель сборки: двоичная