jmmartinez/easy-just-in-time

Example camfilter fails

Opened this issue · 8 comments

I have a self-built LLVM/Clang 6.0.1 and building with examples fails at camfilter with

[1/2] Building CXX object doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o
FAILED: doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o 
/usr/local/bin/clang++   -I/usr/local/include -I/home/maliusarth/dev/ext/repos/easy-just-in-time/include -isystem /usr/local/include/opencv4 -Xclang -disable-O0-optnone -Xclang -load -Xclang /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so -g   -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -MF doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o.d -o doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -c /home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp
/home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp:198:50: error: use of undeclared identifier 'cvPoint'
    cv::putText(*Out, fps_message.str().c_str(), cvPoint(30,30),
                                                 ^
/home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp:200:17: error: use of undeclared identifier 'cvScalar'
                cvScalar(200,200,250), 1, CV_AA);
                ^
/home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp:200:43: error: use of undeclared identifier 'CV_AA'
                cvScalar(200,200,250), 1, CV_AA);
                                          ^
3 errors generated.
ninja: build stopped: subcommand failed.

I also have custom built opencv 4.0.1

fixed it by replacing said lines with this:

    cv::putText(*Out, fps_message.str().c_str(), cv::Point(30,30),
                cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8,
                cv::Scalar(200,200,250), 1, cv::LineTypes::LINE_AA);

but now I get the following errors:

[1/2] Building CXX object doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o
FAILED: doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o 
/usr/local/bin/clang++   -I/usr/local/include -I/home/maliusarth/dev/ext/repos/easy-just-in-time/include -isystem /usr/local/include/opencv4 -Xclang -disable-O0-optnone -Xclang -load -Xclang /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so -g   -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -MF doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o.d -o doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -c /home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp
/usr/local/bin/clang-6.0: symbol lookup error: /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so: undefined symbol: _ZN4llvm22createGVExtractionPassERSt6vectorIPNS_11GlobalValueESaIS2_EEb
clang-6.0: error: unable to execute command: No such file or directory
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.1 (https://github.com/MaliusArth/clang.git 9f53b2773a427f3455097801412d56aa67dcda98) (https://github.com/MaliusArth/llvm.git c00ddb88b985fc3a66acd635f7bcd1ff5bc88100)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-6.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/camfilter-f88ddd.cpp
clang-6.0: note: diagnostic msg: /tmp/camfilter-f88ddd.sh
clang-6.0: note: diagnostic msg: 

********************
ninja: build stopped: subcommand failed.

added .txt file endings because githubs upload filter
camfilter-f88ddd.cpp.txt
camfilter-f88ddd.sh.txt

looks like I forgot to set the LLVM_EXPORT_SYMBOLS_FOR_PLUGINS cmake variable when building llvm/clang... might be related to that.
I'll get back on that once building has finished.

now I get:

[0/1] Re-running CMake...
-- Found LLVM 6.0.1
-- Using LLVMConfig.cmake in /usr/local/lib/cmake/llvm
-- LLVM Root: /usr/local/bin
-- LLVM Include dirs: /usr/local/include
-- Linker detection: GNU ld
-- Could NOT find PY_lit (missing: PY_LIT) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time
[17/18] Building CXX object doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o
FAILED: doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o 
/usr/local/bin/clang++   -I/usr/local/include -I/home/maliusarth/dev/ext/repos/easy-just-in-time/include -isystem /usr/local/include/opencv4 -Xclang -disable-O0-optnone -Xclang -load -Xclang /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so -g   -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -MF doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o.d -o doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -c /home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp
error: unable to load plugin '/home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so': '/home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so: undefined symbol: _ZTVN4llvm2cl6parserINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE'
ninja: build stopped: subcommand failed.

I had the same error, i fixed it by adding this two header (in camfilter.cpp):

#include <opencv2/imgproc/imgproc_c.h>  
#include <opencv2/core/types_c.h>

imgproc_c.h contains definition for CV_AA
types_c.h contains definition of cvPoint (It was not defined when i tried to build the example)

I didn't change the line like you did by the way.

Good to know, but i prefer the c++ headers.

Still, there is the problem with the undefined symbol _ZTVN4llvm2cl6parserINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE'

I could resolve the symbol by adding llvm_config(EasyJitPass support) to pass/CMakeLists.txt.

Now I get this:

[0/1] Re-running CMake...
-- Found LLVM 6.0.1
-- Using LLVMConfig.cmake in /usr/local/lib/cmake/llvm
-- LLVM Root: /usr/local/bin
-- LLVM Include dirs: /usr/local/include
-- Linker detection: GNU ld
-- Could NOT find PY_lit (missing: PY_LIT) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time
[7/8] Building CXX object doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o
FAILED: doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o 
/usr/local/bin/clang++   -I/usr/local/include -I/home/maliusarth/dev/ext/repos/easy-just-in-time/include -isystem /usr/local/include/opencv4 -Xclang -disable-O0-optnone -Xclang -load -Xclang /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so -g   -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++14 -MD -MT doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -MF doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o.d -o doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -c /home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp
clang-6.0: /home/maliusarth/dev/ext/repos/llvm/6.0/lib/Support/CommandLine.cpp:281: void {anonymous}::CommandLineParser::registerCategory(llvm::cl::OptionCategory*): Assertion `count_if(RegisteredOptionCategories, [cat](const OptionCategory *Category) { return cat->getName() == Category->getName(); }) == 0 && "Duplicate option categories"' failed.
#0 0x000000000209751a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/bin/clang-6.0+0x209751a)
#1 0x00000000020952be llvm::sys::RunSignalHandlers() (/usr/local/bin/clang-6.0+0x20952be)
#2 0x0000000002095432 SignalHandler(int) (/usr/local/bin/clang-6.0+0x2095432)
#3 0x00007f4caa06a390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f4ca8ddc428 gsignal /build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f4ca8dde02a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f4ca8dd4bd7 __assert_fail_base /build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
#7 0x00007f4ca8dd4c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x0000000002027353 llvm::cl::OptionCategory::registerCategory() (/usr/local/bin/clang-6.0+0x2027353)
#9 0x00007f4ca8ad7af8 __static_initialization_and_destruction_0(int, int) [clone .constprop.327] (/home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so+0x69af8)
#10 0x00007f4caa2866ca call_init /build/glibc-LK5gWL/glibc-2.23/elf/dl-init.c:72:0
#11 0x00007f4caa2867db call_init /build/glibc-LK5gWL/glibc-2.23/elf/dl-init.c:30:0
#12 0x00007f4caa2867db _dl_init /build/glibc-LK5gWL/glibc-2.23/elf/dl-init.c:120:0
#13 0x00007f4caa28b8f2 dl_open_worker /build/glibc-LK5gWL/glibc-2.23/elf/dl-open.c:578:0
#14 0x00007f4caa286574 _dl_catch_error /build/glibc-LK5gWL/glibc-2.23/elf/dl-error.c:188:0
#15 0x00007f4caa28adb9 _dl_open /build/glibc-LK5gWL/glibc-2.23/elf/dl-open.c:660:0
#16 0x00007f4ca9c3bf09 __asprintf /build/glibc-LK5gWL/glibc-2.23/dlfcn/dlopen.c:66:0
#17 0x00007f4caa286574 _dl_catch_error /build/glibc-LK5gWL/glibc-2.23/elf/dl-error.c:188:0
#18 0x00007f4ca9c3c571 _dlerror_run /build/glibc-LK5gWL/glibc-2.23/dlfcn/dlerror.c:163:0
#19 0x00007f4ca9c3bfa1 dlopen /build/glibc-LK5gWL/glibc-2.23/dlfcn/dlopen.c:87:0
#20 0x0000000003c19c43 llvm::sys::DynamicLibrary::HandleSet::DLOpen(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) (/usr/local/bin/clang-6.0+0x3c19c43)
#21 0x0000000003c1a5d2 llvm::sys::DynamicLibrary::getPermanentLibrary(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) (/usr/local/bin/clang-6.0+0x3c1a5d2)
#22 0x00000000026cf73f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/bin/clang-6.0+0x26cf73f)
#23 0x00000000009241a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/bin/clang-6.0+0x9241a8)
#24 0x00000000008a5ae4 main (/usr/local/bin/clang-6.0+0x8a5ae4)
#25 0x00007f4ca8dc7830 __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#26 0x0000000000920219 _start (/usr/local/bin/clang-6.0+0x920219)
Stack dump:
0.	Program arguments: /usr/local/bin/clang-6.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name camfilter.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.gcno -resource-dir /usr/local/lib/clang/6.0.1 -dependency-file doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o.d -sys-header-deps -MT doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -isystem /usr/local/include/opencv4 -I /usr/local/include -I /home/maliusarth/dev/ext/repos/easy-just-in-time/include -D _GNU_SOURCE -D _DEBUG -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/local/lib/clang/6.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=gnu++14 -fdeprecated-macro -fdebug-compilation-dir /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -disable-O0-optnone -load /home/maliusarth/dev/ext/projects/cmake/easy-just-in-time/bin/EasyJitPass.so -o doc/readme/CMakeFiles/easyjit-example.dir/camfilter.cpp.o -x c++ /home/maliusarth/dev/ext/repos/easy-just-in-time/doc/readme/camfilter.cpp 
clang-6.0: error: unable to execute command: Aborted
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.1 (https://github.com/MaliusArth/clang.git 9f53b2773a427f3455097801412d56aa67dcda98) (https://github.com/MaliusArth/llvm.git c00ddb88b985fc3a66acd635f7bcd1ff5bc88100)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-6.0: error: unable to execute command: Aborted
clang-6.0: note: diagnostic msg: Error generating preprocessed source(s).
ninja: build stopped: subcommand failed.