This is the mail archive of the gcc-patches@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]

patch for fixinc to fix Solaris2 hosted cross compiler build failure


I get inconsistent results from fixinc.sh when there are no input directories
that need fixing.

wilson<36>/bin/sh ./fixinc.sh `pwd`/tmp /non/existant
Fixing headers into /wilson/two/comp-tools/=tx49-elf/gcc/tmp for mips64tx49-unknown-elf target
./fixinc.sh: /non/existant: No such file or directory
wilson<37>echo $?
0
wilson<38>uname -a
Linux wilson.cygnus.com 2.0.33 #1 Wed Mar 18 12:49:51 PST 1998 i686 unknown

ryobi<45>/bin/sh ./fixinc.sh `pwd`/tmp /non/existant
Fixing headers into /horton/wilson/comp-tools/X-tx49-elf/gcc/tmp for mips64tx49-unknown-elf target
./fixinc.sh: /non/existant: does not exist
ryobi<46>echo $status
1
ryobi<47>uname -a
SunOS ryobi.cygnus.com 5.5.1 Generic_103640-29 sun4u sparc SUNW,Ultra-30

The result is that my cross-compiler builds fail on a sparc/solaris2 host,
but work fine on an x86/linux host.

The problem is that the construct
	cd foo || continue
does not work as intended with the Solaris2 /bin/sh.  It exits the shell
script, instead of continuing the loop.  This can be seen with a simple
script.  On a Solaris2 machine, this does not print "/usr".

#!/bin/sh
INPUTLIST="/tmp /non/existent /usr"

for INPUT in ${INPUTLIST} ; do
cd ${INPUT} || continue
echo here `pwd`
done

This can be fixed by testing for the directory before trying to cd into it.
I propose the following patch to fix this problem.

Wed Jan 19 20:39:17 2000  Jim Wilson  <wilson@cygnus.com>

	* fixinc/inclhack.tpl: Test for directory before trying to cd into it.
	* fixinc/fixincl.sh, fixinc/inclhack.sh: Regenerate.
	
Index: fixincl.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.sh,v
retrieving revision 1.26
diff -p -r1.26 fixincl.sh
*** fixincl.sh	2000/01/19 21:41:04	1.26
--- fixincl.sh	2000/01/20 04:45:47
*************** for INPUT in ${INPUTLIST} ; do
*** 138,144 ****
  
  cd ${ORIGDIR}
  
! cd ${INPUT} || continue
  INPUT=`${PWDCMD}`
  
  #
--- 138,149 ----
  
  cd ${ORIGDIR}
  
! # This originally used cd || continue, however, that does not work with the
! # Solaris2 /bin/sh.
! if [ ! -d ${INPUT} ]; then
!   continue
! fi
! cd ${INPUT}
  INPUT=`${PWDCMD}`
  
  #
Index: inclhack.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/inclhack.sh,v
retrieving revision 1.54
diff -p -r1.54 inclhack.sh
*** inclhack.sh	2000/01/19 21:41:04	1.54
--- inclhack.sh	2000/01/20 04:45:47
*************** for INPUT in ${INPUTLIST} ; do
*** 139,145 ****
  
  cd ${ORIGDIR}
  
! cd ${INPUT} || continue
  INPUT=`${PWDCMD}`
  
  #
--- 139,150 ----
  
  cd ${ORIGDIR}
  
! # This originally used cd || continue, however, that does not work with the
! # Solaris2 /bin/sh.
! if [ ! -d ${INPUT} ]; then
!   continue
! fi
! cd ${INPUT}
  INPUT=`${PWDCMD}`
  
  #
Index: inclhack.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/inclhack.tpl,v
retrieving revision 1.14
diff -p -r1.14 inclhack.tpl
*** inclhack.tpl	1999/12/29 22:58:06	1.14
--- inclhack.tpl	2000/01/20 04:45:47
*************** for INPUT in ${INPUTLIST} ; do
*** 135,141 ****
  
  cd ${ORIGDIR}
  
! cd ${INPUT} || continue
  INPUT=`${PWDCMD}`
  
  #
--- 135,146 ----
  
  cd ${ORIGDIR}
  
! # This originally used cd || continue, however, that does not work with the
! # Solaris2 /bin/sh.
! if [ ! -d ${INPUT} ]; then
!   continue
! fi
! cd ${INPUT}
  INPUT=`${PWDCMD}`
  
  #

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