This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Compute flags for target in configure, not Makefile
On Jul 24, 2000, Jason Merrill <jason@redhat.com> wrote:
>>>>>> Alexandre Oliva <aoliva@redhat.com> writes:
>> On Jul 22, 2000, Jason Merrill <jason@redhat.com> wrote:
>>> This seems wrong to me; the $(build_tooldir)/lib and
>>> $(build_tooldir)/include stuff should be used iff we aren't using
>>> newlib, but your patch causes it to always be used.
>> I think they should always be used, so that we get consistent
>> behavior. Otherwise we'll have different behavior depending on
>> whether libsubdir exists or not.
> OK, I suppose, though they shouldn't ever find anything there.
Why? If you've already got any headers installed there, you'd
probably like to use them, especially in case you're doing a glibc
build, not a newlib build. Anyway, we should look at those
directories after any directories in the source or build tree. Here's
a new version of the patch, tested on i686-pc-linux-gnu native and
cross i686-cygwin.
>>> Why can't the build_tooldir stuff all be part of FLAGS_FOR_TARGET?
>> Of course it can, I just don't think it should.
> Why not?
Because it should only be used when we're building GCC. But then, we
can obviously test whether the GCC sources are present. That's what
the revised patch does.
> Especially if you want to include them unconditionally.
I didn't really mean unconditionally :-)
> Also, your patch puts -B$$r/gcc/ twice in CC_FOR_TARGET.
Indeed. Fixed.
Ok to install?
Index: ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Moved all
complexity to...
(FLAGS_FOR_TARGET): New macro.
(GCC_FOR_TARGET, CHILL_FOR_TARGET): Use FLAGS_FOR_TARGET.
* configure.in (FLAGS_FOR_TARGET): Define and subst it. Add
ld build dir to -L path.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/Makefile.in,v
retrieving revision 1.50
diff -u -c -r1.50 Makefile.in
*** Makefile.in 2000/07/24 04:33:01 1.50
--- Makefile.in 2000/07/24 18:17:34
***************
*** 210,275 ****
$(INSTALL_X11_MODULES) \
$(INSTALL_DOSREL)
CC_FOR_TARGET = ` \
if [ -f $$r/gcc/xgcc ] ; then \
! if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
! case "$(target_canonical)" in \
! i[3456]86-*-cygwin*) \
! echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -L$$r/$(TARGET_SUBDIR)/winsup -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/include -idirafter $$s/winsup/cygwin/include -idirafter $$s/winsup/w32api/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc; \
! ;; \
! *) \
! echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
! ;; \
! esac \
! else \
! echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include; \
! fi; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CC); \
else \
t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
fi; \
! fi`
# If CC_FOR_TARGET is not overriden on the command line, then this
# variable is passed down to the gcc Makefile, where it is used to
# build libgcc2.a. We define it here so that it can itself be
# overridden on the command line.
! GCC_FOR_TARGET = $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include
CHILL_FOR_TARGET = ` \
if [ -f $$r/gcc/xgcc ] ; then \
! echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -L$$r/gcc/ch/runtime/; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CC); \
else \
t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
fi; \
! fi`
CXX_FOR_TARGET = ` \
if [ -f $$r/gcc/g++ ] ; then \
! if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
! case "$(target_canonical)" in \
! i[3456]86-*-cygwin*) \
! echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/cygwin/include -idirafter $$s/winsup/w32api/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc -L$$r/$(TARGET_SUBDIR)/libstdc++; \
! ;; \
! *) \
! echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc -L$$r/$(TARGET_SUBDIR)/libstdc++; \
! ;; \
! esac \
! else \
! echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include -L$$r/$(TARGET_SUBDIR)/libstdc++; \
! fi; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CXX); \
else \
t='$(program_transform_name)'; echo c++ | sed -e 's/x/x/' $$t; \
fi; \
! fi`
AS_FOR_TARGET = ` \
if [ -f $$r/gas/as-new ] ; then \
--- 210,256 ----
$(INSTALL_X11_MODULES) \
$(INSTALL_DOSREL)
+ # Defined by configure.in
+ FLAGS_FOR_TARGET =
+
CC_FOR_TARGET = ` \
if [ -f $$r/gcc/xgcc ] ; then \
! echo $$r/gcc/xgcc; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CC); \
else \
t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
fi; \
! fi` $(FLAGS_FOR_TARGET)
# If CC_FOR_TARGET is not overriden on the command line, then this
# variable is passed down to the gcc Makefile, where it is used to
# build libgcc2.a. We define it here so that it can itself be
# overridden on the command line.
! GCC_FOR_TARGET = $$r/gcc/xgcc $(FLAGS_FOR_TARGET)
CHILL_FOR_TARGET = ` \
if [ -f $$r/gcc/xgcc ] ; then \
! echo $$r/gcc/xgcc -L$$r/gcc/ch/runtime/; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CC); \
else \
t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
fi; \
! fi` $(FLAGS_FOR_TARGET)
CXX_FOR_TARGET = ` \
if [ -f $$r/gcc/g++ ] ; then \
! echo $$r/gcc/g++ -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CXX); \
else \
t='$(program_transform_name)'; echo c++ | sed -e 's/x/x/' $$t; \
fi; \
! fi` $(FLAGS_FOR_TARGET)
AS_FOR_TARGET = ` \
if [ -f $$r/gas/as-new ] ; then \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/configure.in,v
retrieving revision 1.53
diff -u -c -r1.53 configure.in
*** configure.in 2000/07/24 04:29:33 1.53
--- configure.in 2000/07/24 18:17:35
***************
*** 1216,1224 ****
--- 1216,1257 ----
gxx_include_dir=${gxx_include_dir}
fi
+ if test -d ${topsrcdir}/gcc; then
+ # Directories specified with -B are searched in reverse order of
+ # appearance in the command line. They're searched for libraries
+ # after any -L flags, but they're searched for headers before any
+ # -isystem flags. Fortunately, we don't expect include directories to
+ # exist in build_tooldir/{bin,lib}, and we want gcc/include to be
+ # searched first.
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/'
+ fi
+ case " $skipdirs " in
+ *" target-newlib "*) ;;
+ *)
+ case "$target" in
+ i[3456]86-*-cygwin*)
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -isystem $$s/winsup/include -isystem $$s/winsup/cygwin/include -isystem $$s/winsup/w32api/include -isystem $$s/newlib/libc/sys/cygwin -isystem $$s/newlib/libc/sys/cygwin32' ;;
+ esac
+
+ # If we're building newlib, use its generic headers last, but search
+ # for any libc-related directories first (so make it the last -B
+ # switch).
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -nostdinc -B$$r/$(TARGET_SUBDIR)/newlib/ -isystem $$r/$(TARGET_SUBDIR)/newlib/targ-include -isystem $$s/newlib/libc/include'
+ ;;
+ esac
+ if test -d ${topsrcdir}/gcc; then
+ # Search for pre-installed headers if nothing else fits.
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -isystem $(build_tooldir)/include'
+ fi
+ if test "x${with_gnu_ld}" = xyes; then
+ # Arrange for us to find uninstalled linker scripts.
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/ld'
+ fi
+
targargs="--cache-file=../config.cache --host=${target_alias} --build=${build_alias} ${targargs}"
sed -e "s:^TARGET_CONFIGDIRS[ ]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
-e "s%^CONFIG_ARGUMENTS[ ]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
+ -e "s%^FLAGS_FOR_TARGET[ ]*=.*$%FLAGS_FOR_TARGET = ${FLAGS_FOR_TARGET}%" \
-e "s%^TARGET_SUBDIR[ ]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
-e "s%^gxx_include_dir[ ]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
Makefile > Makefile.tem
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me