-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example for Aarch64 compile #371
Comments
Unfortunately, I've never cross-compiled it myself, so can't really say what's needed. Feel free to fill in here how it's solved, but in general I think it can be done using generic (i.e., what you find by googling) cmake cross compilation instructions. At least as long as the required libraries are available as well. |
Ok, I arrived at the compile step and ran into the first problem (I had to censor proprietary parts with XXXXXX.): [ 76%] Building CXX object src/CMakeFiles/kcov.dir/parsers/elf.cc.o It seems that the offending header is from the path that is provided via LIBDW_INCLUDE_DIR but the directory in the -I parameter is from LIBELF_INCLUDE_DIR. Does this step require both headers from libdw and libelf? If yes, is this accounted for in the makefiles? |
Yes, both are required. I guess the CMakeLists.txt should be better and stop before compilation starts though... But elfutils (libdw.h) is used for parsing DWARF debugging information, so that's fundamental to kcov. |
Can you tell me in which Cmake file the -I includes for src/CMakeFiles/kcov.dir/parsers/elf.cc.o are specified? |
Sure! src/CMakeLists.txt is the main build file, while the cmake/-directory contains the helpers to find libraries, FindLibElf.cmake and FindElfutils.cmake are of interest here. |
CmakeLists.txt:294 if (LIBDW_FOUND) Is this what should append the path including <elfutils/libdw.h> ? |
Do these indicate a problem that may cause libdw include not getting added? CMake Warning (dev) at /opt/cmake-3.19.3-Linux-x86_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message): CMake Warning (dev) at /opt/cmake-3.19.3-Linux-x86_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message): |
Ok, apparently LIBDW_FOUND is never set. What determines whether this is found? LIBDW_LIBRARY and LIBDW_INCLUDE_DIR? If yes, how should these look like? Currently LIBDW_LIBRARY points directly at libdw.so. |
I think it's probably this part in FindElfutils.cmake that is not properly working,
Probably you can pass CPATH before cmake to allow it to find elfutils/libdw.h, i.e., if you have your target devel headers in
and your libraries in
then run cmake with
edit: My example was for dwarf.h, but the same goes for libdw.h. Also added LIBRARY_PATH |
Which command would set LIBDW_FOUND to true anyways? Edit: Overriding LIBDW_FOUND manually will allow compilation to proceed. |
It's should be set by FindElfutils.cmake if it manages to find the headers and libraries, but good that you found a workaround! Probably the Find utilities doesn't work very well in your cross compilation setting. |
According to https://cmake.org/cmake/help/latest/command/find_package.html find_package would set the LIBDW_FOUND variable but I cannot find a find_package call with LIBDW. Where did you intend to have it set? |
Another question: I managed to run kcov with the intended executable but it doesn't produce any coverage output (it does create the file structure in the output directory like index html, coverage.json etc.). Does kcov work with stripped binaries? Some other tools allow adding symbols later on. |
The find_package_handle_standard_args should do that if I remember correctly. Running without symbols isn't really supported. There is the kcov-system-daemon which tries to do this, but it's not quite functional. It does support debug links though (https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html), which might be useful depending on how you build your system. With those, you could e.g., NFS mount the debug directories and kcov will detect and use those if the binaries are stripped. |
Where is find_package_handle_standard_args called for LIBDW? https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html It's a pity that kcov doesn't have a no symbols mode. We have tests conducted by external staff and handing out our symbols would be a problem. |
It's here, https://github.com/SimonKagstrom/kcov/blob/master/cmake/FindElfutils.cmake#L70 unfortunately, it won't work without symbols. Kcov uses breakpoints to get coverage data, and the symbols (well, the DWARF debug information) are needed in order to provide the translation source-file:line -> address. The source doesn't need to be available when collecting, with --collect-only, but the debug information is needed. The idea with system mode was to overcome this limitation (well, not only, but as well). In that case, you would run kcov on your build output (the sysroot, with debug symbols) to create a list of breakpoints to be set in a file. On target, the kcov system daemon would then read this file and produce coverage output to some directory which can later be copied over to your host machine and analyzed there. But unfortunately, it's still just a proof of concept and hasn't been useful to me personally, so I haven't finished implementing it. |
find_package_handle_standard_args(ElfUtils DEFAULT_MSG If I understand the documentation of find_package_handle_standard_args right then the first parameter, ElfUtils, would have to be equivalent to LIBDW so LIBDW_FOUND=1 is set. Is that the case? Otherwise the result should be something like ELFUTILS_FOUND which is not used anywhere I think. We are coding for embedded environment where a lot of testing is done in the wild and with production software so a mode where the symbols could be resoved later would be invaluable. |
Greetings,
I need to cross-compile kcov for an armv8 Aarch64 yocto linux on an X64 Ubuntu Linux. Can someone point me to an example for how to run cmake to set all necessary parameters?
Thank you.
The text was updated successfully, but these errors were encountered: