diff options
author | Alexey Borzenkov <snaury@gmail.com> | 2014-06-24 04:05:55 +0400 |
---|---|---|
committer | Alexey Borzenkov <snaury@gmail.com> | 2014-06-24 04:05:55 +0400 |
commit | 0246d0618d0014e7028c2b2c643a16764b9ac069 (patch) | |
tree | e83d8944a7c025c116921abf9a06d3b5774b70da | |
parent | 892319cdf6f6be58574b21293dcbbd2c40b802a0 (diff) | |
download | greenlet-0246d0618d0014e7028c2b2c643a16764b9ac069.tar.gz |
Get rid of -fno-tree-dominator-opts
This option is deprecated and removed, so we
cannot rely on it. Additionally, don't rely on
`fancy_return_zero' and use inline assembly to
generate a proper zero return value instead.
-rw-r--r-- | platform/switch_aarch64_gcc.h | 16 | ||||
-rw-r--r-- | platform/switch_amd64_unix.h | 12 | ||||
-rw-r--r-- | platform/switch_x86_unix.h | 12 | ||||
-rwxr-xr-x | setup.py | 25 |
4 files changed, 8 insertions, 57 deletions
diff --git a/platform/switch_aarch64_gcc.h b/platform/switch_aarch64_gcc.h index 0c4e3cc..d6a6a52 100644 --- a/platform/switch_aarch64_gcc.h +++ b/platform/switch_aarch64_gcc.h @@ -20,18 +20,10 @@ "v8", "v9", "v10", "v11", \ "v12", "v13", "v14", "v15" -/* See below for the purpose of this function. */ -__attribute__((noinline, noclone)) int fancy_return_zero(void); -__attribute__((noinline, noclone)) int -fancy_return_zero(void) -{ - return 0; -} - static int slp_switch(void) { - int err = 0; + int err; void *fp; register long *stackref, stsizediff; __asm__ volatile ("" : : : REGS_TO_SAVE); @@ -41,7 +33,7 @@ slp_switch(void) SLP_SAVE_STATE(stackref, stsizediff); __asm__ volatile ( "add sp,sp,%0\n" - "add x29,x29,%0\n" + "add x29,x29,%0\n" : : "r" (stsizediff) ); @@ -66,9 +58,9 @@ slp_switch(void) stack space), and the simplest is to call a function that returns an unknown value (which happens to be zero), so the saved/restored value is unused. */ - err = fancy_return_zero(); + __asm__ volatile ("mov x0, #0" : "=x0" (err)); } - __asm__ volatile ("ldr x29, %0" : : "m" (fp) :); + __asm__ volatile ("ldr x29, %0" : : "m" (fp) :); __asm__ volatile ("" : : : REGS_TO_SAVE); return err; } diff --git a/platform/switch_amd64_unix.h b/platform/switch_amd64_unix.h index 05b34b6..16b99b7 100644 --- a/platform/switch_amd64_unix.h +++ b/platform/switch_amd64_unix.h @@ -36,18 +36,10 @@ #define REGS_TO_SAVE "r12", "r13", "r14", "r15" -/* See switch_aarch64_gcc.h for the purpose of this function */ -__attribute__((noinline, noclone)) int fancy_return_zero(void); -__attribute__((noinline, noclone)) int -fancy_return_zero(void) -{ - return 0; -} - static int slp_switch(void) { - int err = 0; + int err; void* rbp; void* rbx; unsigned int csr; @@ -68,7 +60,7 @@ slp_switch(void) : "r" (stsizediff) ); SLP_RESTORE_STATE(); - err = fancy_return_zero(); + __asm__ volatile ("xorq %%rax, %%rax" : "=a" (err)); } __asm__ volatile ("movq %0, %%rbx" : : "m" (rbx)); __asm__ volatile ("movq %0, %%rbp" : : "m" (rbp)); diff --git a/platform/switch_x86_unix.h b/platform/switch_x86_unix.h index b59793b..3a95186 100644 --- a/platform/switch_x86_unix.h +++ b/platform/switch_x86_unix.h @@ -42,18 +42,10 @@ # define ATTR_NOCLONE #endif -/* See below for the purpose of this function. */ -__attribute__((noinline)) ATTR_NOCLONE int fancy_return_zero(void); -__attribute__((noinline)) ATTR_NOCLONE int -fancy_return_zero(void) -{ - return 0; -} - static int slp_switch(void) { - int err = 0; + int err; #ifdef _WIN32 void *seh; #endif @@ -82,7 +74,7 @@ slp_switch(void) : "r" (stsizediff) ); SLP_RESTORE_STATE(); - err = fancy_return_zero(); + __asm__ volatile ("xorl %%eax, %%eax" : "=a" (err)); } #ifdef _WIN32 __asm__ volatile ( @@ -54,33 +54,9 @@ else: extra_objects=extra_objects, depends=['greenlet.h', 'slp_platformselect.h'] + _find_platform_headers())] -from my_build_ext import build_ext as _build_ext from distutils.core import Command -class build_ext(_build_ext): - def configure_compiler(self): - compiler = self.compiler - if compiler.__class__.__name__ != "UnixCCompiler": - return - - compiler.compiler_so += ["-fno-tree-dominator-opts"] - tmpdir = tempfile.mkdtemp() - - try: - simple_c = os.path.join(tmpdir, "simple.c") - open(simple_c, "w").write("void foo(){}") - compiler.compile([simple_c], output_dir=tmpdir) - except Exception: - del compiler.compiler_so[-1] - - shutil.rmtree(tmpdir) - - def build_extensions(self): - self.configure_compiler() - _build_ext.build_extensions(self) - - setup( name="greenlet", version='0.4.2', @@ -93,7 +69,6 @@ setup( platforms=['any'], headers=headers, ext_modules=ext_modules, - cmdclass=dict(build_ext=build_ext), classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', |