[oe-commits] [openembedded-core] 52/116: glibc.inc: improve optimisation level sanity checking

git at git.openembedded.org git at git.openembedded.org
Sun Feb 28 11:29:38 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 6dfc675b8aed8307092b3e561a3a7e26f3a05462
Author: Andre McCurdy <armccurdy at gmail.com>
AuthorDate: Wed Feb 24 14:39:33 2016 -0800

    glibc.inc: improve optimisation level sanity checking
    
    - Avoid code duplication to handle -O, -O1 and -Os cases
    
    - Consider the effective optimisation level only (avoids spurious
      warnings if multiple optimisation flags are present).
    
    - Prefix warnings with PN instead of hardcoding "glibc" (avoids
      confusing warnings since the test is also applied to glibc-initial,
      nativesdk-glibc, nativesdk-glibc-initial, etc, and each could
      potentually have different optimisation flags).
    
    Signed-off-by: Andre McCurdy <armccurdy at gmail.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/recipes-core/glibc/glibc.inc | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/meta/recipes-core/glibc/glibc.inc b/meta/recipes-core/glibc/glibc.inc
index 5711209..bf1dccd 100644
--- a/meta/recipes-core/glibc/glibc.inc
+++ b/meta/recipes-core/glibc/glibc.inc
@@ -8,19 +8,15 @@ PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
 
 TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TCBOOTSTRAP}"
 
-# glibc can't be built without optimization, if someone tries to compile an
-# entire image as -O0, break with fatal.
 python () {
-    if bb.utils.contains("SELECTED_OPTIMIZATION", "-O", "x", "", d) == "x":
-        bb.note("glibc can't be built with -O, -O -Wno-error will be used instead.")
-        d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
-    elif bb.utils.contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x":
-        bb.fatal("glibc can't be built with -O0, using -O1 -Wno-error or -O1 instead.")
-    elif bb.utils.contains("SELECTED_OPTIMIZATION", "-Os", "x", "", d) == "x":
-        bb.note("glibc can't be built with -Os, -Os -Wno-error will be used instead.")
-        d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
-    elif bb.utils.contains("SELECTED_OPTIMIZATION", "-O1", "x", "", d) == "x":
-        bb.note("glibc can't be built with -O1, -O1 -Wno-error will be used instead.")
+    opt_effective = "-O"
+    for opt in d.getVar('SELECTED_OPTIMIZATION', True).split():
+        if opt in ("-O0", "-O", "-O1", "-O2", "-O3", "-Os"):
+            opt_effective = opt
+    if opt_effective == "-O0":
+        bb.fatal("%s can't be built with %s, try -O1 instead" % (d.getVar('PN', True), opt_effective))
+    if opt_effective in ("-O", "-O1", "-Os"):
+        bb.note("%s doesn't build cleanly with %s, adding -Wno-error to SELECTED_OPTIMIZATION" % (d.getVar('PN', True), opt_effective))
         d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list