1 |
radhermit 13/05/29 01:58:02 |
2 |
|
3 |
Added: greenlet-0.4.0-gcc48.patch |
4 |
Log: |
5 |
Revision bump, add upstream fixes for gcc-4.8 issues. |
6 |
|
7 |
(Portage version: 2.2.0_alpha177/cvs/Linux x86_64, signed Manifest commit with key 4AB3E85B4F064CA3) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-python/greenlet/files/greenlet-0.4.0-gcc48.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/greenlet/files/greenlet-0.4.0-gcc48.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/greenlet/files/greenlet-0.4.0-gcc48.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: greenlet-0.4.0-gcc48.patch |
16 |
=================================================================== |
17 |
From 5a0a628021357bf37cccbcc401e07dc99e9415ee Mon Sep 17 00:00:00 2001 |
18 |
From: Ralf Schmitt <ralf@××××××××××.de> |
19 |
Date: Fri, 3 May 2013 21:48:03 +0200 |
20 |
Subject: [PATCH] fix segfaults when using gcc 4.8 on amd64/x86 unix |
21 |
|
22 |
I'm just porting the aarch64 stuff committed recently. |
23 |
--- |
24 |
platform/switch_amd64_unix.h | 14 +++++++++++++- |
25 |
platform/switch_x86_unix.h | 15 ++++++++++++++- |
26 |
2 files changed, 27 insertions(+), 2 deletions(-) |
27 |
|
28 |
diff --git a/platform/switch_amd64_unix.h b/platform/switch_amd64_unix.h |
29 |
index 3ed0a16..05b34b6 100644 |
30 |
--- a/platform/switch_amd64_unix.h |
31 |
+++ b/platform/switch_amd64_unix.h |
32 |
@@ -2,6 +2,9 @@ |
33 |
* this is the internal transfer function. |
34 |
* |
35 |
* HISTORY |
36 |
+ * 3-May-13 Ralf Schmitt <ralf@××××××××××.de> |
37 |
+ * Add support for strange GCC caller-save decisions |
38 |
+ * (ported from switch_aarch64_gcc.h) |
39 |
* 18-Aug-11 Alexey Borzenkov <snaury@×××××.com> |
40 |
* Correctly save rbp, csr and cw |
41 |
* 01-Apr-04 Hye-Shik Chang <perky@×××××××.org> |
42 |
@@ -33,10 +36,18 @@ |
43 |
|
44 |
#define REGS_TO_SAVE "r12", "r13", "r14", "r15" |
45 |
|
46 |
+/* See switch_aarch64_gcc.h for the purpose of this function */ |
47 |
+__attribute__((noinline, noclone)) int fancy_return_zero(void); |
48 |
+__attribute__((noinline, noclone)) int |
49 |
+fancy_return_zero(void) |
50 |
+{ |
51 |
+ return 0; |
52 |
+} |
53 |
|
54 |
static int |
55 |
slp_switch(void) |
56 |
{ |
57 |
+ int err = 0; |
58 |
void* rbp; |
59 |
void* rbx; |
60 |
unsigned int csr; |
61 |
@@ -57,13 +68,14 @@ slp_switch(void) |
62 |
: "r" (stsizediff) |
63 |
); |
64 |
SLP_RESTORE_STATE(); |
65 |
+ err = fancy_return_zero(); |
66 |
} |
67 |
__asm__ volatile ("movq %0, %%rbx" : : "m" (rbx)); |
68 |
__asm__ volatile ("movq %0, %%rbp" : : "m" (rbp)); |
69 |
__asm__ volatile ("ldmxcsr %0" : : "m" (csr)); |
70 |
__asm__ volatile ("fldcw %0" : : "m" (cw)); |
71 |
__asm__ volatile ("" : : : REGS_TO_SAVE); |
72 |
- return 0; |
73 |
+ return err; |
74 |
} |
75 |
|
76 |
#endif |
77 |
diff --git a/platform/switch_x86_unix.h b/platform/switch_x86_unix.h |
78 |
index 0d42a67..e66633e 100644 |
79 |
--- a/platform/switch_x86_unix.h |
80 |
+++ b/platform/switch_x86_unix.h |
81 |
@@ -2,6 +2,9 @@ |
82 |
* this is the internal transfer function. |
83 |
* |
84 |
* HISTORY |
85 |
+ * 3-May-13 Ralf Schmitt <ralf@××××××××××.de> |
86 |
+ * Add support for strange GCC caller-save decisions |
87 |
+ * (ported from switch_aarch64_gcc.h) |
88 |
* 19-Aug-11 Alexey Borzenkov <snaury@×××××.com> |
89 |
* Correctly save ebp, ebx and cw |
90 |
* 07-Sep-05 (py-dev mailing list discussion) |
91 |
@@ -33,9 +36,18 @@ |
92 |
/* the above works fine with gcc 2.96, but 2.95.3 wants this */ |
93 |
#define STACK_MAGIC 0 |
94 |
|
95 |
+/* See below for the purpose of this function. */ |
96 |
+__attribute__((noinline, noclone)) int fancy_return_zero(void); |
97 |
+__attribute__((noinline, noclone)) int |
98 |
+fancy_return_zero(void) |
99 |
+{ |
100 |
+ return 0; |
101 |
+} |
102 |
+ |
103 |
static int |
104 |
slp_switch(void) |
105 |
{ |
106 |
+ int err = 0; |
107 |
#ifdef _WIN32 |
108 |
void *seh; |
109 |
#endif |
110 |
@@ -64,6 +76,7 @@ slp_switch(void) |
111 |
: "r" (stsizediff) |
112 |
); |
113 |
SLP_RESTORE_STATE(); |
114 |
+ err = fancy_return_zero(); |
115 |
} |
116 |
#ifdef _WIN32 |
117 |
__asm__ volatile ( |
118 |
@@ -77,7 +90,7 @@ slp_switch(void) |
119 |
__asm__ volatile ("movl %0, %%ebp" : : "m" (ebp)); |
120 |
__asm__ volatile ("fldcw %0" : : "m" (cw)); |
121 |
__asm__ volatile ("" : : : "esi", "edi"); |
122 |
- return 0; |
123 |
+ return err; |
124 |
} |
125 |
|
126 |
#endif |
127 |
-- |
128 |
1.8.2.1 |
129 |
|
130 |
--- b/setup.py |
131 |
+++ b/setup.py |
132 |
@@ -1,6 +1,6 @@ |
133 |
#! /usr/bin/env python |
134 |
|
135 |
-import sys, os, glob, platform |
136 |
+import sys, os, glob, platform, tempfile, shutil |
137 |
|
138 |
# workaround segfaults on openbsd and RHEL 3 / CentOS 3 . see |
139 |
# https://bitbucket.org/ambroff/greenlet/issue/11/segfault-on-openbsd-i386 |
140 |
@@ -54,10 +54,33 @@ |
141 |
extra_objects=extra_objects, |
142 |
depends=['greenlet.h', 'slp_platformselect.h'] + _find_platform_headers())] |
143 |
|
144 |
-from my_build_ext import build_ext |
145 |
- |
146 |
+from my_build_ext import build_ext as _build_ext |
147 |
from distutils.core import Command |
148 |
|
149 |
+ |
150 |
+class build_ext(_build_ext): |
151 |
+ def configure_compiler(self): |
152 |
+ compiler = self.compiler |
153 |
+ if compiler.__class__.__name__ != "UnixCCompiler": |
154 |
+ return |
155 |
+ |
156 |
+ compiler.compiler_so += ["-fno-tree-dominator-opts"] |
157 |
+ tmpdir = tempfile.mkdtemp() |
158 |
+ |
159 |
+ try: |
160 |
+ simple_c = os.path.join(tmpdir, "simple.c") |
161 |
+ open(simple_c, "w").write("void foo(){}") |
162 |
+ compiler.compile([simple_c], output_dir=tmpdir) |
163 |
+ except Exception: |
164 |
+ del compiler.compiler_so[-1] |
165 |
+ |
166 |
+ shutil.rmtree(tmpdir) |
167 |
+ |
168 |
+ def build_extensions(self): |
169 |
+ self.configure_compiler() |
170 |
+ _build_ext.build_extensions(self) |
171 |
+ |
172 |
+ |
173 |
class fixup(Command): |
174 |
user_options = [] |
175 |
description = "prevent duplicate uploads and upload for the wrong architecture" |