Bug 234076 - 'gcc -m32 -print-file-name=include' reports wrong path
'gcc -m32 -print-file-name=include' reports wrong path
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-26 17:31 EDT by Bernie Innocenti
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-03-27 15:51:24 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
output of gcc -m32 -print-file-name=include (27.91 KB, application/octet-stream)
2007-03-27 15:38 EDT, Bernie Innocenti
no flags Details
output of strace gcc -print-file-name=include (17.64 KB, application/octet-stream)
2007-03-27 15:39 EDT, Bernie Innocenti
no flags Details

  None (edit)
Description Bernie Innocenti 2007-03-26 17:31:29 EDT
This works fine:
 # gcc -print-file-name=include
 /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include

But with -m32 it prints nonsense:
 # gcc -print-file-name=include -m32
 /lib/../lib/include

gcc-HEAD works:
 # gcc-HEAD -m32 -print-file-name=include
 /usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/include

Version info:
 # gcc --version
 gcc (GCC) 4.1.2 20070317 (Red Hat 4.1.2-5)
Comment 1 Jakub Jelinek 2007-03-27 11:37:39 EDT
Can't reproduce:
gcc --version; gcc -print-file-name=include; gcc -m32 -print-file-name=include;
gcc -print-file-name=include -m32
gcc (GCC) 4.1.2 20070317 (Red Hat 4.1.2-5)
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.

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include

(nor can I reproduce this with FC6 or RHEL5 gcc).
Comment 2 Bernie Innocenti 2007-03-27 15:33:50 EDT
I'm puzzled... attaching strace output for:

  gcc -print-file-name=include
  gcc -m32 -print-file-name=include
Comment 3 Bernie Innocenti 2007-03-27 15:38:56 EDT
Created attachment 151071 [details]
output of gcc -m32 -print-file-name=include
Comment 4 Bernie Innocenti 2007-03-27 15:39:54 EDT
Created attachment 151073 [details]
output of strace gcc -print-file-name=include
Comment 5 Bernie Innocenti 2007-03-27 15:46:56 EDT
Diffing the two traces, I see gcc is looking for
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/32/include, which doesn't exist.  Then it
tries all kinds of fancy paths and eventually finds that silly result.
Comment 6 Jakub Jelinek 2007-03-27 15:51:24 EDT
You have /lib/../lib/include file or directory, that isn't supposed to exist
and in that case it would soon find what you expect.  The GCC file search
algorithm is quite complicated, but /lib is one of the tool dirs and
../lib is the -m32 on x86_64 multi-os-directory.
Not sure if you have /lib as a symlink or have /include file/directory, in
any case this isn't a gcc bug.
Comment 7 Bernie Innocenti 2007-03-27 15:51:55 EDT
Oh, gosh!

The problem is that I really *had* /lib/include in my system since 1999.
That's why you couldn't reproduce it.

But I'd still consider it a bug: gcc built from svn trunk doesn't fall
in the trap.  Maybe it's RedHat specific, maybe not.

Maybe it has something to do with --prefix=/usr ? I read somewhare that
/usr is special in some packages such as glibc because it also implies /
as a search path.
Comment 8 Jakub Jelinek 2007-03-27 16:02:40 EDT
Yes, --prefix=/usr is special, this is nothing Red Hat specific.
Comment 9 Bernie Innocenti 2007-03-27 16:24:08 EDT
I think we can leave this alone, then.

For the record, the 4.3 search path appears very different:

bender:/# gcc -m32 -print-search-dirs 
install: /usr/lib/gcc/x86_64-redhat-linux/4.1.2/
programs:
=/usr/libexec/gcc/x86_64-redhat-linux/4.1.2/:/usr/libexec/gcc/x86_64-redhat-linux/4.1.2/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.1.2/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../x86_64-redhat-linux/bin/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../x86_64-redhat-linux/bin/
libraries:
=/usr/lib/gcc/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../x86_64-redhat-linux/lib/x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../x86_64-redhat-linux/lib/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../x86_64-redhat-linux/4.1.2/:/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../:/lib/x86_64-redhat-linux/4.1.2/:/lib/:/usr/lib/x86_64-redhat-linux/4.1.2/:/usr/lib/

bender:# /usr/local/src/gcc/x86_64-linux-HEAD-install/bin/gcc -m32
-print-search-dirs
install:
/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/
programs:
=/usr/local/src/gcc/x86_64-linux-HEAD-install/libexec/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/libexec/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/bin/
libraries:
=/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/lib/x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/lib/../lib/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../x86_64-unknown-linux-gnu/4.3.0/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/:/lib/x86_64-unknown-linux-gnu/4.3.0/:/lib/../lib/:/usr/lib/x86_64-unknown-linux-gnu/4.3.0/:/usr/lib/../lib/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/lib/:/usr/local/src/gcc/x86_64-linux-HEAD-install/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../:/lib/:/usr/lib/

Note You need to log in before you can comment on or make changes to this bug.