sqlite3: Always build sqlite3-native with zlib
PATCH 1/1 sqlite3: Always build sqlite3-native with zlib
The build of sqlite3-native is not fully deterministic. There is some corner case as shown with the recent pseudo commit where the sqlite3 will sometimes link against zlib. It is possible that in a build with sstate that since the zlib is not listed, that pseudo-native will fail to build because it calls the pkg-config to get the link arguments for sqlite3 and will ultimately try to link against zlib.
=== As observed on the YP Autobuilder ===
/pseudo-native/1.9.0+gitAUTOINC+060058bb29-r0/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=TOPDIR/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 TOPDIR/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+060058bb29-r0/recipe-sysroot-native/usr/lib/libsqlite3.a -lz -lm -ldl -lpthread -lpthread -ldl -lpthread
TOPDIR//tmp/home/hosttoolspokybuild//yoctold-:worker/ qemuarmcannot/build /buildfind/ tmp/-hosttoolslz/ld : cannot find -lz
======
The simple fix is to depend to the zlib-native which will only impact the sqlite3-native build, and then deterministically complete all the dependencies for pseudo-native. For a target build the host native library is ignored as usual.
--- meta/recipes-support/sqlite/sqlite3.inc | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-support/sqlite/sqlite3.inc +2 -0
@@ -2,6 +2,8 @@ SUMMARY = "Embeddable SQL database engine" HOMEPAGE = "http://www.sqlite.org" SECTION = "libs" +DEPENDS = "zlib-native" + PE = "3" def sqlite_download_version(d):
Signature · 1 line
2.21.0
Quoted 7 lines · Jason Wessel
The build of sqlite3-native is not fully deterministic. There is some corner case as shown with the recent pseudo commit where the sqlite3 will sometimes link against zlib. It is possible that in a build with sstate that since the zlib is not listed, that pseudo-native will fail to build because it calls the pkg-config to get the link arguments for sqlite3 and will ultimately try to link against zlib.
It would be good to dig a little deeper and get to the root cause of why sqlite *sometimes* does it. The fix provided below seems like fixing the symptom, not the problem.
Alex
Quoted 12 lines · Alexander Kanavin
On Tue, 6 Aug 2019 at 19:31, Jason Wessel <[email protected] <mailto:[email protected]>> wrote:
The build of sqlite3-native is not fully deterministic. There is some corner case as shown with the recent pseudo commit where the sqlite3 will sometimes link against zlib. It is possible that in a build with sstate that since the zlib is not listed, that pseudo-native will fail to build because it calls the pkg-config to get the link arguments for sqlite3 and will ultimately try to link against zlib.
Quoted 3 lines
It would be good to dig a little deeper and get to the root cause of why sqlite *sometimes* does it. The fix provided below seems like fixing the symptom, not the problem.
Alex
Without getting access to the build machine where it failed to perform more in depth forensics it is a bit hard to determine the exact cause. I performed some local testing using the Fedora 28 and could not replicate the exact circumstance unless I deleted a file in the sysroot. From what I can tell there are two ways of seeing the problem.
1) Host contamination
% pkg-config sqlite3 --libs --static
-lsqlite3 -lm -ldl -lz -lpthread
This was not the way the sqlite3 was built. However there is no way to know if this was the circumstance without poking around in the log files and re-running the context of the run.do_compile script in the packages temp directory.
2) Dependency race
This is the one where I deleted a file to simulate the problem, but I couldn't reproduce it. For this, we'd really need to look at the failed machine's log of the build of sqlite3, which may be long gone from the sstate. But it should have the pkg-config files laying around. If it shows that it did build against the zlib, but zlib was not listed dependency it was never going to build because the recipe-sysroot-native is not going to have the required library.
There of course might be other ways to end up with the same result but these are the most likely candidates, each of which is fixed by listing the dependency. I too would like to know the actual root cause, but without access to the build it is hard to track it down.
Cheers,
Jason
Quoted 25 lines · Jason Wessel
Quoted 12 lines · Alexander Kanavin
On Tue, 6 Aug 2019 at 19:31, Jason Wessel <[email protected] <mailto:[email protected]>> wrote:
The build of sqlite3-native is not fully deterministic. There is some corner case as shown with the recent pseudo commit where the sqlite3 will sometimes link against zlib. It is possible that in a build with sstate that since the zlib is not listed, that pseudo-native will fail to build because it calls the pkg-config to get the link arguments for sqlite3 and will ultimately try to link against zlib.
Quoted 3 lines
It would be good to dig a little deeper and get to the root cause of why sqlite *sometimes* does it. The fix provided below seems like fixing the symptom, not the problem.
Alex
Without getting access to the build machine where it failed to perform more in depth forensics it is a bit hard to determine the exact cause. I performed some local testing using the Fedora 28 and could not replicate the exact circumstance unless I deleted a file in the sysroot. From what I can tell there are two ways of seeing the problem.
1) Host contamination
% pkg-config sqlite3 --libs --static
-lsqlite3 -lm -ldl -lz -lpthread
Quoted 8 lines
This was not the way the sqlite3 was built. However there is no way to know if this was the circumstance without poking around in the log files and re-running the context of the run.do_compile script in the packages temp directory.
2) Dependency race
This is the one where I deleted a file to simulate the problem, but I couldn't reproduce it. For this, we'd really need to look at the failed machine's log of the build of sqlite3, which may be long gone from the sstate. But it should have the pkg-config files laying around. If it shows that it did build against the zlib, but zlib was not listed dependency it was never going to build because the recipe-sysroot-native is not going to have the required library.
There of course might be other ways to end up with the same result but these are the most likely candidates, each of which is fixed by listing the dependency. I too would like to know the actual root cause, but without access to the build it is hard to track it down.
Just to follow up to be very specific about how I deleted files, you can see the identical failure with:
sudo yum install -y zlib-devel
rm -rf tmp
bitbake -c cleansstate sqlite3-native
bitbake sqlite3-native
sudo yum remove -y zlib-devel
bitbake -c cleansstate pseudo-native
bitbake pseudo-native
I seriously doubt this is exactly what is going on on the host builder which failed. More analysis would be needed as I explained earlier to draw a final conclusion. Either way sqlite3-native should be configured to build consistently, which would prevent this kind of contamination.
Cheers,
Jason.
Quoted 15 lines · Jason Wessel
Just to follow up to be very specific about how I deleted files, you can see the identical failure with:
sudo yum install -y zlib-devel
rm -rf tmpbitbake -c cleansstate sqlite3-native
bitbake sqlite3-native
sudo yum remove -y zlib-devel
bitbake -c cleansstate pseudo-native
Quoted 8 lines
bitbake pseudo-native
I seriously doubt this is exactly what is going on on the host builder which failed. More analysis would be needed as I explained earlier to draw a final conclusion. Either way sqlite3-native should be configured to build consistently, which would prevent this kind of contamination.
This is not quite what I meant. I meant looking at the source code of sqlite, and finding out how exactly it is looking for zlib, and where things might go wrong (e.g. host contamination, or other possible causes of non-determinism). There might be a configure switch to control that behavior, or something similar that we can use to achieve deterministic builds.
Alex
Quoted 17 lines · Alexander Kanavin
On Tue, 6 Aug 2019 at 20:52, Jason Wessel <[email protected] <mailto:[email protected]>> wrote:
Just to follow up to be very specific about how I deleted files, you can see the identical failure with:
sudo yum install -y zlib-devel
rm -rf tmp
bitbake -c cleansstate sqlite3-native
bitbake sqlite3-native
sudo yum remove -y zlib-devel
bitbake -c cleansstate pseudo-native
Quoted 8 lines
bitbake pseudo-native
I seriously doubt this is exactly what is going on on the host builder which failed. More analysis would be needed as I explained earlier to draw a final conclusion. Either way sqlite3-native should be configured to build consistently, which would prevent this kind of contamination.
This is not quite what I meant. I meant looking at the source code of sqlite, and finding out how exactly it is looking for zlib, and where things might go wrong (e.g. host contamination, or other possible causes of non-determinism). There might be a configure switch to control that behavior, or something similar that we can use to achieve deterministic builds.
Sqlite3 doesn't have a an explicit disable. It has the typical autoconf check for a header/library. From configure.ac:
AC_CHECK_HEADERS(zlib.h,[ AC_SEARCH_LIBS(deflate,z,[BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_HAVE_ZLIB"]) ])
This means it would need to be patched if you want to make it a pkgconfig option, or play games with the configure cache values... I chose zlib as a default dependency because it was the easiest to implement. If we really want to make it not build with zlib or build it conditionally, it is certainly possible. Is that what is needed to get this patch accepted?
Jason.
Quoted 10 lines · Jason Wessel
Sqlite3 doesn't have a an explicit disable. It has the typical autoconf check for a header/library. From configure.ac:
AC_CHECK_HEADERS(zlib.h,[
AC_SEARCH_LIBS(deflate,z,[BUILD_CFLAGS="$BUILD_CFLAGS
-DSQLITE_HAVE_ZLIB"])
])
Quoted 6 lines
This means it would need to be patched if you want to make it a pkgconfig option, or play games with the configure cache values... I chose zlib as a default dependency because it was the easiest to implement. If we really want to make it not build with zlib or build it conditionally, it is certainly possible. Is that what is needed to get this patch accepted?
I'd say if you adjust the patch to work for both native and target variants and always build with zlib, that should be fine.
Alex