This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc-2.95.1: gcc_tooldir prefix/exec-prefix problem


Under gcc-2.95.1 and Solaris2.5.1, gcc/configure attempts to calculate
gcc_tooldir from the values of prefix and exec_prefix.  Unfortunately,
the code assumes that exec_prefix is a subdirectory of prefix.

In the past, exec_prefix could be anywhere.  I did not find
any documentation for this change that exec_prefix has to
be a sub directory of prefix.

The Ptolemy project has used prefix=$PTOLEMY/gnu/$PTARCH and
exec-prefix=$PTOLEMY/gnu/common for at least 5 years, and this 
problem was not present in egcs-1.1.1

gcc-2.95.1/gcc/configure contains the following:
--start--
# If $(exec_prefix) exists and is not the same as $(prefix), then compute an
# absolute path for gcc_tooldir based on inserting the number of up-directory
# movements required to get from $(exec_prefix) to $(prefix) into the basic
# $(libsubdir)/@(unlibsubdir) based path.
# Don't set gcc_tooldir to tooldir since that's only passed in by the toplevel
# make and thus we'd get different behavior depending on where we built the
# sources.
if test x$exec_prefix = xNONE -o x$exec_prefix = x$prefix; then
    gcc_tooldir='$(libsubdir)/$(unlibsubdir)/../$(target_alias)'
else
# An explanation of the sed strings:
#  -e 's|^\$(prefix)||'   matches and eliminates 'prefix' from 'exec_prefix'
#  -e 's|/$||'            match a trailing forward slash and eliminates it
#  -e 's|^[^/]|/|'        forces the string to start with a forward slash (*)
#  -e 's|/[^/]*|../|g'    replaces each occurance of /<directory> with ../
#
# (*) Note this pattern overwrites the first character of the string
# with a forward slash if one is not already present.  This is not a
# problem because the exact names of the sub-directories concerned is
# unimportant, just the number of them matters.
#
# The practical upshot of these patterns is like this:
#
#  prefix     exec_prefix        result
#  ------     -----------        ------
#   /foo        /foo/bar          ../
#   /foo/       /foo/bar          ../
#   /foo        /foo/bar/         ../
#   /foo/       /foo/bar/         ../
#   /foo        /foo/bar/ugg      ../../
#
    dollar='$$'
    gcc_tooldir="\$(libsubdir)/\$(unlibsubdir)/\`echo \$(exec_prefix) | sed -e 's|^\$(prefix)||' -e 's|/\$(dollar)||' -e 's|^[^/]|/|' -e 's|/[^/]*|../|g'\`\$(target_alias)"
fi

--end--


If I run configure with:
/users/cxh/pt/src/gnu/src/gcc/configure \
				--srcdir=/users/cxh/pt/src/gnu/src/gcc \
				--prefix=/users/cxh/pt/gnu/common \
				--exec-prefix=/users/cxh/pt/gnu/sol2.5 \
				--enable-shared

then the makefile generates an invalid gcc_tooldir value
that points to a directory that could never exist.

To reproduce this, I pulled the essential parts of gcc/Makefile
out and created ~/tmp/tool.mk with these lines.
(The bug rule at the end is not in the original Makefile, it
merely echos the values of some variables)

--start--
target_alias=sparc-sun-solaris2.5.1
# [...]

# Common prefix for installation directories.
# NOTE: This directory must exist when you start installation.
prefix = /users/cxh/pt/gnu/common
# Directory in which to put localized header files. On the systems with
# gcc as the native cc, `local_prefix' may not be `prefix' which is
# `/usr'.
# NOTE: local_prefix *should not* default from prefix.
local_prefix = /usr/local
# Directory in which to put host dependent programs and libraries
exec_prefix = /users/cxh/pt/gnu/sol2.5
# Directory in which to put the executable for the command `gcc'
bindir = ${exec_prefix}/bin
# Directory in which to put the directories used by the compiler.
libdir = ${exec_prefix}/lib
# Directory in which the compiler finds executables, libraries, etc.
libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(version)
# Used to produce a relative $(gcc_tooldir) in gcc.o
unlibsubdir = ../../..
# Directory in which to find other cross-compilation tools and headers.
dollar = $$
# Used in install-cross.
gcc_tooldir = $(libsubdir)/$(unlibsubdir)/`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/$(dollar)||' -e 's|^[^/]|/|' -e 's|/[^/]*|../|g'`$(target_alias)

bug:
	@echo "prefix =      $(prefix)"
	@echo "exec-prefix = $(exec_prefix)"
	echo "gcc_tooldir = $(gcc_tooldir)"
--end--

Here, I run the makefile
cxh@maury 12% make -f ~/tmp/tool.mk
prefix =      /users/cxh/pt/gnu/common
exec-prefix = /users/cxh/pt/gnu/sol2.5
echo "gcc_tooldir = /users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1//../../../`echo /users/cxh/pt/gnu/sol2.5 | sed -e 's|^/users/cxh/pt/gnu/common||' -e 's|/$||' -e 's|^[^/]|/|' -e 's|/[^/]*|../|g'`sparc-sun-solaris2.5.1"
gcc_tooldir = /users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1//../../../../../../../../sparc-sun-solaris2.5.1


Note that gcc_tooldir is not found

cxh@maury 13% ls /users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1/
2.95.1/		include/
cxh@maury 14% ls /users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1//../../../../../../../..
maury1/	maury2/	maury3/	maury4/	maury5/
cxh@maury 15% ls /users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1//../../../../../../../../sparc-sun-solaris2.5.1
/users/cxh/pt/gnu/sol2.5/lib/gcc-lib/sparc-sun-solaris2.5.1//../../../../../../../../sparc-sun-solaris2.5.1 not found
cxh@maury 16% 

-Christopher

Christopher Hylands    cxh@eecs.berkeley.edu  University of California
Ptolemy/Gigascale Silicon Research Center     US Mail: 558 Cory Hall #1770
ph: (510)643-9841 fax:(510)642-2739	      Berkeley, CA 94720-1770
home: (510)526-4010 (if busy -4068)	      (Office: 493 Cory)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]