Bug 7870

Summary: GCC 5.0 or later causes ncurses build to fail
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Martin Stolpe <martin.stolpe>
Component: coreAssignee: Martin Stolpe <martin.stolpe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: jku, martin.stolpe, meta.mr.watcher, meta.watcher
Version: 1.8   
Target Milestone: 1.8.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
add -P to BUILD_CPPFLAGS none

Description Martin Stolpe 2015-06-10 07:29:17 UTC
Created attachment 2542 [details]
add -P to BUILD_CPPFLAGS

When gcc 5.0 or greater is installed on the development PC the build of ncurses will fail because gcc's preprocessor will add line markers which are not expected by the ncurses sed/awk scripts.

Adding "-P" to the CFLAGS will prohibit the insertion of line markers: https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
Comment 1 Martin Stolpe 2015-06-10 07:47:23 UTC
This is the error message without the patch:
| In file included from /home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/ncurses-5.9/ncurses/curses.priv.h:283:0,
|                  from ../ncurses/lib_gen.c:19:
| _22724.c:835:15: error: expected ')' before 'int'
| ../include/curses.h:1594:56: note: in definition of macro 'mouse_trafo'
|  #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
|                                                         ^
| gcc  -DHAVE_CONFIG_H -I../ncurses -I/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/ncurses-5.9/ncurses -isystem/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/sysroots/x86_64-linux/usr/include -D_GNU_SOURCE -DNDEBUG -I. -I../include -I/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/ncurses-5.9/ncurses/../include -I/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/sysroots/x86_64-linux/usr/include -isystem/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/sysroots/x86_64-linux/usr/include -D_GNU_SOURCE -O2 -pipe  --param max-inline-insns-single=1200 -fPIC -c /home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/ncurses-5.9/ncurses/base/lib_hline.c -o ../obj_s/lib_hline.o
| Makefile:1682: recipe for target '../obj_s/lib_gen.o' failed
| make[1]: *** [../obj_s/lib_gen.o] Error 1
| make[1]: *** Waiting for unfinished jobs....
| make[1]: Leaving directory '/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/build/narrowc/ncurses'
| Makefile:134: recipe for target 'libs' failed
| make: *** [libs] Error 2
| make: Leaving directory '/home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/build/narrowc'
| ERROR: oe_runmake failed
| WARNING: /home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/temp/run.do_compile.22631:1 exit 1 from
|   exit 1
| ERROR: Function failed: do_compile (log file is located at /home/martin/projects/beaglebone/yocto/poky-fido/build-raspi/tmp/work/x86_64-linux/ncurses-native/5.9-r15.1/temp/log.do_compile.22631)
ERROR: Task 6 (virtual:native:/home/martin/projects/beaglebone/yocto/poky-fido/meta/recipes-core/ncurses/ncurses_5.9.bb, do_compile) failed with exit code '1'

This is the part of the generated lib_gen.c which causes the error:
# 835 "_22724.c" 3 4
NCURSES_BOOL 
# 835 "_22724.c"
 mouse_trafo (int * a1, int * a2, 
# 835 "_22724.c" 3 4
 NCURSES_BOOL 
# 835 "_22724.c"
 z)
{
	T((T_CALLED("mouse_trafo(%p,%p,%#lx)"), (const void *)a1, (const void *)a2, (long)z)); returnBool(wmouse_trafo(stdscr,a1,a2,z));
}
Comment 2 Ross Burton 2015-06-10 09:12:48 UTC
We don't normally take patches via bugzilla.  Can you send it to openembedded-core@lists.openembedded.org with your signed-off-by and a commit message that follows the guidelines ("ncurses: fix native builds when host has gcc5").
Comment 3 Martin Stolpe 2015-06-10 09:17:33 UTC
I'm not sure if this is the correct way to fix this problem like I did in the patch. Should I send the patch to the list anyway and wait for the responses?
Comment 4 Ross Burton 2015-06-10 09:36:10 UTC
The patch is right afaik.
Comment 5 Martin Stolpe 2015-06-10 13:54:17 UTC
Ok, I have send the patch to the mailing list but it seems this was fixed in master by updating ncurses to the newest version.

Is there any chance this patch can be applied to the fido branch so that ncurses will compile with gcc >= 5.0? I guess it is not very likely that ncurses will be updated in fido.
Comment 6 Ross Burton 2015-06-10 13:55:49 UTC
Right, I just asked that exact question.  Rebase the patch against fido and resend it with a [fido] tag in the subject.
Comment 7 Jussi Kukkonen 2015-10-15 10:24:39 UTC
$ git log -1 origin/fido ../meta/recipes-core/ncurses/ncurses.inc
commit e118d980dab4a0872fe232c17a2305e899b48b87
Author: Martin Stolpe <martinstolpe@gmail.com>
Date:   Wed Jun 10 16:28:26 2015 +0200

    ncurses: fix native builds when host has gcc5
    
    GCC"s preprocessor starts to add newlines which are not
    handled properly by ncurses build system startin from
    version 5.0.
    
    See also: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7870
    
    (From OE-Core rev: 3a5435b371c84ec28b6936b8c8fa6541a592d061)
    
    Signed-off-by: Martin Stolpe <martin.stolpe@gmail.com>
    Signed-off-by: Joshua Lock <joshua.lock@collabora.co.uk>
    Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>