Skip to contentSkip to conversation

sanity.bbclass: Toolchain sanity checks

PATCH Superseded Peter Seebach 2 participants 4 messages Apr 28, 2012 – May 1, 2012

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover sanity.bbclass: Toolchain sanity checks

This is a somewhat cleaned up and fixed version of the toolchain sanity checks I've been working on. (Also my first attempt to submit to OE, so I have probably made humorous mistakes.)

Big outstanding issue: Is it a bug that specifying the name "lib" for a multilib causes parse errors in at least one package? If this is a package bug, I should find out how to fix the package(s) (libxcb blew up for me) instead of making that check for multilibs.

Other issue: The TUNEABI stuff is preliminary, and I'm not totally sure whether it will work in practice. But it won't break anything unless you go out of your way to enable it.

Mark Hatle's already been over this once, but second opinions are always welcome.

The following changes since commit 5a1f172d35be610688842a8a9a84f24edb9aeb51:
Martin Jansa (1):
bitbake.conf: use TUNE_PKGARCH instead of TARGET_ARCH in SDK_NAME

are available in the git repository at:

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

Peter Seebach (2):
tune-sh4.inc: Fix spelling of big-endian feature set sanity.bbclass: Implement initial toolchain sanity checks

 meta/classes/sanity.bbclass                      |   69 ++++++++++++++++++++++
 meta/conf/documentation.conf                     |    6 ++
 meta/conf/machine/include/README                 |    4 +
 meta/conf/machine/include/arm/arch-armv5-dsp.inc |    1 +
 meta/conf/machine/include/arm/arch-armv7a.inc    |    2 +-
 meta/conf/machine/include/ia32/arch-ia32.inc     |    2 +-
 meta/conf/machine/include/mips/arch-mips.inc     |    6 +-
 meta/conf/machine/include/tune-c3.inc            |    2 +-
 meta/conf/machine/include/tune-sh3.inc           |    2 +-
 meta/conf/machine/include/tune-sh4.inc           |    4 +-
 meta/conf/machine/include/tune-xscale.inc        |    2 +-
 11 files changed, 90 insertions(+), 10 deletions(-)
#1 lore raw

PATCH 1/2 tune-sh4.inc: Fix spelling of big-endian feature set

In tune-sh3, tune-xscale, and tune-sh4, several FEATURES lines referred to nonexistent features like "sh3eb" when they should have referred to "sh3 bigendian" or the like. Caught by the TUNEVALID sanity check.

---
 meta/conf/machine/include/tune-sh3.inc    |    2 +-
 meta/conf/machine/include/tune-sh4.inc    |    4 ++--
 meta/conf/machine/include/tune-xscale.inc |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
meta/conf/machine/include/tune-sh3.inc +1 -1
index 816c9c4..70bb10b 100644
@@ -11,7 +11,7 @@ TUNE_ARCH_tune-sh3 = "sh3"
 TUNE_PKGARCH_tune-sh3 = "sh3"
 PACKAGE_EXTRA_ARCHS_tune-sh3 = "sh sh3"
 
-TUNE_FEATURES_tune-sh3eb = "sh3eb"
+TUNE_FEATURES_tune-sh3eb = "sh3 bigendian"
 TUNE_ARCH_tune-sh3eb = "sh3eb"
 TUNE_PKGARCH_tune-sh3eb = "sh3eb"
 PACKAGE_EXTRA_ARCHS_tune-sh3eb = "sheb sh3eb"
meta/conf/machine/include/tune-sh4.inc +2 -2
index f971f23..00cfc3d 100644
@@ -18,7 +18,7 @@ TUNE_ARCH_tune-sh4 = "sh4"
 TUNE_PKGARCH_tune-sh4 = "sh4"
 PACKAGE_EXTRA_ARCHS_tune-sh4 = "sh sh4"
 
-TUNE_FEATURES_tune-sh4eb = "sh4eb"
+TUNE_FEATURES_tune-sh4eb = "sh4 bigendian"
 TUNE_ARCH_tune-sh4eb = "sh4eb"
 TUNE_PKGARCH_tune-sh4eb = "sh4eb"
 PACKAGE_EXTRA_ARCHS_tune-sh4eb = "sheb sh4eb"
@@ -28,7 +28,7 @@ TUNE_ARCH_tune-sh4a = "sh4"
 TUNE_PKGARCH_tune-sh4a = "sh4a"
 PACKAGE_EXTRA_ARCHS_tune-sh4a = "sh sh4 sh4a"
 
-TUNE_FEATURES_tune-sh4aeb = "sh4aeb"
+TUNE_FEATURES_tune-sh4aeb = "sh4a bigendian"
 TUNE_ARCH_tune-sh4aeb = "sh4eb"
 TUNE_PKGARCH_tune-sh4aeb = "sh4aeb"
 PACKAGE_EXTRA_ARCHS_tune-sh4aeb = "sheb sh4eb sh4aeb"
meta/conf/machine/include/tune-xscale.inc +1 -1
index 54f3727..80a3683 100644
@@ -10,7 +10,7 @@ TUNE_FEATURES_tune-xscale = "${TUNE_FEATURES_tune-armv5te} xscale"
 PACKAGE_EXTRA_ARCHS_tune-xscale = "${PACKAGE_EXTRA_ARCHS_tune-armv5te}"
 
 AVAILTUNES += "xscale-be"
-TUNE_FEATURES_tune-xscale-be = "${TUNE_FEATURES_tune-armv5teb} xscale-be"
+TUNE_FEATURES_tune-xscale-be = "${TUNE_FEATURES_tune-armv5teb} xscale bigendian"
 PACKAGE_EXTRA_ARCHS_tune-xscale-be = "${PACKAGE_EXTRA_ARCHS_tune-armv5teb}"
 
 # webkit-gtk has alignment issues with double instructions on armv5 so
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 1/2] tune-sh4.inc: Fix spelling of big-endian feature set

Quoted 51 lines · Peter Seebach

In tune-sh3, tune-xscale, and tune-sh4, several FEATURES lines referred to nonexistent features like "sh3eb" when they should have referred to "sh3 bigendian" or the like. Caught by the TUNEVALID sanity check.

---
  meta/conf/machine/include/tune-sh3.inc    |    2 +-
  meta/conf/machine/include/tune-sh4.inc    |    4 ++--
  meta/conf/machine/include/tune-xscale.inc |    2 +-
  3 files changed, 4 insertions(+), 4 deletions(-)
meta/conf/machine/include/tune-sh3.inc +1 -1
index 816c9c4..70bb10b 100644
@@ -11,7 +11,7 @@ TUNE_ARCH_tune-sh3 = "sh3"
  TUNE_PKGARCH_tune-sh3 = "sh3"
  PACKAGE_EXTRA_ARCHS_tune-sh3 = "sh sh3"
 
-TUNE_FEATURES_tune-sh3eb = "sh3eb"
+TUNE_FEATURES_tune-sh3eb = "sh3 bigendian"
  TUNE_ARCH_tune-sh3eb = "sh3eb"
  TUNE_PKGARCH_tune-sh3eb = "sh3eb"
  PACKAGE_EXTRA_ARCHS_tune-sh3eb = "sheb sh3eb"
meta/conf/machine/include/tune-sh4.inc +2 -2
index f971f23..00cfc3d 100644
@@ -18,7 +18,7 @@ TUNE_ARCH_tune-sh4 = "sh4"
  TUNE_PKGARCH_tune-sh4 = "sh4"
  PACKAGE_EXTRA_ARCHS_tune-sh4 = "sh sh4"
 
-TUNE_FEATURES_tune-sh4eb = "sh4eb"
+TUNE_FEATURES_tune-sh4eb = "sh4 bigendian"
  TUNE_ARCH_tune-sh4eb = "sh4eb"
  TUNE_PKGARCH_tune-sh4eb = "sh4eb"
  PACKAGE_EXTRA_ARCHS_tune-sh4eb = "sheb sh4eb"
@@ -28,7 +28,7 @@ TUNE_ARCH_tune-sh4a = "sh4"
  TUNE_PKGARCH_tune-sh4a = "sh4a"
  PACKAGE_EXTRA_ARCHS_tune-sh4a = "sh sh4 sh4a"
 
-TUNE_FEATURES_tune-sh4aeb = "sh4aeb"
+TUNE_FEATURES_tune-sh4aeb = "sh4a bigendian"
  TUNE_ARCH_tune-sh4aeb = "sh4eb"
  TUNE_PKGARCH_tune-sh4aeb = "sh4aeb"
  PACKAGE_EXTRA_ARCHS_tune-sh4aeb = "sheb sh4eb sh4aeb"
meta/conf/machine/include/tune-xscale.inc +0 -0
index 54f3727..80a3683 100644

meta/conf/machine/include/tune-xscale.inc TUNE_FEATURES_tune-xscale = "${TUNE_FEATURES_tune-armv5te} xscale" · line 16

Quoted 8 lines
meta/conf/machine/include/tune-xscale.inc +1 -1
@@ -10,7 +10,7 @@ TUNE_FEATURES_tune-xscale = "${TUNE_FEATURES_tune-armv5te} xscale"
  PACKAGE_EXTRA_ARCHS_tune-xscale = "${PACKAGE_EXTRA_ARCHS_tune-armv5te}"
 
  AVAILTUNES += "xscale-be"
-TUNE_FEATURES_tune-xscale-be = "${TUNE_FEATURES_tune-armv5teb} xscale-be"
+TUNE_FEATURES_tune-xscale-be = "${TUNE_FEATURES_tune-armv5teb} xscale bigendian"
  PACKAGE_EXTRA_ARCHS_tune-xscale-be = "${PACKAGE_EXTRA_ARCHS_tune-armv5teb}"
 
  # webkit-gtk has alignment issues with double instructions on armv5 so

Merged this patch into OE-Core

Thanks
Sau!

#3 lore raw

PATCH 2/2 sanity.bbclass: Implement initial toolchain sanity checks

In reply to Peter Seebach

This introduces a sanity check for the toolchain, which verifies each tuning (including any multilibs), producing meaningful diagnostics for problems, and also provides some higher-level tuning features.

The TUNEVALID and TUNECONFLICT/TUNECONFLICTS settings were not implemented, and there were some loose ends (like not knowing how the conflict one was spelled). Listed one or two missing features in TUNEVALID, also (in a previous patch) fixed the references to features which didn't exist.

This patch also provides a whitelisting mechanism (which is completely unused) to allow vendors providing prebuilt toolchain components to restrict tunings to those based on or compatible with a particular ABI.

---
 meta/classes/sanity.bbclass                      |   69 ++++++++++++++++++++++
 meta/conf/documentation.conf                     |    6 ++
 meta/conf/machine/include/README                 |    4 +
 meta/conf/machine/include/arm/arch-armv5-dsp.inc |    1 +
 meta/conf/machine/include/arm/arch-armv7a.inc    |    2 +-
 meta/conf/machine/include/ia32/arch-ia32.inc     |    2 +-
 meta/conf/machine/include/mips/arch-mips.inc     |    6 +-
 meta/conf/machine/include/tune-c3.inc            |    2 +-
 8 files changed, 86 insertions(+), 6 deletions(-)
meta/classes/sanity.bbclass +69 -0
index 687ddeb..ff11fec 100644
@@ -11,6 +11,72 @@ def raise_sanity_error(msg):
     
     %s""" % msg)
 
+# Check a single tune for validity.
+def check_toolchain_tune(data, tune, multilib):
+    tune_errors = []
+    if not tune or tune == "":
+        return "No tuning found for %s multilib." % multilib
+    bb.note("Sanity-checking tuning '%s' (%s) features:" % (tune, multilib))
+    features = data.getVar("TUNE_FEATURES_tune-%s" % tune, True) or ""
+    if features == '':
+        return "Tuning '%s' has no defined features, and cannot be used." % tune
+    features = features.split()
+    valid_tunes = data.getVarFlags('TUNEVALID') or ""
+    conflicts = data.getVarFlags('TUNECONFLICTS') or ""
+    split_conflicts = {}
+    for feature in features:
+        if feature in conflicts:
+            if feature not in split_conflicts:
+                split_conflicts[feature] = conflicts[feature].split()
+            for other in features:
+                if other in split_conflicts[feature]:
+                    tune_errors.append("Feature '%s' conflicts with '%s'." %
+                        ( feature, other ))
+        if feature in valid_tunes:
+            bb.note("  %s: %s" % (feature, valid_tunes[feature]))
+        else:
+            tune_errors.append("Feature '%s' is not defined." % feature)
+    whitelist = data.getVar("TUNEABI_WHITELIST", True) or ''
+    if whitelist != '':
+        override = data.getVar("TUNEABI_OVERRIDE", True) or ''
+        if not override:
+            tuneabi = data.getVar("TUNEABI_tune-%s" % tune, True) or ""
+            if tuneabi == "":
+                tuneabi = tune
+            if True not in [x in whitelist.split() for x in tuneabi.split()]:
+                tune_errors.append("Tuning '%s' (%s) cannot be used with any supported tuning/ABI." %
+                    (tune, tuneabi))
+    if tune_errors:
+        return "Tuning '%s' has the following errors:\n" + '\n'.join(tune_errors)
+
+def check_toolchain(data):
+    tune_error_set = []
+    deftune = data.getVar("DEFAULTTUNE", True)
+    tune_errors = check_toolchain_tune(data, deftune, 'default')
+    if tune_errors:
+        tune_error_set.append(tune_errors)
+
+    multilibs = data.getVar("MULTILIBS", True) or ""
+    if multilibs != "":
+        for pairs in [x.split(':') for x in multilibs.split()]:
+            if pairs[0] != 'multilib':
+                bb.warn("Got an unexpected '%s' in MULTILIBS." % pairs[0])
+            else:
+                if pairs[1] == 'lib':
+                    tune_error_set.append("The multilib 'lib' was specified, but that causes parse errors.")
+                else:
+                    tune = data.getVar("DEFAULTTUNE_virtclass-multilib-%s" % pairs[1], True)
+                    if tune == deftune:
+                        bb.warn("Multilib '%s' (%s) is also the default tuning." % (pairs[1], deftune))
+                    else:
+                        tune_errors = check_toolchain_tune(data, tune, pairs[1])
+                    if tune_errors:
+                        tune_error_set.append(tune_errors)
+    if tune_error_set:
+        return "Toolchain tunings invalid:\n" + '\n'.join(tune_error_set)
+
+    return ""
+
 def check_conf_exists(fn, data):
     bbpath = []
     fn = data.expand(fn)
@@ -327,6 +393,9 @@ def check_sanity(e):
         messages = messages + pseudo_msg + '\n'
 
     check_supported_distro(e)
+    toolchain_msg = check_toolchain(e.data)
+    if toolchain_msg != "":
+        messages = messages + toolchain_msg + '\n'
 
     # Check if DISPLAY is set if IMAGETEST is set
     if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu':
meta/conf/documentation.conf +6 -0
index f4d6241..f41c79f 100644
@@ -34,6 +34,12 @@ TARGET_CC_ARCH[doc] = "FIXME"
 TARGET_FPU[doc] = "Floating point option (mostly for FPU-less systems), can be 'soft' or empty \
 for hardware floating point instructions."
 
+# WARNING:  Because the flags on these have semantic implecations,
+# they must not actually be defined.
+#TUNEVALID[doc] = "Descriptions of valid tuning features, stored as flags."
+#TUNEVALID[doc] = "List of conflicting features for a given feature."
+TUNEABI[doc] = "A base ABI used by a given tuning, used with prebuilt binaries."
+
 ASSUME_PROVIDED[doc] = "List of packages (recipes actually) which are assumed to be implicitly available.\
  These packages won't be built by bitbake."
 ASSUME_SHLIBS[doc] = "List of shlib:package[_version] mappings. Useful for lib packages in ASSUME_PROVIDED,\
meta/conf/machine/include/README +4 -0
index 6a3a63d..e4b59c9 100644
@@ -24,6 +24,10 @@ TUNEVALID[feature] - The <feature> is defined with a human readable
 explanation for what it does.  All architectural, cpu, abi, etc tuning 
 features must be defined using TUNEVALID.
 
+TUNECONFLICTS[feature] - A list of features which conflict with <feature>.
+New sanity checks will try to reject combinations in which a single
+tuning ends up with features which conflict with each other.
+
 TUNE_FEATURES - This is automatically defined as TUNE_FEATURES_tune-<tune>.
 See TUNE_FEATURES_tune-<tune> for more information.
 
meta/conf/machine/include/arm/arch-armv5-dsp.inc +1 -0
index 9f03a0f..0f64562 100644
@@ -1,4 +1,5 @@
 ARMPKGSFX_DSP = "${@bb.utils.contains("TUNE_FEATURES", [ "armv5", "dsp" ], "e", "", d)}"
+TUNEVALID[dsp] = "ARM DSP functionality"
 
 require conf/machine/include/arm/arch-armv5.inc
 
meta/conf/machine/include/arm/arch-armv7a.inc +1 -1
index 629960d..c90aff5 100644
@@ -2,7 +2,7 @@ DEFAULTTUNE ?= "armv7a"
 
 ARMPKGARCH ?= "armv7a"
 
-TUNEVALID[armv7-a] = "Enable instructions for ARMv7-a"
+TUNEVALID[armv7a] = "Enable instructions for ARMv7-a"
 TUNE_CONFLICTS[armv7a] = "armv4 armv5 armv6 armv7"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "armv7a", "-march=armv7-a -fno-tree-vectorize", "", d)}"
 MACHINEOVERRIDES .= "${@bb.utils.contains("TUNE_FEATURES", "armv7a", ":armv7a", "" ,d)}"
meta/conf/machine/include/ia32/arch-ia32.inc +1 -1
index a5dae88..15f67d7 100644
@@ -27,7 +27,7 @@ TUNE_ASARGS += "${@bb.utils.contains("TUNE_FEATURES", "mx32", "-x32", "", d)}"
 
 # ELF64 ABI
 TUNEVALID[m64] = "IA32e (x86_64) ELF64 standard ABI"
-TUNECONFLICT[m64] = "m32 mx32"
+TUNECONFLICTS[m64] = "m32 mx32"
 TUNE_ARCH .= "${@bb.utils.contains("TUNE_FEATURES", "m64", "${X86ARCH64}", "" ,d)}"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "m64", "-m64", "", d)}"
 
meta/conf/machine/include/mips/arch-mips.inc +3 -3
index 8758ecd..9f12920 100644
@@ -12,15 +12,15 @@ TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "bigendian", "-meb", "-mel
 
 # ABI flags
 TUNEVALID[o32] = "MIPS o32 ABI"
-TUNECONFLICT[o32] = "n32 n64"
+TUNECONFLICTS[o32] = "n32 n64"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "o32", "-mabi=32", "", d)}"
 
 TUNEVALID[n32] = "MIPS64 n32 ABI"
-TUNECONFLICT[n32] = "o32 n64"
+TUNECONFLICTS[n32] = "o32 n64"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "n32", "-mabi=n32", "", d)}"
 
 TUNEVALID[n64] = "MIPS64 n64 ABI"
-TUNECONFLICT[n64] = "o32 n32"
+TUNECONFLICTS[n64] = "o32 n32"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "n64", "-mabi=64", "", d)}"
 
 # Floating point
meta/conf/machine/include/tune-c3.inc +1 -1
index 06fac8f..79bb67b 100644
@@ -1,7 +1,7 @@
 require conf/machine/include/ia32/arch-ia32.inc
 
 TUNEVALID[c3] = "VIA Cyrix III or VIA C3 specific optimizations"
-TUNECONFLICT[c3] = "m64 mx32"
+TUNECONFLICTS[c3] = "m64 mx32"
 TUNE_CCARGS += "${@bb.utils.contains("TUNE_FEATURES", "c3", "-march=c3 -mtune=c3", "", d)}"
 
 AVAILTUNES += "c3"
Signature · 1 line
1.7.0.4