Bug 5628

Summary: Building libgcrypt failed if TMPDIR conatins '-O2' or '-Ofast'
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Chen Qi <Qi.Chen>
Component: coreAssignee: Chen Qi <Qi.Chen>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: liezhi.yang, mark.hatle, meta.mr.watcher, meta.watcher, sgw, yi.zhao
Version: 1.5   
Target Milestone: 1.6 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Chen Qi 2013-12-05 07:46:19 UTC
1. Error message (stripped for readability):

| i586-poky-linux-libtool: compile:  i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/chenqi/testdir/containing-O1-O1-O1-Os/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/home/chenqi/testdir/containing-O2-O1-O1-Os/sysroots/qemux86/usr/include -O2 -pipe -g -feliminate-unused-debug-types -fvisibility=hidden -Wall -c ./tiger.c  -fPIC -DPIC -o .libs/tiger.o
| ./tiger.c:24:19: fatal error: stdio.h: No such file or directory
|  #include <stdio.h>
|                    ^
| compilation terminated.
| make[2]: *** [tiger.lo] Error 1
| make[2]: *** Waiting for unfinished jobs....
| make[2]: Leaving directory `/home/chenqi/testdir/containing-O2-Ofast-O1-Os/work/i586-poky-linux/libgcrypt/1.5.3-r0/libgcrypt-1.5.3/cipher'

2. How to reproduce
set in local.conf:
TMPDIR = "/home/chenqi/testdir/containing-O2-Ofast-O1-Os"

3. Root cause
In cipher/Makefile.am, we have:

if ENABLE_O_FLAG_MUNGING
o_flag_munging = sed -e 's/-O\([2-9s][2-9s]*\)/-O1/' -e 's/-Ofast/-O1/g'
else
o_flag_munging = cat
endif


# We need to lower the optimization for this module.                                                                                                                                                            
tiger.o: $(srcdir)/tiger.c
        `echo $(COMPILE) -c $(srcdir)/tiger.c | $(o_flag_munging) `

tiger.lo: $(srcdir)/tiger.c
        `echo $(LTCOMPILE) -c $(srcdir)/tiger.c | $(o_flag_munging) `

The '-O2' is replaced by '-O1', thus this problem.
Comment 1 Chen Qi 2013-12-18 08:19:53 UTC
Module: openembedded-core.git
Branch: master-next
Commit: 84514834417e022660e7b3a540910d2d6fb12337
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=84514834417e022660e7b3a540910d2d6fb12337

//Chen Qi
Comment 2 Yi Zhao 2014-01-15 09:33:07 UTC
Verified with master/1b636173ca88e5ccca1992f9a12367a1189fa674

Steps:
1. Add the following line in conf/local.conf
    TMPDIR = "${TOPDIR}/containing-O2-Ofast-O1-Os"
2. bitbake libgcrypt

The package can be built out without errors.