Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 299991 - sys-libs/ncurses-5.6-r2: during cross-compile on comp_hash.c: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_nc_to_widechar’ (long story short: ncurses fails to cross-compile with unicode)
Summary: sys-libs/ncurses-5.6-r2: during cross-compile on comp_hash.c: error: expected...
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-07 05:17 UTC by Jacob Godserv
Modified: 2010-01-08 03:48 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
configure patch (ncurses-5.6-configure-cross-build-cflags.patch,1.01 KB, patch)
2010-01-07 05:18 UTC, Jacob Godserv
Details | Diff
configure.in patch (ncurses-5.6-cross-build-cflags.patch,1.19 KB, patch)
2010-01-07 05:23 UTC, Jacob Godserv
Details | Diff
aclocal.m4 patch (ncurses-5.6-aclocal-divert-help.patch,583 bytes, patch)
2010-01-07 05:24 UTC, Jacob Godserv
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Godserv 2010-01-07 05:17:04 UTC
The error when the unicode USE flag is enabled:
x86_64-pc-linux-gnu-gcc -o make_hash -DHAVE_CONFIG_H -I../ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/../include -I../include  -O2 -pipe -DMAIN_PROGRAM /usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/tinfo/comp_hash.c
In file included from /usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/tinfo/comp_hash.c:42:
/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/curses.priv.h:1082: warning: parameter names (without types) in function declaration
/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/curses.priv.h:1083: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_nc_to_widechar’
make[1]: *** [make_hash] Error 1
make[1]: Leaving directory `/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/widec/ncurses'
make: *** [sources] Error 2

The fix: add -D_GNU_SOURCE in there as an option to gcc. This is what it should look like (in my case):
x86_64-pc-linux-gnu-gcc -o make_hash -DHAVE_CONFIG_H -I../ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/../include -I../include -DHAVE_CONFIG_H -I../ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses -I/usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/../include -I. -I../include  -D_GNU_SOURCE -DXTSTRINGDEFINES -DNDEBUG -I/usr/include/ncursesw -O2 -pipe -DMAIN_PROGRAM /usr/armv7a-unknown-linux-gnueabi/tmp/portage/sys-libs/ncurses-5.6-r2/work/ncurses-5.6/ncurses/tinfo/comp_hash.c -L/usr/armv7a-unknown-linux-gnueabi/lib -L/usr/armv7a-unknown-linux-gnueabi/usr/lib  -ldl

All those extra options are missing when cross-compiling because the configure script thinks its best the Makefiles have no control whatsoever in adding in such essential arguments such as -D_GNU_SOURCE.

The patch is to configure, which is wrong, I know. I would do it to configure.in or some other auto* file, but upstream ncurses uses a custom autotools setup, one which eautoreconf cannot reproduce and fails. Even when I patched aclocal.m4 to contain custom macros, the resulting configure script didn't contain all the seds it needed and thus broke some files with "stray" @VAR@ leftovers.

You can do what you want. I think this is good enough, since it's likely Gentoo will never be able to use eautoreconf on ncurses, until ncurses devs reveal what is necessary to run autoconf on their code.

Patch attached below.

Reproducible: Always

Steps to Reproduce:




 # emerge-armv7a-unknown-linux-gnueabi --info
Portage 2.1.6.13 (default/linux/arm/10.0, gcc-4.3.4, unavailable, 2.6.32-gentoo-r1 x86_64)
=================================================================
System uname: Linux-2.6.32-gentoo-r1-x86_64-Intel-R-_Core-TM-2_Duo_CPU_P8800_@_2.66GHz-with-gentoo-1.12.13
Timestamp of tree: Thu, 07 Jan 2010 02:30:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     4.0_p35
dev-lang/python:     2.6.4
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.63-r1
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="arm"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fomit-frame-pointer -Os -pipe -I/usr/armv7a-unknown-linux-gnueabi/usr/include/ -I/usr/armv7a-unknown-linux-gnueabi/include/"
CHOST="armv7a-unknown-linux-gnueabi"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fomit-frame-pointer -Os -pipe -I/usr/armv7a-unknown-linux-gnueabi/usr/include/ -I/usr/armv7a-unknown-linux-gnueabi/include/"
DISTDIR="/usr/portage/distfiles"
FEATURES="buildpkg collision-protect distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LANG="en_US.UTF-8"
LDFLAGS="-L/usr/armv7a-unknown-linux-gnueabi/lib -L/usr/armv7a-unknown-linux-gnueabi/usr/lib"
MAKEOPTS="-j2"
PKGDIR="/usr/armv7a-unknown-linux-gnueabi/packages/"
PORTAGE_CONFIGROOT="/usr/armv7a-unknown-linux-gnueabi/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/armv7a-unknown-linux-gnueabi/tmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl arm berkdb bzip2 cli cracklib crypt cups cxx fortran gdbm gpm iconv ipv6 modules mudflap ncurses nls nptl nptlonly openmp pam pcre perl pppd python readline reflection session spl ssl sysfs tcpd unicode xorg zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint mach64 mga nv r128 radeon savage sis tdfx trident       voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Jacob Godserv 2010-01-07 05:18:07 UTC
Created attachment 215474 [details, diff]
configure patch
Comment 2 Jacob Godserv 2010-01-07 05:23:07 UTC
Created attachment 215476 [details, diff]
configure.in patch

If you want to see how it really ought to be done, here is the "proper" patch. This causes eautoreconf to fail, however, due to a custom macro AC_DIVERT_HELP.
Comment 3 Jacob Godserv 2010-01-07 05:24:57 UTC
Created attachment 215478 [details, diff]
aclocal.m4 patch

In an attempt to fix this and stick to the proper methods, I found this patch from Google to add the custom AC_DIVERT_HELP macro. eautoreconf no longer fails, but later on gcc will complain about a "stray" @VAR@.
Comment 4 SpanKY gentoo-dev 2010-01-08 02:39:41 UTC
Comment on attachment 215474 [details, diff]
configure patch

the current ncurses code is correct wrt BUILD_* initialization.  when cross-compiling, you should never default to host values.
Comment 5 SpanKY gentoo-dev 2010-01-08 02:43:46 UTC
the _GNU_SOURCE issue should already be fixed via Bug 214642.  if you read the ebuild, you'll see that we append that flag to the BUILD_CPPFLAGS.

post the full build log as an attachment.
Comment 6 Jacob Godserv 2010-01-08 02:56:16 UTC
That is actually wrong, as far as I can tell. The cross-compilation ought to be as close as possible to normal compilation. The patch I have provided includes not just the missing GNU_SOURCE flag but all the other missing includes a normal compile would receive. I compared normal vs. cross to even find the solution.

(I'll get a build.log as soon as my beagle is finished with its current task.)
Comment 7 SpanKY gentoo-dev 2010-01-08 03:22:19 UTC
the toolchain-independent flags that the configure script uses should probably get added to both the host and the build flags, but setting BUILD_* to the host settings when cross-compiling is wrong.  end of story.  you have no idea what the user has put in there and they could easily be usable only by the host toolchain.

the snippet you posted doesnt include -D_GNU_SOURCE when creating make_hash ...
Comment 8 Jacob Godserv 2010-01-08 03:26:43 UTC
Ah, I see... too bad there's no way to differentiate between ncurses and user defaults.

Will post a build.log shortly. Unless you're positive there's no (practical) potential for a better fix here, we can close it.
Comment 9 SpanKY gentoo-dev 2010-01-08 03:48:50 UTC
upstream is aware of this deficiency, but there's no way currently to cleanly solve this short of running configure twice from upstream's perspective.  that's why the ebuild adds -D_GNU_SOURCE to the build flags for people.  you shouldnt be seeing a build failure wrt this flag missing.