AOSP native code coverage issue, gcno:version '402*', prefer 'a75*' on soong build system - code-coverage

I am working on native code coverage for AOSP11, I am referring following links.
Native Code coverage with android soong build system
Android Native Unit test Coverage for cpp via gcov and lcov
I have generated *.gcno and also genrated *.gcov, but after running
lcov --directory . --base-directory . --gcov-tool /usr/bin/gcov --capture -o cov.info .gcno
to collect the code coverage results, I am getting version mismatch issue, i.e.
gcno:version '402', prefer 'a75'
So I checked, and can see my host machine's gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) and gcov version (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0. And I ran "file *.gcno" (on generated *.gcno intermediates). Its printing GCC--> gcno coverage (-ftest-coverage), version 4.2 So, root cause is quite clear, but how to resolve this for Soong build system?

Related

Using ZMQ on iOS

I am trying to build an iOS app that is exposed to a fairly extensive Rust project, but I am having issues with one of the dependencies in the project. The Rust project has a ZMQ dependency, and while I am able to build the project on my Mac, when I try to incorporate the Rust project I get the following error:
error: failed to run custom build command for `zmq-sys v0.8.3`
Caused by:
process didn't exit successfully: `/Users/lisa/company/project/project_detail/target/debug/build/zmq-sys-16dfc88dff84d855/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZMQ_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'Unable to locate libzmq:
pkg-config has not been configured to support cross-compilation.
Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via
PKG_CONFIG environment variable.', /Users/lisa/.cargo/registry/src/github.com-1ecc6299db9ec823/zmq-sys-0.8.3/build.rs:31:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
I am trying to build the appropriate library for the iOS and iOS simulator architectures without relying on pkg-config, but if someone can provide useful instructions for configuring pkg-config for cross-compilation, I am not opposed to it, I just don't know how and can't find any up to date resources.
I have cloned the libzmq project from this github: https://github.com/zeromq/libzmq.git, then navigate into libzmq.
Inside libzmq, I run ./autogen.sh followed by ./configure --prefix [directory location] --target "aarch64-apple-ios", then make and make install.
The above procedure without the --target flag is how I got the project to compile on my Mac in the first place, and with the target flag in place make and make install both complete successfully, but when I try to build the project using PROJECT_DIR="${PWD}/ProjectName" ./ProjectName/build-rust.sh,
I get the previously posted error.
I am following the Swift-Bridge Book (https://chinedufn.github.io/swift-bridge/building/xcode-and-cargo/index.html) to try to load the Rust libraries into Xcode.
One thing to note: In the libzmq git hub, there is a folder called builds/ios/ and inside this folder is what looks to be a build file for all of the iOS archs, but I haven't been able to get the repo to build with that file. I think figuring out how to use the build_ios.sh build file as opposed to the standard build.sh provided might be the answer, but I've tried dropping build_ios.sh where build.sh is, and ./autogen.sh doesn't work, because it complains that it can't find configure.ac, even though this file does exist.

Jenkins does not work properly on Mac M1 agent

We want to use a Mac Mini with the M1 processor as an agent in our CI pipeline to make sure that developers with new Macs can compile the project. We duplicated the setup that we have for x86, but cmake cannot find libraries such as boost:
CMake Error at /opt/homebrew/Cellar/cmake/3.19.7/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR container system
date_time)
Weirdly, this is not an issue when connecting to the machine directly via ssh. Even manually setting the environment variables does not change anything.
The Jenkins agent uses Java. If you install Java via brew (e.g., adoptopenjdk8), you might get an x64 version (as of March 2021) that is run using the Rosetta translation layer. You can verify this by executing sysctl sysctl.proc_translated. In the "normal" SSH connection, this should return 0, when executed as sh "sysctl sysctl.proc_translated" in Jenkins, you will see a 1.
Preferred Option (install native JDK)
Instead of using, e.g., adoptopenjdk8, you can install the zulu JDK, which is available natively, via
brew install --cask zulu
After this, you should be able to verify that proc_translated is 0 within Jenkins. You can verify that a native binary is built as described below.
Hotfix (without changing the JDK)
The following is a hotfix if you cannot install a native JDK.
We were able to force cmake to run natively (and thus to find the native libraries) by modifying our Jenkinsfile as follows:
old:
sh "cmake .."
sh "make hyriseTest"
new:
sh "PATH=/opt/homebrew/bin:$PATH arch -arm64 cmake .."
sh "arch -arm64 make hyriseTest"
Having to repeat the arch command over and over is not really pretty. Maybe someone has a better solution.
Verification of the result
We can verify that our generated binary is a native ARM binary:
sh "file hyriseTest"
Result:
+ file ./hyriseTest
./hyriseTest: Mach-O 64-bit executable arm64
Compiler warnings
Note: We are still seeing linker warnings about "ltmp3" and "ltmp4". I have not found any information about that online and it does not seem to affect the correctness of the result. Example:
ld: warning: direct access in function 'ltmp4' from file 'CMakeFiles/hyriseMvccDeletePlugin.dir/Unity/unity_0_cxx.cxx.o' to global weak symbol

NIST(National Institute of Standards and Technology) library for iOS

I downloaded some code which contains some source code and some txt files.
The Read me or Installation file says following,
NBIS Open Source Software Installation Guide
(For LINUX and MAC OSX)
----------------------------------------------
Step 1:
Run the following command to setup your build environment:
./setup.sh <TARGET INSTALLATION DIR> [--without-X11]
[--STDLIBS] [--without-OPENJP2] [--32 | --64]
<TARGET INSTALLATION DIR> is replaced by the specific directory path
where you want to install the NBIS applications, libraries,
pre-computed runtime data and manuals.
Option Usage :
--without-X11 Build without X11 support.
--STDLIBS Build without JASPER, OpenJP2 and PNG
image format support.
--without-OPENJP2 Build without OpenJP2 image format
support.
--32 Build on 32-bit architecture machine.
(Only applicable for LINUX build.
If you are compiling on a 64-bit
machine, please have the proper
32-bit libraries installed.)
--64 Build on 64-bit architecture machine
(Only applicable for LINUX build.)
Example:
> ./setup.sh /SRC/NBIS/Main --32
Step 2:
Run the following commands to build "NBIS":
make config
make it
Step 3:
Run the following command to install NBIS executables into the
directory:
make install LIBNBIS=[yes|no]
Step 4: (OPTIONAL)
Run the following command, if you want to generate a list of
API supported in NBIS.
make catalog
Note: If you enable the "LIBNBIS=no" option during make install,
it will create the following libraries:
liban2k.a libclapck.a libfft.a libioutil.a libmindtct.a
libnfseg.a libpcautil.a libutil.a libbozorth3.a libf2c.a
libihead.a libjpegb.a libmlp.a libopenjp2.a libpcax.a
libwsq.a libcblas.a libfet.a libimage.a libjpegl.a libnfiq.a
libpca.a libpng.a libz.a
If you enable the "LIBNBIS=yes" option during make install, it will
combine all the libraries listed above and build libnbis.a.
Can I use the library build using above in my xCode project for iOS.
Thank You,
Subhash

Clang Code Coverage Invalid Output

So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html. I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file".
Now I'm stuck and came to SO to look for help :)
I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference.
I had the same problem with clang with lcov on Ubuntu 13.04.
Here is the solution which worked for me on more than one Ubuntu setup.
You will find there are two versions of gcov on Ubuntu. gcov-4.6.4 & gcov-4.7.3. By default the gcov link is set to gcov-4.7.3. Change that to gcov-4.6.4
Furthermore, use lcov version 1.10 instead of what is available via apt-get install
This should generate the code coverage report.
EDIT: Mine was a upgrade from Ubuntu 12.04 to 13.04. Just in case you don't see two versions of gcov.
Just summarising the steps for the answer already shared by #Himanshu in case somebody's looking for the exact steps to go about it:
Install gcc 4.6
sudo apt-get-install -y gcc-4.6
I couldn’t find locv 1.10 version out of the box so I compiled it myself:
git clone https://github.com/linux-test-project/lcov.git
cd lcov
Switch to a new branch with the commit that published lcov 1.10 version as base
git checkout -b 1_10 b5c1bdd
Compile lcov
sudo make install
Confirm that lcov installed is 1.10
lcov --version
With all these things in place, use the command:
lcov --gcov-tool /usr/bin/gcov-4.6 --capture -d gcov_data/ -o gcov_data/coverage.info
This avoids tinkering with the link of the default gcov on the system.
Then generate the visual coverage file
genhtml -o gcov_data/html gcov_data/coverage.info
where gcov_data is the folder containing the gcno and gcda files.

Compiling Qt for iOS (UIKit lighthouse) part 2

I'm trying to compile Qt for the iOS simulator, as explained in this article.
At first I ran into this problem but after it (kinda) solved itself I had some more.
First I kept getting this error after executing the first command, which is supposed to build qmake (../qt/configure ... etc etc):
The OpenGL ES 2.0 functionality test failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in /Qt/qt/mkspecs/qpa/macx-iphonesimulator-g++.
Since I knew that I had the 4.3 SDK, I delved into it some more, analyzed the configure script, and after some tracing I saw that the Makefile generated by qmake, required g++-4.2 (which I didn't have), so I just ln -s g++ g++-4.2 and ln -s gcc gcc-4.2 in /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/.
I'm not sure if the aforementioned steps matter, that's why I'm writing about them. Anyway, with that, the configure step was successful. Now I ran make. After some successfully compiled files I got this:
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/WebServicesCore.framework/Headers/WebServicesCore.h:15,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:37,
from ../../include/QtCore/private/../../../../qt/src/corelib/kernel/qcore_mac_p.h:83,
from ../../include/QtCore/private/qcore_mac_p.h:1,
from /Qt/qt/src/corelib/tools/qlocale_mac.mm:49:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/WebServicesCore.framework/Headers/WSMethodInvocation.h:759:
error: 'CFXMLTreeRef' has not been declared
The same error appears several more times, from several different lines of WebServicesCore.h. So, basically, here's where I'm stuck now.
Any help? Again?...
Edit: Absolutely, 100% the same thing happens when I configure and try to make Qt for the device (as opposed to the simulator)
Additional info:
gcc --version : i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
iOS SDK: I have both 4.3 and 5
OS X version: 10.7.2
Xcode version (if it matters): 4.2.1
Didn't you forget to add -nomake tools and other -nomake ... to your configure ?
Try poking this guys: http://labs.qt.nokia.com/2011/08/09/update-on-uikit-lighthouse-platform/

Resources