diff -Naur gcc-3.2.2-20030218.orig/configure.in gcc-3.2.2-20030218/configure.in --- gcc-3.2.2-20030218.orig/configure.in Tue Sep 24 15:06:53 2002 +++ gcc-3.2.2-20030218/configure.in Wed Sep 10 13:15:28 2003 @@ -812,7 +812,7 @@ noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; *-*-linux*) - noconfigdirs="$noconfigdirs target-newlib target-libgloss" + noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libiberty target-libio target-libstdc++-v3" # linux has rx in libc skipdirs="$skipdirs target-librx" ;; diff -Naur gcc-3.2.2-20030218.orig/gcc/Makefile.in gcc-3.2.2-20030218/gcc/Makefile.in --- gcc-3.2.2-20030218.orig/gcc/Makefile.in Tue Feb 18 13:27:23 2003 +++ gcc-3.2.2-20030218/gcc/Makefile.in Wed Sep 10 13:17:57 2003 @@ -244,7 +244,7 @@ STMP_FIXINC = @STMP_FIXINC@ # Test to see whether exists in the system header files. -LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ] +LIMITS_H_TEST = true target=@target@ target_alias=@target_alias@ @@ -937,18 +937,20 @@ # We call this executable `xgcc' rather than `gcc' # to avoid confusion if the current directory is in the path # and CC is `gcc'. It is renamed to `gcc' when it is installed. -xgcc$(exeext): gcc.o gccspec.o version.o intl.o prefix.o \ - version.o $(LIBDEPS) $(EXTRA_GCC_OBJS) +xgcc$(exeext): gcc.o gccspec.o version.o intl.o prefix.o find_cross.o \ + cross_update_cpu.o version.o $(LIBDEPS) $(EXTRA_GCC_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gcc.o gccspec.o intl.o \ - prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS) + prefix.o version.o find_cross.o cross_update_cpu.o \ + $(EXTRA_GCC_OBJS) $(LIBS) # cpp is to cpp0 as gcc is to cc1. # The only difference from xgcc is that it's linked with cppspec.o # instead of gccspec.o. -cpp$(exeext): gcc.o cppspec.o version.o intl.o prefix.o \ - version.o $(LIBDEPS) $(EXTRA_GCC_OBJS) +cpp$(exeext): gcc.o cppspec.o version.o intl.o prefix.o find_cross.o \ + cross_update_cpu.o version.o $(LIBDEPS) $(EXTRA_GCC_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gcc.o cppspec.o intl.o \ - prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS) + prefix.o version.o find_cross.o cross_update_cpu.o \ + $(EXTRA_GCC_OBJS) $(LIBS) # Dump a specs file to make -B./ read these specs over installed ones. specs: xgcc$(exeext) @@ -1329,6 +1331,13 @@ -DPREFIX=\"$(prefix)\" \ -c $(srcdir)/prefix.c $(OUTPUT_OPTION) +find_cross.o: find_cross.c Makefile + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + -DPREFIX=\"$(prefix)\" \ + -c $(srcdir)/find_cross.c $(OUTPUT_OPTION) + +cross_update_cpu.o: cross_update_cpu.c + convert.o: convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h convert.h toplev.h langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) toplev.h \ @@ -1969,7 +1978,8 @@ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \ cpphash.o cpperror.o cppinit.o cppdefault.o \ - hashtable.o line-map.o mkdeps.o prefix.o version.o mbchar.o + hashtable.o line-map.o mkdeps.o prefix.o version.o mbchar.o \ + find_cross.o prefix.o LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \ $(OBSTACK_H) $(SYSTEM_H) @@ -1994,8 +2004,12 @@ cpplib.o: cpplib.c $(CONFIG_H) $(LIBCPP_DEPS) cpphash.o: cpphash.c $(CONFIG_H) $(LIBCPP_DEPS) cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h + cppinit.o: cppinit.c $(CONFIG_H) $(LIBCPP_DEPS) cppdefault.h \ mkdeps.h prefix.h version.h except.h + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(PREPROCESSOR_DEFINES) -DTARGET_NAME=\"$(target_alias)\" \ + -c $(srcdir)/cppinit.c $(OUTPUT_OPTION) cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) cppdefault.h Makefile $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ @@ -2007,11 +2021,16 @@ # The traditional mode preprocessor, a separate program for ease of # maintenance. Some code is shared with the ISO-C cpp. tradcpp0$(exeext): tradcpp.o tradcif.o cppdefault.o version.o intl.o \ - mkdeps.o $(LIBDEPS) + mkdeps.o $(LIBDEPS) find_cross.o prefix.o $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o tradcpp0$(exeext) \ - tradcpp.o tradcif.o mkdeps.o cppdefault.o version.o intl.o $(LIBS) + tradcpp.o tradcif.o mkdeps.o cppdefault.o version.o intl.o \ + find_cross.o prefix.o $(LIBS) tradcpp.o: tradcpp.c $(CONFIG_H) $(SYSTEM_H) version.h cppdefault.h tradcpp.h + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(PREPROCESSOR_DEFINES) -DTARGET_NAME=\"$(target_alias)\"\ + -c $(srcdir)/tradcpp.c $(OUTPUT_OPTION) + tradcif.o: $(srcdir)/tradcif.c $(CONFIG_H) $(SYSTEM_H) tradcpp.h $(srcdir)/tradcif.c: $(srcdir)/tradcif.y @@ -2023,7 +2042,7 @@ proto: config.status protoize$(exeext) unprotoize$(exeext) SYSCALLS.c.X -PROTO_OBJS = intl.o version.o cppdefault.o +PROTO_OBJS = intl.o version.o cppdefault.o find_cross.o prefix.o protoize$(exeext): protoize.o $(PROTO_OBJS) $(LIBDEPS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ protoize.o $(PROTO_OBJS) $(LIBS) @@ -2037,6 +2056,7 @@ SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(DRIVER_DEFINES) \ + $(PREPROCESSOR_DEFINES) -DTARGET_NAME=\"$(target_alias)\"\ $(srcdir)/protoize.c $(OUTPUT_OPTION)) unprotoize.o: protoize.c $(srcdir)/../include/getopt.h \ @@ -2045,6 +2065,7 @@ SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \ $(CC) -c -DUNPROTOIZE $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(DRIVER_DEFINES) \ + $(PREPROCESSOR_DEFINES) -DTARGET_NAME=\"$(target_alias)\"\ $(srcdir)/protoize.c $(OUTPUT_OPTION)) # This info describes the target machine, so compile with GCC just built. @@ -2153,14 +2174,10 @@ $(SHELL) $${srcdir}/mkfixinc.sh $(build_canonical) $(target)) # Build fixed copies of system files. -stmp-fixinc: fixinc.sh gsyslimits.h +stmp-fixinc: gsyslimits.h rm -rf include; mkdir include -chmod a+rx include - (TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); pwd`; \ - SHELL='$(SHELL)' ;\ - export TARGET_MACHINE srcdir SHELL ; \ - $(SHELL) ./fixinc.sh `pwd`/include $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS); \ - rm -f include/syslimits.h; \ + (rm -f include/syslimits.h; \ if [ -f include/limits.h ]; then \ mv include/limits.h include/syslimits.h; \ else \ @@ -2238,7 +2255,7 @@ # The idea is to make sure fix-header gets built, # but not rerun fixproto after each stage # just because fix-header's mtime has changed. -fixhdr.ready: fix-header$(build_exeext) +fixhdr.ready: -if [ -f fixhdr.ready ] ; then \ true; \ else \ @@ -2540,9 +2557,9 @@ -if [ -f gcc-cross$(exeext) ] ; then \ rm -f $(DESTDIR)$(bindir)/$(CPP_CROSS_NAME)$(exeext); \ $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(DESTDIR)$(bindir)/$(CPP_CROSS_NAME)$(exeext); \ - if [ x$(cpp_install_dir) != x ]; then \ - rm -f $(DESTDIR)$(prefix)/$(cpp_install_dir)/$(CPP_CROSS_NAME)$(exeext); \ - $(INSTALL_PROGRAM) -m 755 cpp$(exeext) $(DESTDIR)$(prefix)/$(cpp_install_dir)/$(CPP_CROSS_NAME)$(exeext); \ + if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \ + rm -f $(DESTDIR)$(gcc_tooldir)/bin/cpp$(exeext); \ + ln -s ../../bin/$(CPP_CROSS_NAME)$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/cpp$(exeext); \ else true; fi; \ else \ rm -f $(DESTDIR)$(bindir)/$(CPP_INSTALL_NAME)$(exeext); \ @@ -2569,6 +2586,8 @@ $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(includedir) $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(infodir) $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(slibdir) + $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(gcc_tooldir) + $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(gcc_tooldir)/bin $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(man1dir) $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(man7dir) @@ -2606,8 +2625,12 @@ if [ -f gcc-cross$(exeext) ] ; then \ rm -f $(DESTDIR)$(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \ $(INSTALL_PROGRAM) protoize$(exeext) $(DESTDIR)$(bindir)/$(PROTOIZE_CROSS_NAME)$(exeext); \ + rm -f $(DESTDIR)$(gcc_tooldir)/bin/protoize$(exeext); \ + ln -s ../../bin/$(PROTOIZE_CROSS_NAME)$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/protoize$(exeext); \ rm -f $(DESTDIR)$(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \ $(INSTALL_PROGRAM) unprotoize$(exeext) $(DESTDIR)$(bindir)/$(UNPROTOIZE_CROSS_NAME)$(exeext); \ + rm -f $(DESTDIR)$(gcc_tooldir)/bin/unprotoize$(exeext); \ + ln -s ../../bin/$(UNPROTOIZE_CROSS_NAME)$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/unprotoize$(exeext); \ else \ rm -f $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \ $(INSTALL_PROGRAM) protoize$(exeext) $(DESTDIR)$(bindir)/$(PROTOIZE_INSTALL_NAME)$(exeext); \ @@ -2638,7 +2661,7 @@ $(INSTALL_PROGRAM) gcc-cross$(exeext) $(DESTDIR)$(bindir)/$(GCC_CROSS_NAME)$(exeext); \ if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \ rm -f $(DESTDIR)$(gcc_tooldir)/bin/gcc$(exeext); \ - $(INSTALL_PROGRAM) gcc-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gcc$(exeext); \ + ln -s ../../bin/$(GCC_CROSS_NAME)$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gcc$(exeext); \ else true; fi; \ else \ rm -f $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext); \ diff -Naur gcc-3.2.2-20030218.orig/gcc/config/rs6000/linux.h gcc-3.2.2-20030218/gcc/config/rs6000/linux.h --- gcc-3.2.2-20030218.orig/gcc/config/rs6000/linux.h Wed Jan 29 14:23:13 2003 +++ gcc-3.2.2-20030218/gcc/config/rs6000/linux.h Wed Sep 10 13:15:28 2003 @@ -81,8 +81,176 @@ state data appropriately. See unwind-dw2.c for the structs. */ #ifdef IN_LIBGCC2 -#include -#include + +/* from bits/type.h(wordsize.h,typesizes.h) (glibc-2.3) */ +#define __pid_t int +#define __uid_t unsigned long +#define __clock_t long int +#define size_t int + + +/* from bits/siginfo.h (glibc-2.3) */ +typedef union sigval { + int sival_int; + void *sival_ptr; +} sigval_t; + +# define __SI_MAX_SIZE 128 +#define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) + +typedef struct siginfo + { + int si_signo; /* Signal number. */ + int si_errno; /* If non-zero, an errno value associated with + this signal, as defined in . */ + int si_code; /* Signal code. */ + + union + { + int _pad[__SI_PAD_SIZE]; + + /* kill(). */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + } _kill; + + /* POSIX.1b timers. */ + struct + { + unsigned int _timer1; + unsigned int _timer2; + } _timer; + + /* POSIX.1b signals. */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + sigval_t si_sigval; /* Signal value. */ + } _rt; + + /* SIGCHLD. */ + struct + { + __pid_t si_pid; /* Which child. */ + __uid_t si_uid; /* Real user ID of sending process. */ + int si_status; /* Exit value or signal. */ + __clock_t si_utime; + __clock_t si_stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ + struct + { + void *si_addr; /* Faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL. */ + struct + { + long int si_band; /* Band event for SIGPOLL. */ + int si_fd; + } _sigpoll; + } _sifields; + } siginfo_t; + +/* from asm/ptrace.h (Linux-2.4) */ +struct pt_regs { + unsigned long gpr[32]; + unsigned long nip; + unsigned long msr; + unsigned long orig_gpr3; /* Used for restarting system calls */ + unsigned long ctr; + unsigned long link; + unsigned long xer; + unsigned long ccr; + unsigned long mq; /* 601 only (not used at present) */ + /* Used on APUS to hold IPL value. */ + unsigned long trap; /* Reason for being here */ + unsigned long dar; /* Fault registers */ + unsigned long dsisr; + unsigned long result; /* Result of a system call */ +}; + +/* from asm/sigcontext.h (Linux-2.4) */ +struct sigcontext_struct { + unsigned long _unused[4]; + int signal; + unsigned long handler; + unsigned long oldmask; + struct pt_regs *regs; +}; + +#define sigcontext sigcontext_struct + +/* from asm/signal.h (Linux-2.4) */ +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +typedef struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + +/* from bits/sigset.h (glibc-2.3) */ +# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) +typedef struct + { + unsigned long int __val[_SIGSET_NWORDS]; + } __sigset_t; + +/* from sys/ucontext.h (glibc-2.3) */ +#define NGREG 19 +typedef int greg_t; +typedef greg_t gregset_t[NGREG]; +struct _libc_fpreg +{ + unsigned short int significand[4]; + unsigned short int exponent; +}; +struct _libc_fpstate +{ + unsigned long int cw; + unsigned long int sw; + unsigned long int tag; + unsigned long int ipoff; + unsigned long int cssel; + unsigned long int dataoff; + unsigned long int datasel; + struct _libc_fpreg _st[8]; + unsigned long int status; +}; +typedef struct _libc_fpstate *fpregset_t; + +/* Context to describe whole processor state. */ +typedef struct + { + gregset_t gregs; + /* Due to Linux's history we have to use a pointer here. The SysV/i386 + ABI requires a struct with the values. */ + fpregset_t fpregs; + unsigned long int oldmask; + unsigned long int cr2; + } mcontext_t; + +/* Userlevel context. */ +typedef struct ucontext + { + unsigned long int uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + __sigset_t uc_sigmask; + struct _libc_fpstate __fpregs_mem; + } ucontext_t; enum { SIGNAL_FRAMESIZE = 64 }; #endif diff -Naur gcc-3.2.2-20030218.orig/gcc/config/rs6000/rs6000.c gcc-3.2.2-20030218/gcc/config/rs6000/rs6000.c --- gcc-3.2.2-20030218.orig/gcc/config/rs6000/rs6000.c Wed Jan 29 14:23:13 2003 +++ gcc-3.2.2-20030218/gcc/config/rs6000/rs6000.c Wed Sep 10 13:15:28 2003 @@ -358,6 +358,9 @@ {"403", PROCESSOR_PPC403, MASK_POWERPC | MASK_SOFT_FLOAT | MASK_NEW_MNEMONICS | MASK_STRICT_ALIGN, POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64}, + {"405pm", PROCESSOR_PPC403, + MASK_POWERPC | MASK_NEW_MNEMONICS | MASK_STRICT_ALIGN, + POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64}, {"405", PROCESSOR_PPC405, MASK_POWERPC | MASK_SOFT_FLOAT | MASK_NEW_MNEMONICS, POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64}, diff -Naur gcc-3.2.2-20030218.orig/gcc/config/rs6000/rs6000.h gcc-3.2.2-20030218/gcc/config/rs6000/rs6000.h --- gcc-3.2.2-20030218.orig/gcc/config/rs6000/rs6000.h Thu Aug 8 20:09:18 2002 +++ gcc-3.2.2-20030218/gcc/config/rs6000/rs6000.h Wed Oct 22 13:15:28 2003 @@ -66,6 +66,7 @@ %{mcpu=rsc1: -D_ARCH_PWR} \ %{mcpu=401: -D_ARCH_PPC} \ %{mcpu=403: -D_ARCH_PPC} \ +%{mcpu=405pm: -D_ARCH_PPC} \ %{mcpu=405: -D_ARCH_PPC} \ %{mcpu=505: -D_ARCH_PPC} \ %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \ @@ -107,6 +108,7 @@ %{mcpu=401: -mppc} \ %{mcpu=403: -m403} \ %{mcpu=405: -m405} \ +%{mcpu=405pm: -m405} \ %{mcpu=505: -mppc} \ %{mcpu=601: -m601} \ %{mcpu=602: -mppc} \ @@ -117,7 +119,7 @@ %{mcpu=604e: -mppc} \ %{mcpu=620: -mppc} \ %{mcpu=740: -mppc} \ -%{mcpu=7400: -mppc} \ +%{mcpu=7400: -m7400} \ %{mcpu=7450: -mppc} \ %{mcpu=750: -mppc} \ %{mcpu=801: -mppc} \ diff -Naur gcc-3.2.2-20030218.orig/gcc/config/rs6000/t-ppcos gcc-3.2.2-20030218/gcc/config/rs6000/t-ppcos --- gcc-3.2.2-20030218.orig/gcc/config/rs6000/t-ppcos Wed Nov 21 13:02:15 2001 +++ gcc-3.2.2-20030218/gcc/config/rs6000/t-ppcos Wed Sep 10 13:15:28 2003 @@ -1,8 +1,10 @@ # Multilibs for a powerpc hosted ELF target (linux, SVR4) -MULTILIB_OPTIONS = msoft-float -MULTILIB_DIRNAMES = nof -MULTILIB_EXTRA_OPTS = fPIC mstrict-align +MULTILIB_OPTIONS = mcpu=403/mcpu=7400/mcpu=750/mcpu=603/mcpu=860/mcpu=405pm fPIC +MULTILIB_DIRNAMES = m403 m7400 m750 m603 m860 m405pm pic +MULTILIB_EXTRA_OPTS = mstrict-align MULTILIB_EXCEPTIONS = -MULTILIB_MATCHES = ${MULTILIB_MATCHES_FLOAT} +MULTILIB_MATCHES = fPIC=mrelocatable-lib \ + fPIC=mrelocatable \ + fPIC=fpic diff -Naur gcc-3.2.2-20030218.orig/gcc/config/t-linux gcc-3.2.2-20030218/gcc/config/t-linux --- gcc-3.2.2-20030218.orig/gcc/config/t-linux Wed Nov 27 00:07:57 2002 +++ gcc-3.2.2-20030218/gcc/config/t-linux Wed Sep 10 13:15:28 2003 @@ -4,11 +4,11 @@ # Compile crtbeginS.o and crtendS.o with pic. CRTSTUFF_T_CFLAGS_S = $(CRTSTUFF_T_CFLAGS) -fPIC # Compile libgcc2.a with pic. -TARGET_LIBGCC2_CFLAGS = -fPIC +TARGET_LIBGCC2_CFLAGS = -fPIC -I../../gcc/glibc-include # Override t-slibgcc-elf-ver to export some libgcc symbols with # the symbol versions that glibc used. -SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver +# SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver # Use unwind-dw2-fde-glibc LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \ diff -Naur gcc-3.2.2-20030218.orig/gcc/config.gcc gcc-3.2.2-20030218/gcc/config.gcc --- gcc-3.2.2-20030218.orig/gcc/config.gcc Mon Feb 3 23:58:16 2003 +++ gcc-3.2.2-20030218/gcc/config.gcc Wed Sep 10 13:15:28 2003 @@ -2860,7 +2860,7 @@ powerpc-*-linux*) tm_file="${tm_file} dbxelf.h elfos.h svr4.h freebsd-spec.h rs6000/sysv4.h rs6000/linux.h" out_file=rs6000/rs6000.c - tmake_file="rs6000/t-ppcos t-slibgcc-elf-ver t-linux rs6000/t-ppccomm" + tmake_file="rs6000/t-ppcos t-linux rs6000/t-ppccomm" ;; powerpc-*-gnu-gnualtivec*) tm_file="${cpu_type}/${cpu_type}.h elfos.h svr4.h freebsd-spec.h gnu.h rs6000/sysv4.h rs6000/linux.h rs6000/linuxaltivec.h rs6000/gnu.h" diff -Naur gcc-3.2.2-20030218.orig/gcc/cp/Make-lang.in gcc-3.2.2-20030218/gcc/cp/Make-lang.in --- gcc-3.2.2-20030218.orig/gcc/cp/Make-lang.in Mon Feb 3 23:58:23 2003 +++ gcc-3.2.2-20030218/gcc/cp/Make-lang.in Wed Sep 10 13:15:28 2003 @@ -71,7 +71,8 @@ po-generated: $(srcdir)/cp/parse.c # Create the compiler driver for g++. -GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o +GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o find_cross.o \ + cross_update_cpu.o g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \ $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS) @@ -160,13 +161,13 @@ chmod a+x $(DESTDIR)$(bindir)/$(GXX_CROSS_NAME)$(exeext); \ rm -f $(DESTDIR)$(bindir)/$(CXX_CROSS_NAME)$(exeext); \ ( cd $(DESTDIR)$(bindir) && \ - $(LN) $(GXX_CROSS_NAME)$(exeext) $(CXX_CROSS_NAME)$(exeext) ); \ + ln -s $(GXX_CROSS_NAME)$(exeext) $(CXX_CROSS_NAME)$(exeext) ); \ if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \ rm -f $(DESTDIR)$(gcc_tooldir)/bin/g++$(exeext); \ - $(INSTALL_PROGRAM) g++-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/g++$(exeext); \ + ln -s ../../bin/$(GXX_CROSS_NAME)$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/g++$(exeext); \ rm -f $(DESTDIR)$(gcc_tooldir)/bin/c++$(exeext); \ ( cd $(DESTDIR)$(gcc_tooldir)/bin && \ - $(LN) g++$(exeext) c++$(exeext) ); \ + ln -s g++$(exeext) c++$(exeext) ); \ else true; fi; \ else \ rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \ diff -Naur gcc-3.2.2-20030218.orig/gcc/cppdefault.c gcc-3.2.2-20030218/gcc/cppdefault.c --- gcc-3.2.2-20030218.orig/gcc/cppdefault.c Wed Oct 3 12:35:01 2001 +++ gcc-3.2.2-20030218/gcc/cppdefault.c Wed Sep 10 13:15:28 2003 @@ -26,53 +26,7 @@ #include "system.h" #include "cppdefault.h" -const struct default_include cpp_include_defaults[] -#ifdef INCLUDE_DEFAULTS -= INCLUDE_DEFAULTS; -#else -= { -#ifdef GPLUSPLUS_INCLUDE_DIR - /* Pick up GNU C++ generic include files. */ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, -#endif -#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR - /* Pick up GNU C++ target-dependent include files. */ - { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1 }, -#endif -#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR - /* Pick up GNU C++ backward and deprecated include files. */ - { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, -#endif -#ifdef LOCAL_INCLUDE_DIR - /* /usr/local/include comes before the fixincluded header files. */ - { LOCAL_INCLUDE_DIR, 0, 0, 1 }, -#endif -#ifdef PREFIX_INCLUDE_DIR - { PREFIX_INCLUDE_DIR, 0, 0, 1 }, -#endif -#ifdef GCC_INCLUDE_DIR - /* This is the dir for fixincludes and for gcc's private headers. */ - { GCC_INCLUDE_DIR, "GCC", 0, 0 }, -#endif -#ifdef CROSS_INCLUDE_DIR - /* One place the target system's headers might be. */ - { CROSS_INCLUDE_DIR, "GCC", 0, 0 }, -#endif -#ifdef TOOL_INCLUDE_DIR - /* Another place the target system's headers might be. */ - { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 }, -#endif -#ifdef SYSTEM_INCLUDE_DIR - /* Some systems have an extra dir of include files. */ - { SYSTEM_INCLUDE_DIR, 0, 0, 0 }, -#endif -#ifdef STANDARD_INCLUDE_DIR - /* /usr/include comes dead last. */ - { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 }, -#endif - { 0, 0, 0, 0 } - }; -#endif /* no INCLUDE_DEFAULTS */ +struct default_include cpp_include_defaults[10]; #ifdef GCC_INCLUDE_DIR const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR; diff -Naur gcc-3.2.2-20030218.orig/gcc/cppdefault.h gcc-3.2.2-20030218/gcc/cppdefault.h --- gcc-3.2.2-20030218.orig/gcc/cppdefault.h Thu Oct 11 19:59:32 2001 +++ gcc-3.2.2-20030218/gcc/cppdefault.h Wed Sep 10 13:15:28 2003 @@ -96,17 +96,22 @@ struct default_include { - const char *const fname; /* The name of the directory. */ - const char *const component; /* The component containing the directory + char * fname; /* The name of the directory. */ + char * component; /* The component containing the directory (see update_path in prefix.c) */ - const int cplusplus; /* Only look here if we're compiling C++. */ - const int cxx_aware; /* Includes in this directory don't need to + int cplusplus; /* Only look here if we're compiling C++. */ + int cxx_aware; /* Includes in this directory don't need to be wrapped in extern "C" when compiling C++. */ }; -extern const struct default_include cpp_include_defaults[]; +extern struct default_include cpp_include_defaults[]; extern const char cpp_GCC_INCLUDE_DIR[]; extern const size_t cpp_GCC_INCLUDE_DIR_len; +extern const char *fullprogname; +extern char *replace(char*, char*); +extern int find_family_cpu(char *, char **); +extern char *get_std_prefix(); + #endif /* ! GCC_CPPDEFAULT_H */ diff -Naur gcc-3.2.2-20030218.orig/gcc/cppinit.c gcc-3.2.2-20030218/gcc/cppinit.c --- gcc-3.2.2-20030218.orig/gcc/cppinit.c Tue Oct 8 15:28:36 2002 +++ gcc-3.2.2-20030218/gcc/cppinit.c Wed Sep 10 13:15:28 2003 @@ -851,6 +851,131 @@ const struct default_include *p; const char *specd_prefix = CPP_OPTION (pfile, include_prefix); + +#define add_to_include(_var, _fname, _component, _cplusplus, _cxx_aware) \ + do { _var.fname = _fname; \ + _var.component = _component; \ + _var.cplusplus = _cplusplus; \ + _var.cxx_aware = _cxx_aware; \ + } while (0); + + + char *cross_dir; + char *family_cpu; + int ind = 0; + + + if (!find_family_cpu(fullprogname, &family_cpu)) { + cpp_fatal(pfile, "CROSS_COMPILE variable is not set or invalid"); + } + + /* Set new standard prefix to use instead of /cdt */ + find_cross_dir(fullprogname, &cross_dir, 1); + if (cross_dir) + { + set_std_prefix(cross_dir, strlen(cross_dir)); + + /* Generate the cpp_include_defaults. It can not be initialized because + some paths can depend on values of environment variables */ +#ifdef GPLUSPLUS_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif +#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_BACKWARD_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GCC_INCLUDE_DIR), + "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, CROSS_INCLUDE_DIR), + "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, TOOL_INCLUDE_DIR), + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(cross_dir, "/../", family_cpu, + "/usr/include", NULL); + char * gxx_target_include_dir = concat(cross_dir, "/../", family_cpu, + GPLUSPLUS_INCLUDE_DIR, NULL); + char * gxx_target_arch_include_dir = concat(cross_dir, "/../", family_cpu, + GPLUSPLUS_TOOL_INCLUDE_DIR, NULL); + char * gxx_target_backward_include_dir = concat(cross_dir, "/../", + family_cpu, GPLUSPLUS_BACKWARD_INCLUDE_DIR, NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_arch_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_arch_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_backward_include_dir) { + add_to_include(cpp_include_defaults[ind], + gxx_target_backward_include_dir, "G++", 1, 1); + ind++; + } + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + "GCC", 0, 0); + ind++; + } + } + } + else { + /* cross_dir can not be determined */ + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1); + ind++; + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1); + add_to_include(cpp_include_defaults[ind], + GCC_INCLUDE_DIR, "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], CROSS_INCLUDE_DIR, + "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], TOOL_INCLUDE_DIR, + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, "/usr/include", NULL); + char * gxx_target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, GPLUSPLUS_INCLUDE_DIR, + NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + 0, 1, 1); + ind++; + } + + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + 0, 0, 0); + ind++; + } + } + } + + add_to_include(cpp_include_defaults[ind], 0, 0, 0, 0 ); + +#undef add_to_include + /* Several environment variables may add to the include search path. CPATH specifies an additional list of directories to be searched as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, diff -Naur gcc-3.2.2-20030218.orig/gcc/cppmain.c gcc-3.2.2-20030218/gcc/cppmain.c --- gcc-3.2.2-20030218.orig/gcc/cppmain.c Fri May 3 20:19:22 2002 +++ gcc-3.2.2-20030218/gcc/cppmain.c Wed Sep 10 13:15:28 2003 @@ -69,6 +69,8 @@ static cpp_options *options; /* Options of pfile. */ static struct printer print; +char * fullprogname; + int main (argc, argv) int argc; @@ -76,6 +78,8 @@ { general_init (argv[0]); + fullprogname = argv[0]; + /* Construct a reader with default language GNU C89. */ pfile = cpp_create_reader (CLK_GNUC89); options = cpp_get_options (pfile); diff -Naur gcc-3.2.2-20030218.orig/gcc/cross_update_cpu.c gcc-3.2.2-20030218/gcc/cross_update_cpu.c --- gcc-3.2.2-20030218.orig/gcc/cross_update_cpu.c Thu Jan 1 01:00:00 1970 +++ gcc-3.2.2-20030218/gcc/cross_update_cpu.c Wed Sep 10 13:15:28 2003 @@ -0,0 +1,67 @@ +#include +#include + +/* The following structure sets matching between CROSS_COMPILE env. variable + * and --mcpu= flag values + */ + +static struct target_cpu { + char *target_arch; /* cpu specification in CROSS_COMPILE env. variable */ + char *cpu_id; /* cpu specification in the mcpu flag */ +}; + +struct target_cpu ppc_cpu_tbl[] = { + {"4xx", "403" }, + {"4xxFP","405pm"}, + {"74xx", "7400"}, + {"7xx", "750" }, + {"82xx", "603" }, + {"8xx", "860" } +}; + +void cross_update_cpu(argc, argv, family_cpu) + int *argc; + char ***argv; + char *family_cpu; +{ + int i; + char *cpu; + + if (!strncasecmp(family_cpu, "ppc_", 4)) + { + cpu = family_cpu + 4; + + for (i = 0; i < *argc; i++) + { + if (!strncmp((*argv)[i], "-mcpu=", 6)) + break; + } + if (i == *argc) + { + /* The user has not specified cpu option - add it */ + char **newargv = xmalloc((*argc + 1)*sizeof(char *)); + char *cpu_id = NULL; + + for (i = 0; i < sizeof(ppc_cpu_tbl)/sizeof(ppc_cpu_tbl[0]); i++) + { + if (! strcmp(ppc_cpu_tbl[i].target_arch, cpu)) { + cpu_id = ppc_cpu_tbl[i].cpu_id; + break; + } + } + if (cpu_id) + { + newargv[0] = (*argv)[0]; + newargv[1] = xmalloc(strlen(cpu_id) + 7); + strcpy(newargv[1], "-mcpu="); + strcat(newargv[1], cpu_id); + for (i = 2; i < *argc + 1; i++) + newargv[i] = (*argv)[i-1]; + *argv = newargv; + (*argc)++; + } + } + } +} + + diff -Naur gcc-3.2.2-20030218.orig/gcc/find_cross.c gcc-3.2.2-20030218/gcc/find_cross.c --- gcc-3.2.2-20030218.orig/gcc/find_cross.c Thu Jan 1 01:00:00 1970 +++ gcc-3.2.2-20030218/gcc/find_cross.c Wed Sep 10 13:15:28 2003 @@ -0,0 +1,273 @@ +/* Utility to update paths from internal to external forms. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef PATH_SEPARATOR +#define PATH_SEPARATOR ':' +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +static void remove_relative_paths (char * path); +void find_cross_dir(char *progname, char **ptr, int is_cpp0); +char * replace (char *new_prefix, char *path); +int find_family_cpu(char * program_name, char **family_cpu); + +/* Remove relative paths -- .. and . */ +static void +remove_relative_paths (char * path) +{ + char *p, *s; + + p = path; + while ((p = strchr (p, DIR_SEPARATOR))) + { + p++; + if (*p == '.') + { + p++; + if (*p == DIR_SEPARATOR) + { + /* Translate "/./" ==> "/" */ + strcpy (p-2, p); + } + else if (*p == '.' && *(p+1) == DIR_SEPARATOR) + { + /* Translate "//../" ==> "/" */ + s = p + 1; + p -= 3; + while ( p > path && *p != DIR_SEPARATOR) + p--; + strcpy (p, s); + } + } + } +} + +/* Find cross directory root */ +void find_cross_dir(char *progname, char **ptr, int is_cpp0) +{ + char *fullpath = (char *) xmalloc(MAXPATHLEN); + char *linkfile = (char *) xmalloc(MAXPATHLEN); + char *realpath = (char *) xmalloc(MAXPATHLEN); + struct stat file; + int ret = 0; + char *p; + int i; + + *ptr = 0; + + if (strchr (progname, '/')) + { + if (progname[0] == '/') + { + /* We have absolute path */ + strcpy (fullpath, progname); + } else { + /* We have relative path, prepend $cwd */ + getcwd (fullpath, MAXPATHLEN); + strcat (fullpath, "/"); + strcat (fullpath, progname); + } + } else { + /* Search pathlist for matching progname */ + char *path; + char *beg, *end; + + path = getenv("PATH"); + beg = path; + while (1) + { + for (end = beg; *end && *end != PATH_SEPARATOR; end++) ; + strncpy (fullpath, beg, end - beg); + fullpath[end - beg] = '\0'; + if (fullpath[end - beg - 1] == DIR_SEPARATOR) + fullpath[end - beg - 1] = '\0'; + if (strcmp (fullpath, ".") == 0) + getcwd (fullpath, MAXPATHLEN); + strcat (fullpath, "/"); + strcat (fullpath, progname); + if ((lstat (fullpath, &file) == 0) && + (S_ISREG(file.st_mode) || S_ISLNK(file.st_mode))) break; + if (*end == '\0') { + free(realpath); + goto RET; /* Not found on path */ + } + beg = end + 1; + } + } + + /* Resolve all symbolic links in the full path */ + while (fullpath[0]) + { + char *t, *s, *q; + int len, off; + + while ((ret = lstat (fullpath, &file)) == 0 && S_ISLNK(file.st_mode)) + { + /* fullpath is a link */ + linkfile[readlink (fullpath, linkfile, MAXPATHLEN)] = '\0'; + if (linkfile[0] == DIR_SEPARATOR) + { + /* Link replaces path */ + strcpy (fullpath, linkfile); + } + else + { + /* Link is relative to current directory */ + q = strrchr (fullpath, DIR_SEPARATOR); + *(q + 1) = '\0'; + strcat (fullpath, linkfile); + } + /* We might have added more relative paths -- remove them */ + remove_relative_paths (fullpath); + } + if (ret) + { + free(realpath); + goto RET; + } + /* Strip off the last segment of the path */ + if ((q = strrchr (fullpath, DIR_SEPARATOR))) + *q++ = '\0'; + else + q = fullpath; + + /* Shift realpath right to make room for new segment and slash */ + off = strlen (q) + 1; + len = strlen (realpath); + for (i = len; i >= 0; i--) + realpath [off + i] = realpath [i]; + + /* Copy new segment to realpath */ + s = q; + t = realpath + 1; + while (*s) + *t++ = *s++; + + /* Stick in separator at beginning of segment. */ + realpath[0] = DIR_SEPARATOR; + } + + /* Split executable name from path */ + p = strrchr (realpath, DIR_SEPARATOR); + *++p = '\0'; + + remove_relative_paths (realpath); + + /* Exclude trailing segments to get to the .../usr directory */ + /* cpp0 is located in the /usr/lib/gcc-lib// directory */ + /* all binaries are located in the /usr/bin */ + p = realpath; + for (i = 0; i< (is_cpp0 ? 5 : 2) ; i++) { + if (!(p = strrchr(realpath, '/'))) { + free(realpath); + goto RET; + } + *p = '\0'; + } + *ptr = realpath; + +RET: + free (fullpath); + free (linkfile); +} + +/* Replace the initial occurance of PREFIX by the specified prefix */ + +char * +replace (char *new_prefix, char *path) +{ + int len = strlen(PREFIX); + + if (strcmp(new_prefix, PREFIX) && + ! strncmp (path, PREFIX, len)) + { + char *new = (char *) xmalloc(strlen(new_prefix) + + strlen(path) - len + 1); + strcpy(new, new_prefix); + strcat(new, path + len); + return new; + } + return path; +} + +int +find_family_cpu(char * program_name, char **family_cpu) +{ + char *p, *ep, *tmp = 0; + int len; + + p = getenv("CROSS_COMPILE"); + if (p && *p) + { + p = basename(p); + len = strlen(p); + *family_cpu = xmalloc(len + 1); + strcpy(*family_cpu, p); + if ((*family_cpu)[len - 1] == '-') + (*family_cpu)[len - 1] = '\0'; + } + + /* try to determine family_cpu using program name */ + p = basename(program_name); + ep = strrchr(p, '-'); + if (ep && strchr(p, '_')) + { + len = ep - p; + tmp = (char *) xmalloc(len + 1); + strncpy(tmp, p, len); + tmp[len] = '\0'; + } + + if (! *family_cpu && ! tmp) + { + /* No way to set family_cpu - error */ + return 0; + } + if (tmp) + { + if (*family_cpu) + { + if (strcmp(tmp, *family_cpu)) + { + /* CROSS_COMPILER value is inconsistent with program name */ + /* CROSS_COMPILER value is inconsistent with program name */ + return 0; + } + free(tmp); + return 1; + } + *family_cpu = tmp; + setenv("CROSS_COMPILE", tmp, 0); + return 1; + } + return 1; +} + diff -Naur gcc-3.2.2-20030218.orig/gcc/gcc.c gcc-3.2.2-20030218/gcc/gcc.c --- gcc-3.2.2-20030218.orig/gcc/gcc.c Fri Jan 17 18:31:22 2003 +++ gcc-3.2.2-20030218/gcc/gcc.c Wed Sep 10 13:15:28 2003 @@ -747,6 +747,14 @@ static struct user_specs *user_specs_head, *user_specs_tail; +char *cross_dir; +char *family_cpu; + +extern char *replace(char *, char *); +extern int find_family_cpu(char *, char **); +extern void cross_update_cpu(int *, char ***, char*); + + /* This defines which switch letters take arguments. */ #define DEFAULT_SWITCH_TAKES_ARG(CHAR) \ @@ -3804,6 +3812,28 @@ (such as cpp) rather than those of the host system. */ /* Use 2 as fourth arg meaning try just the machine as a suffix, as well as trying the machine and the version. */ + if (cross_dir) + { +#ifndef OS2 + add_prefix (&exec_prefixes, + replace(cross_dir, standard_exec_prefix), + "GCC", PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); + add_prefix (&exec_prefixes, + replace(cross_dir, standard_exec_prefix), + "BINUTILS", PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0); + add_prefix (&exec_prefixes, + replace(cross_dir, standard_exec_prefix_1), + "BINUTILS", PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0); +#endif + add_prefix (&startfile_prefixes, + replace(cross_dir, standard_exec_prefix), + "BINUTILS", PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); + add_prefix (&startfile_prefixes, + replace(cross_dir, standard_exec_prefix_1), + "BINUTILS", PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); + } + else { + #ifndef OS2 add_prefix (&exec_prefixes, standard_exec_prefix, "GCC", PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); @@ -3817,6 +3847,7 @@ PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); add_prefix (&startfile_prefixes, standard_exec_prefix_1, "BINUTILS", PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0); + } tooldir_prefix = concat (tooldir_base_prefix, spec_machine, dir_separator_str, NULL); @@ -3851,12 +3882,42 @@ dir_separator_str, tooldir_prefix, NULL); } + if (cross_dir) { + add_prefix (&exec_prefixes, + concat (replace(cross_dir, tooldir_prefix), + "bin", dir_separator_str, NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); + add_prefix (&startfile_prefixes, + concat (replace(cross_dir, tooldir_prefix), + "lib", dir_separator_str, NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1); + if (family_cpu && *family_cpu) + { + add_prefix (&startfile_prefixes, + concat (cross_dir, "/../", family_cpu, "/lib/", NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); + add_prefix (&startfile_prefixes, + concat (cross_dir, "/../", family_cpu, "/usr/lib/", NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); + } + } else { add_prefix (&exec_prefixes, concat (tooldir_prefix, "bin", dir_separator_str, NULL), "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); add_prefix (&startfile_prefixes, concat (tooldir_prefix, "lib", dir_separator_str, NULL), "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1); + if (family_cpu && *family_cpu) + { + add_prefix (&startfile_prefixes, + concat (tooldir_prefix, "/../../", family_cpu, "/lib/", NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); + add_prefix (&startfile_prefixes, + concat (tooldir_prefix, "/../../", family_cpu, "/usr/lib/", NULL), + "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0); + } + + } /* More prefixes are enabled in main, after we read the specs file and determine whether this is cross-compilation or not. */ @@ -5807,6 +5868,10 @@ --p; programname = p; + if (! find_family_cpu(programname, &family_cpu)) { + fatal("CROSS_COMPILE variable is not set or invalid"); + } + xmalloc_set_program_name (programname); #ifdef GCC_DRIVER_HOST_INITIALIZATION @@ -5894,6 +5959,17 @@ putenv (INIT_ENVIRONMENT); #endif + /* Set new standard prefix to use instead of /cdt */ + find_cross_dir(argv[0], &cross_dir, 0); + if (cross_dir) { + set_std_prefix(cross_dir, strlen(cross_dir)); + } + /* If CROSS_COMPILE is defined and a user have not specified the + "-mcpu=..." option we must insert -mcpu= option + in the argv list + */ + cross_update_cpu(&argc, &argv, family_cpu); + /* Make a table of what switches there are (switches, n_switches). Make a table of specified input files (infiles, n_infiles). Decode switches that are handled locally. */ @@ -6025,7 +6101,11 @@ if (print_search_dirs) { - printf (_("install: %s%s\n"), standard_exec_prefix, machine_suffix); + if (cross_dir) { + printf (_("install: %s/lib/gcc-lib/%s\n"), cross_dir, machine_suffix); + } else { + printf (_("install: %s%s\n"), standard_exec_prefix, machine_suffix); + } printf (_("programs: %s\n"), build_search_list (&exec_prefixes, "", 0)); printf (_("libraries: %s\n"), build_search_list (&startfile_prefixes, "", 0)); return (0); diff -Naur gcc-3.2.2-20030218.orig/gcc/glibc-include/pthread.h gcc-3.2.2-20030218/gcc/glibc-include/pthread.h --- gcc-3.2.2-20030218.orig/gcc/glibc-include/pthread.h Thu Jan 1 01:00:00 1970 +++ gcc-3.2.2-20030218/gcc/glibc-include/pthread.h Wed Sep 10 13:15:28 2003 @@ -0,0 +1,181 @@ +/* Linuxthreads - a simple clone()-based implementation of Posix */ +/* threads for Linux. */ + +/* This header file combines several header files from glibc-2.3. If the + source glibc headers are changed this file should be changed too. */ + +#ifndef _PTHREAD_H +#define _PTHREAD_H 1 + +/* from sys/cdefs.h */ +#define __THROW +#define __const const +#define __restrict + +/* from bits/sched.h */ +struct __sched_param + { + int __sched_priority; + }; + +/* from bits/initspin.h */ +#define __LOCK_INITIALIZER { 0, 0 } + +/* from bits/pthreadtypes.h */ +struct _pthread_fastlock +{ + long int __status; /* "Free" or "taken" or head of waiting list */ + int __spinlock; /* Used by compare_and_swap emulation. Also, + adaptive SMP lock stores spin count here. */ +}; + +/* Thread descriptors */ +typedef struct _pthread_descr_struct *_pthread_descr; + +/* Attributes for threads. */ +typedef struct __pthread_attr_s +{ + int __detachstate; + int __schedpolicy; + struct __sched_param __schedparam; + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; +} pthread_attr_t; + +/* Keys for thread-specific data */ +typedef unsigned int pthread_key_t; + +/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */ +/* (The layout is unnatural to maintain binary compatibility + with earlier releases of LinuxThreads.) */ +typedef struct +{ + int __m_reserved; /* Reserved for future use */ + int __m_count; /* Depth of recursive locking */ + _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */ + int __m_kind; /* Mutex kind: fast, recursive or errcheck */ + struct _pthread_fastlock __m_lock; /* Underlying fast lock */ +} pthread_mutex_t; + +/* Attribute for mutex. */ +typedef struct +{ + int __mutexkind; +} pthread_mutexattr_t; + +/* Once-only execution */ +typedef int pthread_once_t; + +/* Thread identifiers */ +typedef unsigned long int pthread_t; + +/* from pthread.h */ +#define PTHREAD_MUTEX_INITIALIZER \ + {0, 0, 0, PTHREAD_MUTEX_TIMED_NP, __LOCK_INITIALIZER} + +/* Values for attributes. */ +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +#define PTHREAD_ONCE_INIT 0 + +/* Function for handling threads. */ +/* Create a thread with given attributes ATTR (or default attributes + if ATTR is NULL), and call function START_ROUTINE with given + arguments ARG. */ +extern int pthread_create (pthread_t *__restrict __threadp, + __const pthread_attr_t *__restrict __attr, + void *(*__start_routine) (void *), + void *__restrict __arg) __THROW; +/* Functions for mutex handling. */ + +/* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the + default values if later is NULL. */ +extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex, + __const pthread_mutexattr_t *__restrict + __mutex_attr) __THROW; + +/* Destroy MUTEX. */ +extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW; + +/* Try to lock MUTEX. */ +extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW; + +/* Wait until lock for MUTEX becomes available and lock it. */ +extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW; + +/* Unlock MUTEX. */ +extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW; + +/* Functions for handling thread-specific data. */ + +/* Create a key value identifying a location in the thread-specific + data area. Each thread maintains a distinct thread-specific data + area. DESTR_FUNCTION, if non-NULL, is called with the value + associated to that key when the key is destroyed. + DESTR_FUNCTION is not called if the value associated is NULL when + the key is destroyed. */ +extern int pthread_key_create (pthread_key_t *__key, + void (*__destr_function) (void *)) __THROW; + +/* Destroy KEY. */ +extern int pthread_key_delete (pthread_key_t __key) __THROW; + +/* Store POINTER in the thread-specific data slot identified by KEY. */ +extern int pthread_setspecific (pthread_key_t __key, + __const void *__pointer) __THROW; + +/* Return current value of the thread-specific data slot identified by KEY. */ +extern void *pthread_getspecific (pthread_key_t __key) __THROW; + +/* Functions for handling initialization. */ + +/* Guarantee that the initialization function INIT_ROUTINE will be called + only once, even if pthread_once is executed several times with the + same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or + extern variable initialized to PTHREAD_ONCE_INIT. */ +extern int pthread_once (pthread_once_t *__once_control, + void (*__init_routine) (void)) __THROW; +#endif /* pthread.h */ + diff -Naur gcc-3.2.2-20030218.orig/gcc/libgcc2.c gcc-3.2.2-20030218/gcc/libgcc2.c --- gcc-3.2.2-20030218.orig/gcc/libgcc2.c Thu Oct 10 17:39:24 2002 +++ gcc-3.2.2-20030218/gcc/libgcc2.c Wed Sep 10 13:15:28 2003 @@ -1141,7 +1141,7 @@ #undef double #undef MIN #undef MAX -#include +#include UWtype __fixunsxfSI (XFtype a) @@ -1163,7 +1163,7 @@ #undef double #undef MIN #undef MAX -#include +#include UWtype __fixunsdfSI (DFtype a) @@ -1185,7 +1185,7 @@ #undef double #undef MIN #undef MAX -#include +#include UWtype __fixunssfSI (SFtype a) diff -Naur gcc-3.2.2-20030218.orig/gcc/main.c gcc-3.2.2-20030218/gcc/main.c --- gcc-3.2.2-20030218.orig/gcc/main.c Mon Oct 22 11:07:03 2001 +++ gcc-3.2.2-20030218/gcc/main.c Wed Sep 10 13:15:28 2003 @@ -21,6 +21,8 @@ #include "system.h" #include "toplev.h" +const char *fullprogname; + int main PARAMS ((int argc, char **argv)); /* We define main() to call toplev_main(), which is defined in toplev.c. @@ -32,5 +34,7 @@ int argc; char **argv; { + fullprogname = argv[0]; + return toplev_main (argc, argv); } diff -Naur gcc-3.2.2-20030218.orig/gcc/prefix.c gcc-3.2.2-20030218/gcc/prefix.c --- gcc-3.2.2-20030218.orig/gcc/prefix.c Thu Oct 11 19:59:45 2001 +++ gcc-3.2.2-20030218/gcc/prefix.c Wed Sep 10 13:15:28 2003 @@ -298,3 +298,8 @@ { std_prefix = save_string (prefix, len); } + +char *get_std_prefix() +{ + return std_prefix; +} diff -Naur gcc-3.2.2-20030218.orig/gcc/protoize.c gcc-3.2.2-20030218/gcc/protoize.c --- gcc-3.2.2-20030218.orig/gcc/protoize.c Wed Apr 17 15:35:40 2002 +++ gcc-3.2.2-20030218/gcc/protoize.c Wed Sep 10 13:15:28 2003 @@ -38,6 +38,10 @@ /* Include getopt.h for the sake of getopt_long. */ #include "getopt.h" +extern void find_cross_dir(char *progname, char **ptr, int is_cpp0); +extern void set_std_prefix(const char *prefix, int len); +extern char *get_std_prefix(); + /* Macro to see if the path elements match. */ #ifdef HAVE_DOS_BASED_FILE_SYSTEM #define IS_SAME_PATH_CHAR(a,b) (TOUPPER (a) == TOUPPER (b)) @@ -4620,6 +4624,130 @@ usage (); } } + + /* Fill in the cpp_include_default array */ + { char *cross_dir; + char *family_cpu; + int ind = 0; + +#define add_to_include(_var, _fname, _component, _cplusplus, _cxx_aware) \ + do { _var.fname = _fname; \ + _var.component = _component; \ + _var.cplusplus = _cplusplus; \ + _var.cxx_aware = _cxx_aware; \ + } while (0); + + if (!find_family_cpu(argv[0], &family_cpu)) { + notice ("%s: CROSS_COMPILE variable is not set or invalid\n", pname); + exit (FATAL_EXIT_CODE); + } + + /* Set new standard prefix to use instead of /cdt */ + find_cross_dir(argv[0], &cross_dir, 1); + if (cross_dir) + { + set_std_prefix(cross_dir, strlen(cross_dir)); + + /* Generate the cpp_include_defaults. It can not be initialized because + some paths can depend on values of environment variables */ +#ifdef GPLUSPLUS_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif +#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_BACKWARD_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GCC_INCLUDE_DIR), + "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, CROSS_INCLUDE_DIR), + "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, TOOL_INCLUDE_DIR), + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(cross_dir, "/../", family_cpu, + "/usr/include", NULL); + char * gxx_target_include_dir = concat(cross_dir, "/../", family_cpu, + GPLUSPLUS_INCLUDE_DIR, NULL); + char * gxx_target_arch_include_dir = concat(cross_dir, "/../", family_cpu, GPLUSPLUS_TOOL_INCLUDE_DIR, NULL); + char * gxx_target_backward_include_dir = concat(cross_dir, "/../", + family_cpu, GPLUSPLUS_BACKWARD_INCLUDE_DIR, NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_arch_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_arch_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_backward_include_dir) { + add_to_include(cpp_include_defaults[ind], + gxx_target_backward_include_dir, "G++", 1, 1); + ind++; + } + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + "GCC", 0, 0); + ind++; + } + } + } + else { + /* cross_dir can not be determined */ + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1); + ind++; + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1); + add_to_include(cpp_include_defaults[ind], + GCC_INCLUDE_DIR, "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], CROSS_INCLUDE_DIR, + "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], TOOL_INCLUDE_DIR, + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, "/usr/include", NULL); + char * gxx_target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, GPLUSPLUS_INCLUDE_DIR, + NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + 0, 1, 1); + ind++; + } + + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + 0, 0, 0); + ind++; + } + } + } + + add_to_include(cpp_include_defaults[ind], 0, 0, 0, 0); + +#undef add_to_include + } /* Set up compile_params based on -p and -c options. */ munge_compile_params (params); diff -Naur gcc-3.2.2-20030218.orig/gcc/tradcpp.c gcc-3.2.2-20030218/gcc/tradcpp.c --- gcc-3.2.2-20030218.orig/gcc/tradcpp.c Mon Feb 3 23:58:17 2003 +++ gcc-3.2.2-20030218/gcc/tradcpp.c Wed Sep 10 13:15:28 2003 @@ -29,6 +29,10 @@ typedef unsigned char U_CHAR; +extern void find_cross_dir(char *progname, char **ptr, int is_cpp0); +extern void set_std_prefix(const char *prefix, int len); +extern char *get_std_prefix(); + /* Name under which this program was invoked. */ static const char *progname; @@ -833,6 +837,130 @@ const struct default_include *di; struct file_name_list *old_last_include = last_include; struct file_name_list *dirtmp; + + /* Fill in cpp_include_defaults */ +#define add_to_include(_var, _fname, _component, _cplusplus, _cxx_aware) \ + do { _var.fname = _fname; \ + _var.component = _component; \ + _var.cplusplus = _cplusplus; \ + _var.cxx_aware = _cxx_aware; \ + } while (0); + + char *cross_dir; + char *family_cpu; + int ind = 0; + + if (!find_family_cpu(argv[0], &family_cpu)) { + fatal("CROSS_COMPILE variable is not set or invalid"); + } + + /* Set new standard prefix to use instead of /cdt */ + find_cross_dir(argv[0], &cross_dir, 1); + if (cross_dir) + { + set_std_prefix(cross_dir, strlen(cross_dir)); + + /* Generate the cpp_include_defaults. It can not be initialized because + some paths can depend on values of environment variables */ +#ifdef GPLUSPLUS_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif +#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GPLUSPLUS_BACKWARD_INCLUDE_DIR), + "G++", 1, 1); + ind++; +#endif + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, GCC_INCLUDE_DIR), + "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, CROSS_INCLUDE_DIR), + "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], + replace(cross_dir, TOOL_INCLUDE_DIR), + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(cross_dir, "/../", family_cpu, + "/usr/include", NULL); + char * gxx_target_include_dir = concat(cross_dir, "/../", family_cpu, + GPLUSPLUS_INCLUDE_DIR, NULL); + char * gxx_target_arch_include_dir = concat(cross_dir, "/../", + family_cpu, GPLUSPLUS_TOOL_INCLUDE_DIR, NULL); + char * gxx_target_backward_include_dir = concat(cross_dir, "/../", + family_cpu, GPLUSPLUS_BACKWARD_INCLUDE_DIR, NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_arch_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_arch_include_dir, + "G++", 1, 1); + ind++; + } + if (gxx_target_backward_include_dir) { + add_to_include(cpp_include_defaults[ind], + gxx_target_backward_include_dir, "G++", 1, 1); + ind++; + } + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + "GCC", 0, 0); + ind++; + } + } + } + else { + /* cross_dir can not be determined */ + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1); + ind++; + add_to_include(cpp_include_defaults[ind], + GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1); + add_to_include(cpp_include_defaults[ind], + GCC_INCLUDE_DIR, "GCC", 0, 0); + ind++; + add_to_include(cpp_include_defaults[ind], CROSS_INCLUDE_DIR, "GCC", 0, 0); + ind++; +#ifdef TOOL_INCLUDE_DIR + add_to_include(cpp_include_defaults[ind], TOOL_INCLUDE_DIR, + "BINUTILS", 0, 1); + ind++; +#endif + { + char *target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, "/usr/include", NULL); + char * gxx_target_include_dir = concat(get_std_prefix(), "/../", + family_cpu, GPLUSPLUS_INCLUDE_DIR, + NULL); + if (gxx_target_include_dir) { + add_to_include(cpp_include_defaults[ind], gxx_target_include_dir, + 0, 1, 1); + ind++; + } + + if (target_include_dir) { + add_to_include(cpp_include_defaults[ind], target_include_dir, + 0, 0, 0); + ind++; + } + } + } + + add_to_include(cpp_include_defaults[ind], 0, 0, 0, 0); + +#undef add_to_include + + /* Now we can start up cpp_include_defaults processing */ for (di = cpp_include_defaults; di->fname; di++) { if (di->cplusplus) continue;