Skip to contentSkip to conversation

Make NO32LIBS=0 more an order than a suggestion

PATCH New Peter Seebach 1 participant 2 messages Jul 26, 2013

lore
Share & tools
lore
#0 lore raw

cover Make NO32LIBS=0 more an order than a suggestion

The NO32LIBS hackery replaced an attempt to discern whether we could likely build a 32-bit libpseudo.so, and for some use cases such as external toolchains, we sometimes wish to *require* a 32-bit libpseudo.so. Unfortunately, NO32LIBS=0 doesn't do that; it just means that we'll try to build it if we happen to find stubs-32.h and think it'll work.

Change this so that NO32LIBS=0 makes the build mandatory, and also add a couple of diagnostics to increase the chances that people being bitten by this will find out why. In particular, this should reduce the incidence of people who are using external toolchains and failing to get a 32-bit libpseudo, resulting in pseudo database corruption with no obvious explanation, and a flood of "failed to load libpseudo.so" messages.

NOTE: This has been tested some, but the pool of possible ways these tests could fail is large, so it's probably worth giving this some soak time, or trying it on various machines, before assuming it'll work consistently. It will likely expose at least one failure which was actually a misconfigured host that simply happened to be avoiding getting caught.

The following changes since commit ac5d20f4adac69ea1702694fb50849c9e465b443:

systemd: Remove systemd_unitdir if systemd is not in distro features (2013-07-23 07:49:54 -0700)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib seebs/no32libs
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/no32libs

Peter Seebach (1):
Always try to build 32-bit libpseudo when NO32LIBS is set to 0

 meta/recipes-devtools/pseudo/pseudo.inc | 50 +++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3
#1 lore raw

PATCH 1/1 Always try to build 32-bit libpseudo when NO32LIBS is set to 0

This is for Yocto bug #4920. The NO32LIBS variable is intended to allow the user to force the creation of a 32-bit libpseudo, for use with things like prebuilt binary toolchains. Unfortunately, the tests for likely compilability (stubs-32.h) were still present, so you would get silent failures. And if you did cause it to try to build, the failures were not particularly clearly explained.

So, we:
1. Emit at least a message during configuration saying we're only building 64-bit, if we are.
2. Warn the user for at least one common case where we know builds are likely to fail.
3. If NO32LIBS is 0, we try the compile for sure, and if it fails, we've emitted at least some sort of message up near the top of the compile output that tells you what might be wrong.

---
 meta/recipes-devtools/pseudo/pseudo.inc | 50 +++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 9 deletions(-)
meta/recipes-devtools/pseudo/pseudo.inc +41 -9
index 3baf3af..5451aa2 100644
@@ -37,14 +37,44 @@ do_compile () {
 	oe_runmake ${MAKEOPTS}
 }
 
+maybe_make32() {
+	# We probably don't need to build 32-bit binaries.
+	make32=false
+	if [ "${SITEINFO_BITS}" = "64" ]; then
+		case "${NO32LIBS}" in
+		0)	make32=true
+			;;
+		1)	make32=false
+			;;
+		*)	# If unset, build 32-bit if we think we can.
+			if [ -e "/usr/include/gnu/stubs-32.h" ]; then
+				make32=true
+			fi
+			;;
+		esac
+	fi
+	if $make32; then
+		if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then
+			echo >&2 "WARNING: Can't find stubs-32.h, but usually need it to build 32-bit libpseudo."
+			echo >&2 "If the build fails, install 32-bit developer packages."
+			echo >&2 "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional."
+		else
+			echo "Attempting to build 32-bit libpseudo.so for ${PN}."
+		fi
+	else
+		echo "Building/installing only 64-bit libpseudo.so for ${PN}."
+		echo "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0."
+	fi
+}
+
 # Two below are the same
 # If necessary compile for the alternative machine arch.  This is only 
 # necessary in a native build.
 do_compile_prepend_class-native () {
-	if [ "${SITEINFO_BITS}" = "64" -a -e "/usr/include/gnu/stubs-32.h" -a "${PN}" = "pseudo-native" -a "${NO32LIBS}" != "1" ]; then
+	maybe_make32
+	if $make32; then
 		# We need the 32-bit libpseudo on a 64-bit machine...
-                # ... and we really, really, hope that the native host is
-                # x86, or else --bits may not work.
+		# Note that this is not well-tested outside of x86/x86_64.
 
 		# if we're being rebuilt due to a dependency change, we need to make sure
 		# everything is clean before we configure and build -- if we haven't previously
@@ -59,10 +89,10 @@ do_compile_prepend_class-native () {
 }
 
 do_compile_prepend_class-nativesdk () {
-	if [ "${SITEINFO_BITS}" = "64" -a -e "/usr/include/gnu/stubs-32.h" -a "${PN}" = "pseudo-native" -a "${NO32LIBS}" != "1" ]; then
-		# We need the 32-bit libpseudo on a 64-bit machine...
-                # ... and we really, really, hope that the native host is
-                # x86, or else --bits may not work.
+	maybe_make32
+	if $make32; then
+		# We need the 32-bit libpseudo on a 64-bit machine.
+		# Note that this is not well-tested outside of x86/x86_64.
 		./configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --bits=32 --without-rpath
 		oe_runmake ${MAKEOPTS} libpseudo
 		# prevent it from removing the lib, but remove everything else
@@ -78,14 +108,16 @@ do_install () {
 # If necessary install for the alternative machine arch.  This is only 
 # necessary in a native build.
 do_install_append_class-native () {
-	if [ "${SITEINFO_BITS}" = "64" -a -e "/usr/include/gnu/stubs-32.h" -a "${PN}" = "pseudo-native" -a "${NO32LIBS}" != "1" ]; then
+	maybe_make32
+	if $make32; then
 		mkdir -p ${D}${prefix}/lib/pseudo/lib
 		cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
 	fi
 }
 
 do_install_append_class-nativesdk () {
-	if [ "${SITEINFO_BITS}" = "64" -a -e "/usr/include/gnu/stubs-32.h" -a "${PN}" = "pseudo-native" -a "${NO32LIBS}" != "1" ]; then
+	maybe_make32
+	if $make32; then
 		mkdir -p ${D}${prefix}/lib/pseudo/lib
 		cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
 	fi
Signature · 1 line
1.8.3