summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Tilley <lv@gentoo.org>2004-06-04 23:19:52 +0000
committerTravis Tilley <lv@gentoo.org>2004-06-04 23:19:52 +0000
commitc3e85b7f1c51f1883c3e287e709c7202ce36d635 (patch)
tree9d4ee0d192ca4d1ad9674ab6454d76d64fe36acb /sys-devel
parentAdded to ~ppc (diff)
downloadgentoo-2-c3e85b7f1c51f1883c3e287e709c7202ce36d635.tar.gz
gentoo-2-c3e85b7f1c51f1883c3e287e709c7202ce36d635.tar.bz2
gentoo-2-c3e85b7f1c51f1883c3e287e709c7202ce36d635.zip
updated the ice hack patch and added a stack protector fix for cc1
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/gcc/ChangeLog7
-rw-r--r--sys-devel/gcc/files/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch11
-rw-r--r--sys-devel/gcc/files/3.4.0/gcc34-ice-hack.patch327
-rw-r--r--sys-devel/gcc/gcc-3.4.0-r6.ebuild18
4 files changed, 359 insertions, 4 deletions
diff --git a/sys-devel/gcc/ChangeLog b/sys-devel/gcc/ChangeLog
index a47f553615fa..e3b80c181e04 100644
--- a/sys-devel/gcc/ChangeLog
+++ b/sys-devel/gcc/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for sys-devel/gcc
# Copyright 2002-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/ChangeLog,v 1.264 2004/06/04 15:27:38 lv Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/ChangeLog,v 1.265 2004/06/04 23:19:52 lv Exp $
+
+ 04 Jun 2004; Travis Tilley <lv@gentoo.org>
+ +files/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch,
+ +files/3.4.0/gcc34-ice-hack.patch, gcc-3.4.0-r6.ebuild:
+ updated the ice hack patch and added a stack protector fix for cc1
04 Jun 2004; Travis Tilley <lv@gentoo.org> gcc-3.4.0-r6.ebuild:
stable on amd64
diff --git a/sys-devel/gcc/files/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch b/sys-devel/gcc/files/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch
new file mode 100644
index 000000000000..72bce28a552b
--- /dev/null
+++ b/sys-devel/gcc/files/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch
@@ -0,0 +1,11 @@
+--- gcc/Makefile.in.mps 2004-06-01 22:06:17.000000000 +0200
++++ gcc/Makefile.in 2004-06-01 22:06:56.000000000 +0200
+@@ -1845,7 +1845,7 @@ $(out_object_file): $(out_file) $(CONFIG
+ output.h $(INSN_ATTR_H) $(SYSTEM_H) toplev.h $(TARGET_H) libfuncs.h \
+ $(TARGET_DEF_H) function.h sched-int.h $(TM_P_H) $(EXPR_H) $(OPTABS_H) \
+ langhooks.h
+- $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
++ $(CC) -c $(ALL_CFLAGS) -fno-stack-protector $(ALL_CPPFLAGS) $(INCLUDES) \
+ $(out_file) $(OUTPUT_OPTION)
+
+ # Build auxiliary files that support ecoff format.
diff --git a/sys-devel/gcc/files/3.4.0/gcc34-ice-hack.patch b/sys-devel/gcc/files/3.4.0/gcc34-ice-hack.patch
new file mode 100644
index 000000000000..dd1669f5bc6e
--- /dev/null
+++ b/sys-devel/gcc/files/3.4.0/gcc34-ice-hack.patch
@@ -0,0 +1,327 @@
+2004-01-23 Jakub Jelinek <jakub@redhat.com>
+
+ * system.h (ICE_EXIT_CODE): Define.
+ * gcc.c (execute): Don't free first string early, but at the end
+ of the function. Call retry_ice if compiler exited with
+ ICE_EXIT_CODE.
+ (retry_ice): New function.
+ * diagnostic.c (diagnostic_count_diagnostic,
+ diagnostic_action_after_output, error_recursion): Exit with
+ ICE_EXIT_CODE instead of FATAL_EXIT_CODE.
+
+--- gcc/system.h.jj 2004-01-19 17:29:30.000000000 +0100
++++ gcc/system.h 2004-01-21 11:53:41.000000000 +0100
+@@ -153,6 +153,10 @@ extern int errno;
+ # endif
+ #endif
+
++#ifndef ICE_EXIT_CODE
++# define ICE_EXIT_CODE 27
++#endif
++
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+--- gcc/gcc.c.jj 2004-01-21 11:45:20.000000000 +0100
++++ gcc/gcc.c 2004-01-21 11:56:46.000000000 +0100
+@@ -352,6 +352,9 @@ static void init_gcc_specs (struct obsta
+ #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+ static const char *convert_filename (const char *, int, int);
+ #endif
++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
++static void retry_ice (const char *prog, const char **argv);
++#endif
+
+ static const char *if_exists_spec_function (int, const char **);
+ static const char *if_exists_else_spec_function (int, const char **);
+@@ -2753,7 +2756,7 @@ execute (void)
+ if (commands[i].pid == -1)
+ pfatal_pexecute (errmsg_fmt, errmsg_arg);
+
+- if (string != commands[i].prog)
++ if (i && string != commands[i].prog)
+ free ((void *) string);
+ }
+
+@@ -2831,6 +2834,17 @@ See %s for instructions.",
+ else if (WIFEXITED (status)
+ && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
+ {
++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
++ /* For ICEs in cc1, cc1obj, cc1plus see if it is
++ reproducible or not. */
++ char *p;
++ if (WEXITSTATUS (status) == ICE_EXIT_CODE
++ && j == 0
++ && (p = strrchr (commands[j].argv[0], DIR_SEPARATOR))
++ && ! strncmp (p + 1, "cc1", 3))
++ retry_ice (commands[j].prog, commands[j].argv);
++#endif
++
+ if (WEXITSTATUS (status) > greatest_status)
+ greatest_status = WEXITSTATUS (status);
+ ret_code = -1;
+@@ -2842,6 +2856,10 @@ See %s for instructions.",
+ break;
+ }
+ }
++
++ if (commands[0].argv[0] != commands[0].prog)
++ free ((PTR) commands[0].argv[0]);
++
+ return ret_code;
+ }
+ }
+@@ -5809,6 +5827,224 @@ give_switch (int switchnum, int omit_fir
+ switches[switchnum].validated = 1;
+ }
+
++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
++#define RETRY_ICE_ATTEMPTS 2
++
++static void
++retry_ice (const char *prog, const char **argv)
++{
++ int nargs, out_arg = -1, quiet = 0, attempt;
++ int pid, retries, sleep_interval;
++ const char **new_argv;
++ char *temp_filenames[RETRY_ICE_ATTEMPTS * 2 + 2];
++
++ if (input_filename == NULL || ! strcmp (input_filename, "-"))
++ return;
++
++ for (nargs = 0; argv[nargs] != NULL; ++nargs)
++ /* Only retry compiler ICEs, not preprocessor ones. */
++ if (! strcmp (argv[nargs], "-E"))
++ return;
++ else if (argv[nargs][0] == '-' && argv[nargs][1] == 'o')
++ {
++ if (out_arg == -1)
++ out_arg = nargs;
++ else
++ return;
++ }
++ /* If the compiler is going to output any time information,
++ it might varry between invocations. */
++ else if (! strcmp (argv[nargs], "-quiet"))
++ quiet = 1;
++ else if (! strcmp (argv[nargs], "-ftime-report"))
++ return;
++
++ if (out_arg == -1 || !quiet)
++ return;
++
++ memset (temp_filenames, '\0', sizeof (temp_filenames));
++ new_argv = alloca ((nargs + 3) * sizeof (const char *));
++ memcpy (new_argv, argv, (nargs + 1) * sizeof (const char *));
++ new_argv[nargs++] = "-frandom-seed=0";
++ new_argv[nargs] = NULL;
++ if (new_argv[out_arg][2] == '\0')
++ new_argv[out_arg + 1] = "-";
++ else
++ new_argv[out_arg] = "-o-";
++
++ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS + 1; ++attempt)
++ {
++ int fd;
++ int status;
++
++ temp_filenames[attempt * 2] = make_temp_file (".out");
++ temp_filenames[attempt * 2 + 1] = make_temp_file (".err");
++
++ if (attempt == RETRY_ICE_ATTEMPTS)
++ {
++ int i;
++ int fd1, fd2;
++ struct stat st1, st2;
++ size_t n, len;
++ char *buf;
++
++ buf = xmalloc (8192);
++
++ for (i = 0; i < 2; ++i)
++ {
++ fd1 = open (temp_filenames[i], O_RDONLY);
++ fd2 = open (temp_filenames[2 + i], O_RDONLY);
++
++ if (fd1 < 0 || fd2 < 0)
++ {
++ i = -1;
++ close (fd1);
++ close (fd2);
++ break;
++ }
++
++ if (fstat (fd1, &st1) < 0 || fstat (fd2, &st2) < 0)
++ {
++ i = -1;
++ close (fd1);
++ close (fd2);
++ break;
++ }
++
++ if (st1.st_size != st2.st_size)
++ {
++ close (fd1);
++ close (fd2);
++ break;
++ }
++
++ len = 0;
++ for (n = st1.st_size; n; n -= len)
++ {
++ len = n;
++ if (len > 4096)
++ len = 4096;
++
++ if (read (fd1, buf, len) != (int) len
++ || read (fd2, buf + 4096, len) != (int) len)
++ {
++ i = -1;
++ break;
++ }
++
++ if (memcmp (buf, buf + 4096, len) != 0)
++ break;
++ }
++
++ close (fd1);
++ close (fd2);
++
++ if (n)
++ break;
++ }
++
++ free (buf);
++ if (i == -1)
++ break;
++
++ if (i != 2)
++ {
++ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
++ break;
++ }
++
++ fd = open (temp_filenames[attempt * 2], O_RDWR);
++ if (fd < 0)
++ break;
++ write (fd, "//", 2);
++ for (i = 0; i < nargs; i++)
++ {
++ write (fd, " ", 1);
++ write (fd, new_argv[i], strlen (new_argv[i]));
++ }
++ write (fd, "\n", 1);
++ new_argv[nargs] = "-E";
++ new_argv[nargs + 1] = NULL;
++ }
++
++ /* Fork a subprocess; wait and retry if it fails. */
++ sleep_interval = 1;
++ pid = -1;
++ for (retries = 0; retries < 4; retries++)
++ {
++ pid = fork ();
++ if (pid >= 0)
++ break;
++ sleep (sleep_interval);
++ sleep_interval *= 2;
++ }
++
++ if (pid < 0)
++ break;
++ else if (pid == 0)
++ {
++ if (attempt != RETRY_ICE_ATTEMPTS)
++ fd = open (temp_filenames[attempt * 2], O_RDWR);
++ if (fd < 0)
++ exit (-1);
++ if (fd != 1)
++ {
++ close (1);
++ dup (fd);
++ close (fd);
++ }
++
++ fd = open (temp_filenames[attempt * 2 + 1], O_RDWR);
++ if (fd < 0)
++ exit (-1);
++ if (fd != 2)
++ {
++ close (2);
++ dup (fd);
++ close (fd);
++ }
++
++ if (prog == new_argv[0])
++ execvp (prog, (char *const *) new_argv);
++ else
++ execv (new_argv[0], (char *const *) new_argv);
++ exit (-1);
++ }
++
++ if (waitpid (pid, &status, 0) < 0)
++ break;
++
++ if (attempt < RETRY_ICE_ATTEMPTS
++ && (! WIFEXITED (status) || WEXITSTATUS (status) != ICE_EXIT_CODE))
++ {
++ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
++ break;
++ }
++ else if (attempt == RETRY_ICE_ATTEMPTS)
++ {
++ close (fd);
++ if (WIFEXITED (status)
++ && WEXITSTATUS (status) == SUCCESS_EXIT_CODE)
++ {
++ notice ("Preprocessed source stored into %s file, please attach this to your bugreport.\n",
++ temp_filenames[attempt * 2]);
++ /* Make sure it is not deleted. */
++ free (temp_filenames[attempt * 2]);
++ temp_filenames[attempt * 2] = NULL;
++ break;
++ }
++ }
++ }
++
++ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS * 2 + 2; attempt++)
++ if (temp_filenames[attempt])
++ {
++ unlink (temp_filenames[attempt]);
++ free (temp_filenames[attempt]);
++ }
++}
++#endif
++
+ /* Search for a file named NAME trying various prefixes including the
+ user's -B prefix and some standard ones.
+ Return the absolute file name found. If nothing is found, return NAME. */
+--- gcc/diagnostic.c.jj 2003-10-01 12:09:21.000000000 +0200
++++ gcc/diagnostic.c 2004-01-21 11:54:47.000000000 +0100
+@@ -272,14 +272,14 @@ diagnostic_action_after_output (diagnost
+ real_abort ();
+
+ fnotice (stderr, bug_report_request, bug_report_url);
+- exit (FATAL_EXIT_CODE);
++ exit (ICE_EXIT_CODE);
+
+ case DK_FATAL:
+ if (context->abort_on_error)
+ real_abort ();
+
+ fnotice (stderr, "compilation terminated.\n");
+- exit (FATAL_EXIT_CODE);
++ exit (ICE_EXIT_CODE);
+
+ default:
+ real_abort ();
+@@ -571,7 +571,7 @@ error_recursion (diagnostic_context *con
+ fnotice (stderr,
+ "Internal compiler error: Error reporting routines re-entered.\n");
+ fnotice (stderr, bug_report_request, bug_report_url);
+- exit (FATAL_EXIT_CODE);
++ exit (ICE_EXIT_CODE);
+ }
+
+ /* Report an internal compiler error in a friendly manner. This is
diff --git a/sys-devel/gcc/gcc-3.4.0-r6.ebuild b/sys-devel/gcc/gcc-3.4.0-r6.ebuild
index 3df75f9f6e64..b02e92435a3b 100644
--- a/sys-devel/gcc/gcc-3.4.0-r6.ebuild
+++ b/sys-devel/gcc/gcc-3.4.0-r6.ebuild
@@ -1,8 +1,8 @@
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/gcc-3.4.0-r6.ebuild,v 1.7 2004/06/04 15:27:38 lv Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/gcc-3.4.0-r6.ebuild,v 1.8 2004/06/04 23:19:52 lv Exp $
-IUSE="static nls bootstrap java build X multilib gcj f77 objc pic hardened uclibc n32 n64"
+IUSE="static nls bootstrap java build X multilib gcj f77 objc hardened uclibc n32 n64"
inherit eutils flag-o-matic libtool
@@ -362,6 +362,8 @@ src_unpack() {
then
mkdir -p ${WORKDIR}/patch/exclude
#mv -f ${WORKDIR}/patch/84* ${WORKDIR}/patch/exclude/
+ bzip2 -c ${FILESDIR}/3.4.0/gcc34-ice-hack.patch > \
+ ${WORKDIR}/patch/02_all_gcc34-ice-hack.patch.bz2
# for uclibc we rather copy the needed files and patch them
mkdir ${S}/libstdc++-v3/config/{locale/uclibc,os/uclibc} || \
@@ -391,7 +393,9 @@ src_unpack() {
epatch ${WORKDIR}/patch
# the uclibc patches need autoconf to be run
- cd ${S}/libstdc++-v3; autoconf; cd ${S}
+ # for build stage we need the updated files though
+ use build || ( cd ${S}/libstdc++-v3; autoconf; cd ${S} )
+ use build && use uclibc && ewarn "uclibc in build stage is not supported yet" && exit 1
use uclibc && epatch ${FILESDIR}/3.3.3/gcc-uclibc-3.3-loop.patch
elif [ -n "`use multilib`" -a "${ARCH}" = "amd64" ]
@@ -430,6 +434,14 @@ src_unpack() {
sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -fno-stack-protector-all|' \
-i ${S}/gcc/Makefile.in || die "Failed to update libgcc!"
+ # if gcc in a stage3 defaults to ssp, is version 3.4.0 and a stage1 is built
+ # the build fails building timevar.o w/:
+ # cc1: stack smashing attack in function ix86_split_to_parts()
+ if gcc -dumpspecs | grep -q "fno-stack-protector:"
+ then
+ use build && epatch ${FILESDIR}/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch
+ fi
+
release_version="${release_version}, ssp-${PP_FVER}"
update_gcc_for_libc_ssp