Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 209129 - sys-apps/gawk-3.1.5-r05.1 doesn't honour CPPFLAGS for 'emake filefuncs'
Summary: sys-apps/gawk-3.1.5-r05.1 doesn't honour CPPFLAGS for 'emake filefuncs'
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: MIPS IRIX
: High normal (vote)
Assignee: Gentoo non-Linux Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-06 12:19 UTC by Stuart Shelton
Modified: 2009-07-08 10:40 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Shelton 2008-02-06 12:19:42 UTC
When building sys-apps/gawk-3.1.5-r05.1 on IRIX with USE="nls", building filfuncs.c fails with:

cc -c99 -n32 -mips4 -shared -Wall -DHAVE_CONFIG_H -c -O2 -fPIC -I/usr/opt/portage/var/tmp/portage/sys-apps/gawk-3.1.5-r05.1/work/gawk-3.1.5 filefuncs.c
cc-1005 cc: ERROR File = /usr/opt/portage/var/tmp/portage/sys-apps/gawk-3.1.5-r05.1/work/gawk-3.1.5/gettext.h, Line = 31
  The source file "libintl.h" is unavailable.

  # include <libintl.h>
                       ^

1 catastrophic error detected in the compilation of "filefuncs.c".
Compilation terminated.
make: *** [filefuncs.o] Error 2
 * 
 * ERROR: sys-apps/gawk-3.1.5-r05.1 failed.
 * Call stack:
 *               ebuild.sh, line   46:  Called src_compile
 *             environment, line 2058:  Called die
 * The specific snippet of code:
 *       emake CC=$(tc-getCC) LIBDIR="${EPREFIX}/$(get_libdir)" || diefunc "$FUNCNAME" "$LINENO" "$?" "filefuncs emake failed"
 *  The die message:
 *   filefuncs emake failed
 * 
 * If you need support, post the topmost build error, and the call stack if relevant.
 * A complete build log is located at '/usr/opt/portage/var/tmp/portage/sys-apps/gawk-3.1.5-r05.1/temp/build.log'.
 * The ebuild environment file is located at '/usr/opt/portage/var/tmp/portage/sys-apps/gawk-3.1.5-r05.1/temp/environment'.

This looks as if the filefuncs Makefile (from the files directory of the ebuild in portage) neither uses CPPFLAGS nor adds '-I${EPREFIX}/usr/include'.

(But shouldn't this affect all prefix builds?  The Solaris installation guide says that CPPFLAGS should be unset prior to 'emerge system' - so has the default include path not been hard-coded if I failed to do this?)

In any case, I fixed this by conditionally setting PREFIXINCDIR to '-I$(EPREFIX)/usr/include' or nothing immediately below the AWKINCDIR declarations in the Makefile, and added $(PREFIXINCDIR) to the $(CC) directive.  I guess this could equally be rolled into AWKINCDIR, but that's getting away from how it is named...
Comment 1 Fabian Groffen gentoo-dev 2008-02-06 12:27:45 UTC
(In reply to comment #0)
> This looks as if the filefuncs Makefile (from the files directory of the ebuild
> in portage) neither uses CPPFLAGS nor adds '-I${EPREFIX}/usr/include'.
> 
> (But shouldn't this affect all prefix builds?  The Solaris installation guide
> says that CPPFLAGS should be unset prior to 'emerge system' - so has the
> default include path not been hard-coded if I failed to do this?)

Yep, but the problem here is that you don't use a compiler built by Portage.

In Prefix we sort of "help" many compilations by
a) building a compiler that "knows" about the prefix (it looks into the include dir of the prefix)
b) making sure that the linker "knows" about the prefix too (by making it look into the prefix lib paths, and assuring those libs can be found at runtime)

We achieve a) by compiling our own gcc, and b) by having an ld wrapper (binutils-config provides it) that injects the correct search paths.  Since you don't do a), your compiler doesn't look in the prefix include path, and also doesn't use our ld wrapper, making b) fail.

The way to solve this, is to:
1) have a wrapper for your compiler to include the -I directive for prefix
2) have this LD_PRELOAD code to intercept calls by the compiler to the linker, to make them go through the ld-wrappers instead.
Comment 2 Stuart Shelton 2008-02-07 18:09:27 UTC
Hmm - would the following be an option:

3) Have "-I${EPREFIX}/usr/include" permanently remain in CPPFLAGS and "-L{EPREFIX}/usr/lib -L{EPREFIX}/lib" permanently remain in LDFLAGS, and then ensure that ebuilds honour these values?

... having said this, an IRIX-wrappers build could be very useful: as well as ensuring that those values are present, it could (un)wrap LD args (-Wl,...) for cc/ld as necessary, and install a noop ranlib script for ebuilds that insist on calling it, and finally fix the problem of the compiler returning 0 after exiting due to a #error.  It could kill a flock of birds with one stone ;)

My only concern would be if the compiler tools perform some strange magic based on how they were invoked...

I'll have a play and see what I can come up with.
Comment 3 Stuart Shelton 2008-02-08 22:06:20 UTC
I've written a script which sanity-checks compiler/linker arguments and tries to filter them appropriately - and it seems to work...

I think that what I have is a little over engineered (over 500 lines in size) right now, though - so I'm going to rebuild my system with it with full debugging enabled to catch any problems.

(On the plus side, the only non-builtin command used is a single invokation of 'sed', so it should run efficiently)

Once that's done (and I've taken some timings to ensure that it's not too much of a burden when compiling many small files), I'll post the result.
Comment 4 Fabian Groffen gentoo-dev 2008-02-11 10:32:26 UTC
(In reply to comment #3)
> I've written a script which sanity-checks compiler/linker arguments and tries
> to filter them appropriately - and it seems to work...
> 
> I think that what I have is a little over engineered (over 500 lines in size)
> right now, though - so I'm going to rebuild my system with it with full
> debugging enabled to catch any problems.
> 
> (On the plus side, the only non-builtin command used is a single invokation of
> 'sed', so it should run efficiently)
> 
> Once that's done (and I've taken some timings to ensure that it's not too much
> of a burden when compiling many small files), I'll post the result.

Can you open a bug for this script (I guess it's a "gcc" wrapper?), so we can look at it, and possibly make suggestions?  I prefer to only add keywords and some of the patches only when we have some cc under our control (e.g. a wrapper package in the tree, like native-cctools).
Comment 5 SpanKY gentoo-dev 2009-05-16 22:02:14 UTC
CPPFLAGS should be respected now

http://sources.gentoo.org/sys-apps/gawk/files/filefuncs/Makefile?r1=1.9&r2=1.10
Comment 6 Fabian Groffen gentoo-dev 2009-07-05 11:13:12 UTC
fix0rzed by SpanKY
Comment 7 Stuart Shelton 2009-07-08 10:40:24 UTC
Also fixed by IRIX-MIPSpro-wrapper (which re-writes compiler/linker flags on-the-fly).  Successful build of gawk-3.1.6. confirmed.

Non-fatal test-suite failures:

fmtspcl
fmtspcl.ok _fmtspcl differ: byte 168, line 3
make[1]: [fmtspcl] Error 1 (ignored)

intformat
./intformat.ok _intformat differ: byte 1, line 1
make[1]: [intformat] Error 1 (ignored)

ovrflow1
./ovrflow1.ok _ovrflow1 differ: byte 19, line 1
make[1]: [ovrflow1] Error 1 (ignored)

double1
./double1.ok _double1 differ: byte 19, line 1
make[1]: [double1] Error 1 (ignored)
double2
./double2.ok _double2 differ: byte 22, line 1
make[1]: [double2] Error 1 (ignored)

make[2]: Entering directory `/usr/opt/gentoo/var/tmp/portage/sys-apps/gawk-3.1.6/work/gawk-3.1.6/test'
5 TESTS FAILED

>>> Completed installing gawk-3.1.6 into /usr/opt/gentoo/var/tmp/portage/sys-apps/gawk-3.1.6/image/opt/gentoo/

ecompressdir: bzip2 -9 /opt/gentoo/usr/share/man
bzip2: Can't open input file /usr/opt/gentoo/var/tmp/portage/sys-apps/gawk-3.1.6/image/opt/gentoo/usr/share/doc/gawk-3.1.6/README_d/OBSOLETE: No such file or directory.