Patchwork [1/1] eglibc: always compile with optimization.

login
register
mail settings
Submitter jackie huang
Date Nov. 12, 2012, 3:31 a.m.
Message ID <88778c5a8e868a75c53ed8e60bb80a2cda17bc8d.1352690328.git.jackie.huang@windriver.com>
Download mbox | patch
Permalink /patch/38849/
State New
Headers show

Comments

jackie huang - Nov. 12, 2012, 3:31 a.m.
From: Jackie Huang <jackie.huang@windriver.com>

eglibc fails to compile if someone tries to compile an entire image as -O0:
error "glibc cannot be compiled without optimization"
so in this case, force to use -O2 and give a note about it.

[YOCTO #3405]

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 meta/recipes-core/eglibc/eglibc_2.16.bb |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
Phil Blundell - Nov. 12, 2012, 9:48 a.m.
On Mon, 2012-11-12 at 11:31 +0800, jackie.huang@windriver.com wrote:
> +# eglibc can't be built without optimization, if someone tries to compile an
> +# entire image as -O0, we override it with -O2 here and give a note about it.
> +def get_optimization(d):
> +    if base_contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x":
> +        bb.note("eglibc can't be built with -O0, -O2 will be used instead.")
> +        selected_optimization = d.getVar("SELECTED_OPTIMIZATION", True)
> +        return selected_optimization.replace("-O0", "-O2")
> +    return selected_optimization

Did you test this patch at all?

p.
jackie huang - Nov. 13, 2012, 1:44 a.m.
On 11/12/2012 5:48 PM, Phil Blundell wrote:
> On Mon, 2012-11-12 at 11:31 +0800, jackie.huang@windriver.com wrote:
>> +# eglibc can't be built without optimization, if someone tries to compile an
>> +# entire image as -O0, we override it with -O2 here and give a note about it.
>> +def get_optimization(d):
>> +    if base_contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x":
>> +        bb.note("eglibc can't be built with -O0, -O2 will be used instead.")
>> +        selected_optimization = d.getVar("SELECTED_OPTIMIZATION", True)
>> +        return selected_optimization.replace("-O0", "-O2")
>> +    return selected_optimization
>
> Did you test this patch at all?

I did test only in the cases that caused the defect but now I realized 
that it's not well tested and it doesn't work in other cases, sorry 
about that, I will re-work on it.

Thanks,
Jackie

>
> p.
>
>
>
>

Patch

diff --git a/meta/recipes-core/eglibc/eglibc_2.16.bb b/meta/recipes-core/eglibc/eglibc_2.16.bb
index aa9256c..0047c1c 100644
--- a/meta/recipes-core/eglibc/eglibc_2.16.bb
+++ b/meta/recipes-core/eglibc/eglibc_2.16.bb
@@ -87,6 +87,17 @@  EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \
 
 EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}"
 
+# eglibc can't be built without optimization, if someone tries to compile an
+# entire image as -O0, we override it with -O2 here and give a note about it.
+def get_optimization(d):
+    if base_contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x":
+        bb.note("eglibc can't be built with -O0, -O2 will be used instead.")
+        selected_optimization = d.getVar("SELECTED_OPTIMIZATION", True)
+        return selected_optimization.replace("-O0", "-O2")
+    return selected_optimization
+
+SELECTED_OPTIMIZATION := "${@get_optimization(d)}"
+
 do_unpack_append() {
     bb.build.exec_func('do_move_ports', d)
 }