libelektra
libelektra copied to clipboard
build failure on ARMhf
Steps to Reproduce the Problem
Build Elektra on A20 (DEB_BUILD_ARCH=armhf)
make VERBOSE=1
Expected Result
Successful build
Actual Result
[ 79%] Linking C executable ../../bin/testmod_type
cd /mnt/data/build/src/plugins_tests && /usr/bin/cmake -E cmake_link_script CMakeFiles/testmod_type.dir/link.txt --verbose=1
/usr/bin/cc -std=gnu99 -Wno-deprecated-declarations -Wstrict-prototypes -Wno-long-long -Wpedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -Wsign-compare -Wfloat-equal -O2 -g -DNDEBUG CMakeFiles/testmod_type.dir/type/testmod_type.c.o ../../tests/cframework/CMakeFiles/cframework.dir/tests.c.o ../plugins/type/CMakeFiles/elektra-type-objects.dir/type.c.o ../plugins/type/CMakeFiles/elektra-type-objects.dir/types.c.o -o ../../bin/testmod_type -Wl,-rpath,/mnt/data/build/lib: ../../lib/libelektra-kdb.so.0.9.10 ../../lib/libelektra-plugin.so.0.9.10 ../../lib/libelektra-meta.so.0.9.10 ../../lib/libelektra-ease.so.0.9.10 ../../lib/libelektra-core.so.0.9.10 -ldl
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../arm-linux-gnueabihf/Scrt1.o: in function `_start':
(.text+0x44): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [src/plugins_tests/CMakeFiles/testmod_type.dir/build.make:114: bin/testmod_type] Error 1
make[2]: Leaving directory '/mnt/data/build'
make[1]: *** [CMakeFiles/Makefile2:14781: src/plugins_tests/CMakeFiles/testmod_type.dir/all] Error 2
System Information
- Elektra: master
The examples notificationPolling and opts has the same problem:
cd /mnt/data/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /mnt/data/libelektra /mnt/data/libelektra/tests/ctest /mnt/data/build /mnt/data/build/tests/ctest /mnt/data/build/tests/ctest/CMakeFiles/test_storage.dir/DependInfo.cmake --color=
/usr/bin/cc -std=gnu99 -Wno-deprecated-declarations -Wstrict-prototypes -Wno-long-long -Wpedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -Wsign-compare -Wfloat-equal -O2 -g -DNDEBUG CMakeFiles/opts.dir/opts.c.o -o ../bin/opts -Wl,-rpath,/mnt/data/build/lib ../lib/libelektra-kdb.so.0.9.10 ../lib/libelektra-core.so.0.9.10 -ldl
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../arm-linux-gnueabihf/Scrt1.o: in function `_start':
(.text+0x44): undefined reference to `main'
Workaround: remove tests from type and internalnotification plugin. For opts commenting out the examples is required.
There is another problem on the weak hardware: the system crashes when compiling the cpp context example/test cases. I excluded these examples/tests now manually.
For reference, here is what I changed to get 0.9.10 compiled/packaged:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34915dcb2..822bb6224 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,7 +124,7 @@ if (BUILD_FULL
endif (BUILD_TESTING)
add_subdirectory (src)
- add_subdirectory (examples)
+ #add_subdirectory (examples)
if (BUILD_TESTING)
add_subdirectory (benchmarks)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index f0e5de999..cbaefcdc4 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -30,7 +30,7 @@ target_link_elektra (kdbintro elektra-kdb)
target_link_elektra (kdbopen elektra-kdb)
target_link_elektra (kdbset elektra-kdb elektra-merge)
target_link_elektra (set_key elektra-kdb)
-target_link_elektra (opts elektra-ease elektra-opts)
+#target_link_elektra (opts elektra-ease elektra-opts)
target_link_elektra (optsCommands elektra-ease elektra-opts)
target_link_elektra (gopts elektra-ease elektra-kdb)
target_link_elektra (goptsCommands elektra-ease elektra-kdb)
diff --git a/src/bindings/cpp/CMakeLists.txt b/src/bindings/cpp/CMakeLists.txt
index 010b92ea7..c172c354e 100644
--- a/src/bindings/cpp/CMakeLists.txt
+++ b/src/bindings/cpp/CMakeLists.txt
@@ -2,10 +2,10 @@ include (LibAddMacros)
add_binding (cpp)
-if (BUILD_TESTING)
- add_subdirectory (tests)
-endif (BUILD_TESTING)
-add_subdirectory (examples)
-add_subdirectory (benchmarks)
+#if (BUILD_TESTING)
+#add_subdirectory (tests)
+#endif (BUILD_TESTING)
+#add_subdirectory (examples)
+#add_subdirectory (benchmarks)
Packaging also fails with the error (many lines snipped, so I give line numbers of build output):
3183 CMake Error at /usr/share/cmake-3.18/Modules/Internal/CPack/CPackDeb.cmake:327 (message):
...
3215 dpkg-shlibdeps: error: cannot find library libelektraintercept-env.so.0
3216 needed by ./usr/local/lib/elektra/tool_exec/test_fork (ELF format:
3217 'elf32-littlearm' abi: '0101002800000000'; RPATH: '')
...
3234 dpkg-shlibdeps: error: cannot find library libelektraintercept-env.so.0
3235 needed by ./usr/local/lib/elektra/tool_exec/test_getenv (ELF format:
3236 'elf32-littlearm' abi: '0101002800000000'; RPATH: '')
...
3266 dpkg-shlibdeps: error: cannot find library libelektraintercept-env.so.0
3267 needed by ./usr/local/lib/elektra/tool_exec/test_context (ELF format:
3268 'elf32-littlearm' abi: '0101002800000000'; RPATH: '')
...
3336 dpkg-shlibdeps: error: cannot continue due to the errors listed above
Removing the binding intercept_env fixes this problem.
I now have working armhf deb for 0.9.10. If anyone is interested I can share them. (No proper repo planned at the moment, first we should fix these build problems.)
A big thanks to @robaerd :sparkling_heart:, cpack turns out to be very useful!
@atmaxinger can you do this? They are needed to make libelektra build on olimex boards. Would be good to fix this for the upcoming release (before new_backend merge).
Sure. Do I build it on the board or cross compile?
Sure.
:sparkling_heart:
Do I build it on the board or cross compile?
I only tried building on the board with the image from Olimex. Cross compilation actually would be much easier for our build servers, as we would not need to integrate this slow hardware.
So I just took the base image from olimex, installed all packages that are described in the bullseye Dockerfile, cloned from master.
cd libelektra
mkdir cmake-build
cd cmake-build
cmake ..
cmake --build . -- -j2
and everything built fine, even testmod_type.
Great news, then it was probably some dependency issue. Did you install all the packages described in the bullseye Dockerfile?
Yes, I executed the following command:
https://github.com/ElektraInitiative/libelektra/blob/5ebc9a4ba5215950f990f7dca948ce310f764079/scripts/docker/debian/bullseye/Dockerfile#L7-L81
One thing I have noticed tho are that sometimes there are random build failures, not always in the same files. And also not really an error regarding syntax or linking. They also disappear when you run the make command again.
For example:
cd /home/olimex/libelektra/cmake-build/tests/kdb && /usr/bin/c++ -DHAVE_KDBCONFIG_H -I/home/olimex/libelektra/cmake-build/src/include -I/home/olimex/libelektra/src/include -I/home/olimex/libelektra/tests/data -I/home/olimex/libelektra/cmake-build/src/bindings/cpp/include -I/home/olimex/libelektra/src/bindings/cpp/include -I/home/olimex/libelektra/cmake-build/src/libs/tools/include -I/home/olimex/libelektra/src/libs/tools/include -I/home/olimex/libelektra/tests/gtest-framework -isystem /include -isystem /home/olimex/libelektra/cmake-build/googletest-src/googletest/include -isystem /home/olimex/libelektra/cmake-build/googletest-src/googletest -std=c++11 -Wno-deprecated-declarations -Wold-style-cast -Wstrict-null-sentinel -D_GLIBCXX_USE_NANOSLEEP -Wno-missing-field-initializers -Woverloaded-virtual -Wsign-promo -Wno-long-long -Wpedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -O2 -g -DNDEBUG -Wno-sign-promo -o CMakeFiles/testkdb_highlevel.dir/testkdb_highlevel.cpp.o -c /home/olimex/libelektra/tests/kdb/testkdb_highlevel.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [src/bindings/swig/python/CMakeFiles/_swig-python-tools.dir/build.make:82: src/bindings/swig/python/CMakeFiles/_swig-python-tools.dir/kdb/toolsPYTHON_wrap.cxx.o] Error 1
make[2]: Leaving directory '/home/olimex/libelektra/cmake-build'
make[1]: *** [CMakeFiles/Makefile2:11716: src/bindings/swig/python/CMakeFiles/_swig-python-tools.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Here it only says
c++: fatal error: Killed signal terminated program cc1plus
As the compilation on the board itself takes somewhere between 30 and 40 minutes, I think it might be related to the hardware. Either the CPU is overheating (as both cores are at 100% for the entire duration) or it runs out of memory and the c++ process is killed.
I will try to use qemu-user-static and the Olimex image in a chroot environment to see if I can reproduce this on my main machine. If not, it's probably hardware related.
Great news, then it was probably some dependency issue.
To me this almost sounds like a weird compiler bug or an issue with the cmake .. flags (you, markus2330, didn't tell us how you set up the build dir). I know "compiler bug" is the last thing you should suspect, but "undefined reference to 'main'" is just a very strange error when main clearly exists in the code and the correct files are included in the linker command. You didn't state compiler (just says /usr/bin/cc) or it's version, so we can't check if there was an issue that has been fixed since July.
Either the CPU is overheating or it runs out of memory
I think out-of-memory is more likely. It would be the first time I hear of a system that doesn't just shutdown when overheating and instead starts killing individual processes.
I'll try building on a Raspberry Pi 4. That's also armhf, but should be more powerful than the Olimex board.
c++: fatal error: Killed signal terminated program cc1plus
I can now confirm that, error is for "out of memory" ;)
I'll try building on a Raspberry Pi 4
I didn't have time to install all the dependencies, but neither type nor internalnotification need any deps. You can see in my cmake.log what parts I compiled. Everything compiled fine (once I increase the swap size to avoid the out-of-memory issue). The OS details are as follows, packages are up-to-date:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
Can also confirm. Let the olimex image run within a chroot and qemu-user-static on my main system, works flawlessly every time (and faster than on the board itself 😂)
Here is a guide using systemd-nspawn for those who are interested: https://www.olimex.com/forum/index.php?topic=2239.0
I retried on a different device and there I can compile Elektra successfully. So it is probably some problem in the local setup. Thank you for your tests! :revolving_hearts: