This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix gcc.dg/pch/largefile.c on Solaris 2 (PR pch/14940)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 24 Feb 2010 14:49:01 +0100
- Subject: PATCH: Fix gcc.dg/pch/largefile.c on Solaris 2 (PR pch/14940)
While investigating the failures of gcc.dg/pch/largefile.c on Solaris
11/x86, I noticed a couple of things:
* The SEGVs observed are due to another error; cc1 tries to call
fatal_error ("had to relocate PCH") at this point, without line_map
being set up.
* The address space range it tries to use at this point is really in
use, which is no wonder since it's somewhere in the middle of the
heap, and, as documented on mmap(2), Solaris mmap both adds a total of
4 red-zone pages to the mapping size and rounds up the size to a
multiple of 64 kB, 512 MB, 1 MB, or 4 MB, depending on a couple of
conditions.
* Checking the code in config/host-hpux.c, I found that Solaris simply
lacks its own implementation of gt_pch_get_address to suggest a likely
unused range in the processes' address space. I've provided one,
based on the HP-UX implementation and the overview of SPARC and x86
Solaris address space layouts given in McDougall, Mauro, Solaris
Internals, 2nd ed.
With this change, the largefile.c tests suddenly succeed on
i386-pc-solaris2.11, thus I could remove the dg-xfail-if in pch.exp,
too.
Ok for mainline?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2010-02-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc:
PR pch/14940
* config/host-solaris.c (HOST_HOOKS_GT_PCH_GET_ADDRESS): Redefine
to sol_gt_pch_get_address.
(TRY_EMPTY_VM_SPACE): Define for all combinations of 32 and
64-bit, SPARC and x86.
(sol_gt_pch_get_address): New function.
gcc/testsuite:
PR pch/14940
* gcc.dg/pch/pch.exp: Don't XFAIL largefile.c on i?86-*-solaris2.10.
diff -r 0e0663481abb -r d8d980e6a7c4 gcc/config/host-solaris.c
--- a/gcc/config/host-solaris.c Wed Feb 10 21:06:23 2010 +0100
+++ b/gcc/config/host-solaris.c Thu Feb 11 23:16:03 2010 +0100
@@ -1,5 +1,5 @@
/* Solaris host-specific hook definitions.
- Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -25,9 +25,48 @@
#include "hosthooks-def.h"
+#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
+#define HOST_HOOKS_GT_PCH_GET_ADDRESS sol_gt_pch_get_address
#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
#define HOST_HOOKS_GT_PCH_USE_ADDRESS sol_gt_pch_use_address
+/* For various ports, try to guess a fixed spot in the vm space
+ that's probably free. Based on McDougall, Mauro, Solaris Internals, 2nd
+ ed., p.460-461, fig. 9-3, 9-4, 9-5. */
+#if defined(__sparcv9__)
+/* This low to avoid VA hole on UltraSPARC I/II. */
+# define TRY_EMPTY_VM_SPACE 0x70000000000
+#elif defined(__sparc__)
+# define TRY_EMPTY_VM_SPACE 0x80000000
+#elif defined(__x86_64__)
+# define TRY_EMPTY_VM_SPACE 0x8000000000000000
+#elif defined(__i386__)
+# define TRY_EMPTY_VM_SPACE 0xB0000000
+#else
+# define TRY_EMPTY_VM_SPACE 0
+#endif
+
+/* Determine a location where we might be able to reliably allocate
+ SIZE bytes. FD is the PCH file, though we should return with the
+ file unmapped. */
+
+static void *
+sol_gt_pch_get_address (size_t size, int fd)
+{
+ void *addr;
+
+ addr = mmap ((caddr_t) TRY_EMPTY_VM_SPACE, size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE, fd, 0);
+
+ /* If we failed the map, that means there's *no* free space. */
+ if (addr == (void *) MAP_FAILED)
+ return NULL;
+ /* Unmap the area before returning. */
+ munmap ((caddr_t) addr, size);
+
+ return addr;
+}
+
/* Map SIZE bytes of FD+OFFSET at BASE. Return 1 if we succeeded at
mapping the data at BASE, -1 if we couldn't. */
diff -r 0e0663481abb -r d8d980e6a7c4 gcc/testsuite/gcc.dg/pch/pch.exp
--- a/gcc/testsuite/gcc.dg/pch/pch.exp Wed Feb 10 21:06:23 2010 +0100
+++ b/gcc/testsuite/gcc.dg/pch/pch.exp Thu Feb 11 23:16:03 2010 +0100
@@ -43,7 +43,6 @@
set test "largefile.c"
set testh "largefile.hs"
set f [open $test w]
-puts $f "/* { dg-xfail-if \"PR 14940\" { \"i?86-*-solaris2.10\" } { \"*\" } { \"\" } } */"
puts $f "/* { dg-timeout-factor 4.0 } */"
set v 0
for { set v 0 } { $v < 10000 } { incr v } {