Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 245319 - sys-devel/gcc-4.2.3 include paths not properly searched when using C_INCLUDE_PATH
Summary: sys-devel/gcc-4.2.3 include paths not properly searched when using C_INCLUDE_...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-02 20:56 UTC by Jeremy Huddleston Sequoia
Modified: 2008-12-07 20:28 UTC (History)
1 user (show)

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 Jeremy Huddleston Sequoia 2008-11-02 20:56:37 UTC
I can't get gcc to prioritize the current directory in a search for include files.  In this example, the binutils directory (pwd) has a config.h file, but ../bfd/config.h is included instead.  Even if I change the -I. to -I../binutils, it's still ../bfd/config.h that is included.  If I cd ../b (an empty dir), it will pick up ../binutils/config.h correctly,

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/binutils $ gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -I. -I../bfd -I. -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../bfd -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../include   -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../intl -I../intl  -DLOCALEDIR="\"/home/cloud/jeremy/src/netbsd/netbsd-5/tooldir.linux-amd64/share/locale\""  -Dbin_dummy_emulation=bin_vanilla_emulation  -D_LARGEFILE64_SOURCE -W -Wall -Wstrict-prototypes -Wmissing-prototypes -O -c /home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/bucomm.c -E | grep /config.h
# 1 "../bfd/config.h" 1

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/binutils $ gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -I$(pwd) -I../bfd -I$(pwd) -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../bfd -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../include   -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../intl -I../intl  -DLOCALEDIR="\"/home/cloud/jeremy/src/netbsd/netbsd-5/tooldir.linux-amd64/share/locale\""  -Dbin_dummy_emulation=bin_vanilla_emulation  -D_LARGEFILE64_SOURCE -W -Wall -Wstrict-prototypes -Wmissing-prototypes -O -c /home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/bucomm.c -E | grep /config.h
# 1 "../bfd/config.h" 1

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/binutils $ gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -I../binutils -I../bfd -I../binutils -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../bfd -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../include   -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../intl -I../intl  -DLOCALEDIR="\"/home/cloud/jeremy/src/netbsd/netbsd-5/tooldir.linux-amd64/share/locale\""  -Dbin_dummy_emulation=bin_vanilla_emulation  -D_LARGEFILE64_SOURCE -W -Wall -Wstrict-prototypes -Wmissing-prototypes -O -c /home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/bucomm.c -E | grep /config.h
# 1 "../bfd/config.h" 1

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/binutils $ cd ../b

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/b $ gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -I../binutils -I../bfd -I../binutils -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../bfd -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../include   -I/home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/../intl -I../intl  -DLOCALEDIR="\"/home/cloud/jeremy/src/netbsd/netbsd-5/tooldir.linux-amd64/share/locale\""  -Dbin_dummy_emulation=bin_vanilla_emulation  -D_LARGEFILE64_SOURCE -W -Wall -Wstrict-prototypes -Wmissing-prototypes -O -c /home/cloud/jeremy/src/netbsd/netbsd-5/src/tools/binutils/../../gnu/dist/binutils/binutils/bucomm.c -E | grep /config.h
# 1 "../binutils/config.h" 1




---

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/b $ gcc --versiongcc (GCC) 4.2.3 (Gentoo 4.2.3 p1.0)Copyright (C) 2007 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/src/netbsd/netbsd-5/src/tools/binutils/obj/build/b $ emerge --info
Portage 2.2_rc11 (default/linux/amd64/2008.0, gcc-4.2.3, glibc-2.7-r2, 2.6.25-hardened-r8 x86_64)
=================================================================
System uname: Linux-2.6.25-hardened-r8-x86_64-AMD_Athlon-tm-_64_Processor_2800+-with-glibc2.2.5
Timestamp of tree: Sun, 02 Nov 2008 10:15:01 +0000
app-shells/bash:     3.2_p33
dev-java/java-config: 1.3.7, 2.1.6
dev-lang/python:     2.5.2-r7
dev-python/pycrypto: 2.0.1-r6
dev-util/cmake:      2.4.7-r1
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r2
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=k8"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=k8"
DISTDIR="/var/tmp/gentoo/distfiles"
FEATURES="bindeps candy collision-protect distlocks metadata-transfer parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv userpriv_fakeroot usersandbox verify-rdepend"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/"
LANG="en_US.utf8"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,-O1"
LINGUAS="en en_US"
MAKEOPTS="-j2"
PKGDIR="/var/tmp/gentoo/packages-amd64"
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="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync7.us.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext 3ds S3TC X X509 Xaw3d a52 aac aalib acl acpi activefilter adplug aim alsa amd amd64 amr ao apache2 artworkextra atlas audiofile avahi avantgo bash-completion bcmath berkdb bidi browserplugin bzip2 bzlib c++ calendar caps cdda cddb cdio cdparanoia cdr cgi chroot clamav clanJavaScript clanVoice clearpasswd cli client clisp cracklib crypt cscope css cups curl curlwrappers cvs cvsgraph dbase dbcp dbm dbus dbx dedicated dga dio divx4linux dlloader dmx dnd dri dts dv dvd dvdr dvdread edl eds emacs emacs-w3 enca encode enscript erandom esd ethereal evms2 evo exif exiv2 expat ext-png ext-zlib extensions f77 faac faad fam fame fat fax fbcon fbdev ffmpeg fftw filter firefox flac flash flatfile fltk fluidsynth font-server foomaticdb fortran fpx freetts freetype fs gb gcj gcl gd gd-external gdbm gif gimp gimpprint glade glep glib glibc-omitfp glitz glut gmp gmtfull gmthigh gmtsuppl gmttria gnome gnomedb gnuplot gnutls gocr gpm gps graphviz gs gstreamer gtk gtkhtml hal hash hbci hdri highlight howl howl-compat iconv icq idea idl idn ieee1394 image imagemagick imap imlib imlib2 inifile innodb ipalias iproute2 ipsec ipv6 isdnlog ithreads jabber jack java javacomm javamail javascript jbig jikes joystick jpeg jpeg2k junit justify kde ladcca latex lcms ldap libcaca libclamav libdsk libedit libg++ libgda libsamplerate libwww lids live lm_sensors lmtp log4j logitech-mouse ltsp lua lucid lzo mad maildir makecheck matroska mbrola mcal md5sum mdnsresponder-compat mhash midi mikmod mime ming mixer mjpeg mmx mmxext mng mod_python mozcalendar mozctl mozdevelop mozilla mozp3p mozsvg mozxmlterm mp2 mp3 mpeg mpeg4 mplayer mpm-prefork msession msn mtp mudflap mule multilib multislot musepack music mysql mysqli mythtv nas native ncurses neXt network nis nls nptl nptlonly nsplugin nviz oav objc objc++ objc-gc ocaml ocrad odbc offensive ofx ogg oggvorbis oldworld openal opendoc openexr opengl openmp openssl opensslcrypt opera oscar oss pam parse-clocks pcap pch pcntl pcre pda pdf perl php physfs pic pie plotutils png pnm pnp portaudio povray ppds pppd prelude procmail pulseaudio python q32 qhull qt qt3 qt3support qt4 quicktime rar readline recode reflection regexp rplay rtc samba sasl savedconfig sdk sdl sdl-image server session sharedmem sid silc slp sms sndfile soap socks5 sox speex spell spl sql sqlite sqlite3 src srt sse sse2 ssl subversion suexec svg sysfs sysvipc t1lib tcltk tcpd tesseract tetex tex tga theora tidy tiff timidity transcode transparent-proxy truetype trusted tta type1 ucs2 unicode urandom usb user-homedirs userlocales v4l v4l2 vcd vda vhosts videos vim-with-x virus-scan visualization vlm vnc vorbis wav wavpack wddx wma wmf wsconvert wxwin wxwindows x264 xanim xchattext xcomposite xemacs xface xforms xfs xine xinerama xml xml2 xmlreader xmlrpc xmlwriter xorg xosd xpm xsl xv xvid xvmc yahoo zeo zeroconf zip zlib" ALSA_CARDS="via82xx" 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="wacom joystick keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" USERLAND="GNU" VIDEO_CARDS="nvidia nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Jeremy Huddleston Sequoia 2008-11-02 23:32:47 UTC
Reduced example:

~/GR-245319 $ find .
.
./dir1
./dir1/config.h
./dir2
./dir2/config.h
./dir3
./dir3/test.c

~/GR-245319 $ cat dir3/test.c 
#include "config.h"

int blah() {
	return 1;
}

~/GR-245319 $ cd dir2/

~/GR-245319/dir2 $ gcc -I. -I../dir1 -I. -E ../dir3/test.c 
# 1 "../dir3/test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "../dir3/test.c"
# 1 "../dir1/config.h" 1
# 2 "../dir3/test.c" 2

int blah() {
 return 1;
}
Comment 2 Jeremy Huddleston Sequoia 2008-11-02 23:36:59 UTC
NetBSD's 3.3.3 and Gentoo's 3.4.6-r2 work as expected:

~/src/GR-245319/dir2 $  gcc -I. -I../dir1 -I. -E ../dir3/test.c
# 1 "../dir3/test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "../dir3/test.c"
# 1 "config.h" 1
# 2 "../dir3/test.c" 2

int blah() {
        return 1;
}

~/src/GR-245319/dir2 $  gcc --version
gcc (GCC) 3.3.3 (NetBSD nb3 20040520)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


--------

And also gcc-3.4.6:

~/GR-245319/dir2 $ gcc -I. -I../dir1 -I. -E ../dir3/test.c 
# 1 "../dir3/test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "../dir3/test.c"
# 1 "./config.h" 1
# 2 "../dir3/test.c" 2

int blah() {
 return 1;
}

~/GR-245319/dir2 $ gcc --version
gcc (GCC) 3.4.6 (Gentoo Hardened 3.4.6-r2 p1.5, ssp-3.4.6-1.0, pie-8.7.10)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


---

gcc-4.1.2 shows this bug as well.
Comment 3 Jeremy Huddleston Sequoia 2008-11-03 06:28:45 UTC
Ok, this is weird... 3.4.6-r2 doesn't work on the system with the emerge --info from above.  The "working" 3.4.6-r2 above was from a stable hardened i386 system:

Portage 2.2_rc12 (hardened/x86/2.6, gcc-3.4.6-hardenednossp, glibc-2.6.1-r0, 2.6.25-hardened-r9 i686)
=================================================================
System uname: Linux-2.6.25-hardened-r9-i686-Intel-R-_Pentium-R-_4_CPU_2.80GHz-with-glibc2.1.3
Timestamp of tree: Sun, 02 Nov 2008 10:15:01 +0000
app-shells/bash:     3.2_p33
dev-java/java-config: 1.3.7, 2.1.6
dev-lang/python:     2.5.2-r7
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r2
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -fomit-frame-pointer -O2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=pentium4 -fomit-frame-pointer -O2 -pipe"
DISTDIR="/var/tmp/distfiles"
FEATURES="ccache distlocks loadpolicy nostrip parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LC_ALL="en_US.utf8"
LDFLAGS=""
LINGUAS="en es ja"
PKGDIR="/usr/portage/packages"
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="/var/tmp"
PORTDIR="/var/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync7.us.gentoo.org/gentoo-portage"
USE="X Xaw3d a52 aac aalib alsa amrnb ao apache2 asf audiofile avahi bash-completion berkdb bidi bitmap-fonts bl browserplugin bzip2 cdda cddb cdparanoia cjk clamav cpudetection cracklib crypt cups curl dba dbus deprecated dga dri dts dv dvd eds elf emacs enca encode enscript erandom esd exif expat fam fame fat ffmpeg firefox flac flash font-server fontconfig fortran fpx ftp gd gd-external gdbm gif glibc-omitfp glut glx gmp gnome gnutls gpm graphviz gs gstreamer gtk gtk2 gtkhtml guild guile gzip hal hardened hardenedphp hdri i8x0 iconv icq idn imap imlib imlib2 iproute2 ipsec ipv6 jack java jbig jp2 jpeg jpeg2k kcal kde lame lcms libcaca libclamav libgda libvisual linuxthreads-tls live lm_sensors logitech-mouse logrotate lzo mad maildir md5sum mdnsresponder-compat mhash midi ming mixer mjpeg mmx mmxext mng mod_python modperl mouse mp2 mp3 mp4 mpeg mpeg2 mplayer multislot musepack musicbrainz mysql mysqli ncurses network networking new-login nfs nls nptl nsplugin oav objc ocaml ogg oggvorbis openal opendoc openexr opengl oss pam pam_chroot pcre perl php pic png pnm portaudio postfix povray ppds pvr python pyzor q32 qca qt qt3 qt3support qt4 quicktime quotas radio rar razor readline real realmedia regex rtc samba sasl sdk sdl sensord sndfile sockets sox spamassassin speex spell sql sqlite sqlite3 srt sse sse2 ssl startup-notification subtitles subversion suexec suhosin svg sysfs syslog tcpd teletext tga theora tiff timidity tivo transcode truetype type1 udev unicode urandom usb utf8 vcd vcdimager vfat vidix vim vim-pager vim-with-x virus-scan visualization vorbis win32codecs wma wmf wxwindows x264 x86 xanim xchat xemacs xfs xft xine xinetd xml xml2 xmlreader xorg xpm xprint xrandr xscreensaver xv xvid xvmc yahoo zip zlib zoran" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 	emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m 	maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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 auth_digest authn_dbd dbd ident imagemap" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en es ja" USERLAND="GNU" VIDEO_CARDS="intel"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 4 Jeremy Huddleston Sequoia 2008-11-03 20:48:09 UTC
Additionally, this only seems to happen when C_INCLUDE_PATH is set.  If I 'unset C_INCLUDE_PATH' first, this is not a problem.
Comment 5 SpanKY gentoo-dev 2008-12-07 20:28:42 UTC
afaik, this is correct behavior