summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2023-01-26 15:50:04 -0600
committerGitHub <noreply@github.com>2023-01-26 15:50:04 -0600
commit424733f52b9d2ad1c0bf8abd58119bc27aec30c8 (patch)
tree38c5aaecf0a694ad13fb29bf5e9c16bd7875f000
parent60c3a3ac694c836187458435b94c7ce3f51922a4 (diff)
parent99cad0de1ee0af3c62d16415d1632d781fa3af60 (diff)
downloadgreenlet-424733f52b9d2ad1c0bf8abd58119bc27aec30c8.tar.gz
Merge pull request #339 from python-greenlet/issue300
Adjusting compiler arguments for 300
-rw-r--r--.github/workflows/tests.yml4
-rw-r--r--CHANGES.rst2
-rwxr-xr-xsetup.py42
3 files changed, 36 insertions, 12 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 56d986d..fa8c4c4 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -145,7 +145,7 @@ jobs:
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v1
+ uses: github/codeql-action/init@v2
with:
languages: python, cpp
# Override the default behavior so that the action doesn't attempt
@@ -157,7 +157,7 @@ jobs:
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
+ uses: github/codeql-action/analyze@v2
manylinux:
diff --git a/CHANGES.rst b/CHANGES.rst
index 856ea27..88c0f36 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,7 +8,7 @@
- Fix calling ``greenlet.settrace()`` with the same tracer object that
was currently active. See `issue 332
<https://github.com/python-greenlet/greenlet/issues/332>`_.
-- Various compilation and standards conformance fixes. See #335, #336.
+- Various compilation and standards conformance fixes. See #335, #336, #300.
2.0.1 (2022-11-07)
diff --git a/setup.py b/setup.py
index af6781d..97278b6 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import os
@@ -30,18 +31,41 @@ is_win = sys.platform.startswith("win")
# https://github.com/python-greenlet/greenlet/issues/94
# pylint:disable=too-many-boolean-expressions
is_linux = sys.platform.startswith('linux') # could be linux or linux2
-if ((sys.platform == "openbsd4" and os.uname()[-1] == "i386")
- or ("-with-redhat-3." in platform.platform() and platform.machine() == 'i686')
- or (sys.platform == "sunos5" and os.uname()[-1] == "sun4v")
- or ("SunOS" in platform.platform() and platform.machine() == "sun4v")
- or (is_linux and platform.machine() == "ppc")):
+plat_platform = platform.platform()
+plat_machine = platform.machine()
+plat_compiler = platform.python_compiler()
+try:
+ # (sysname, nodename, release, version, machine)
+ unam_machine = os.uname()[-1]
+except AttributeError:
+ unam_machine = ''
+if (
+ (sys.platform == "openbsd4" and unam_machine == "i386")
+ or ("-with-redhat-3." in plat_platform and plat_machine == 'i686')
+ or (sys.platform == "sunos5" and unam_machine == "sun4v") # SysV-based Solaris
+ or ("SunOS" in plat_platform and plat_machine == "sun4v") # Old BSD-based SunOS
+ or (is_linux and plat_machine == "ppc")
+ # https://github.com/python-greenlet/greenlet/pull/300: When compiling for RISC-V the command
+ # ``riscv64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time \
+ # -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-7GU7VT/python2.7-2.7.18=. \
+ # -fstack-protector-strong -Wformat -Werror=format-security -fPIC \
+ # -I/usr/include/python2.7
+ # -c src/greenlet/greenlet.cpp -o build/temp.linux-riscv64-2.7/src/greenlet/greenlet.o``
+ #
+ # fails with:
+ #
+ # src/greenlet/platform/switch_riscv_unix.h:30:1: error: s0 cannot be used in 'asm' here
+ #
+ # Adding the -Os flag fixes the problem.
+ or (is_linux and plat_machine == "riscv64")
+):
global_compile_args.append("-Os")
-if sys.platform == 'darwin':
+if sys.platform == 'darwin' or 'clang' in plat_compiler:
# The clang compiler doesn't use --std=c++11 by default
cpp_compile_args.append("--std=gnu++11")
-elif is_win and "MSC" in platform.python_compiler():
+elif is_win and "MSC" in plat_compiler:
# Older versions of MSVC (Python 2.7) don't handle C++ exceptions
# correctly by default. While newer versions do handle exceptions by default,
# they don't do it fully correctly. So we need an argument on all versions.
@@ -108,14 +132,14 @@ else:
if is_win and '64 bit' in sys.version:
# this works when building with msvc, not with 64 bit gcc
# switch_<platform>_masm.obj can be created with setup_switch_<platform>_masm.cmd
- obj_fn = 'switch_arm64_masm.obj' if platform.machine() == 'ARM64' else 'switch_x64_masm.obj'
+ obj_fn = 'switch_arm64_masm.obj' if plat_machine == 'ARM64' else 'switch_x64_masm.obj'
extra_objects = [os.path.join(GREENLET_PLATFORM_DIR, obj_fn)]
else:
extra_objects = []
if is_win and os.environ.get('GREENLET_STATIC_RUNTIME') in ('1', 'yes'):
main_compile_args.append('/MT')
- elif hasattr(os, 'uname') and os.uname()[4] in ['ppc64el', 'ppc64le']:
+ elif unam_machine in ('ppc64el', 'ppc64le'):
main_compile_args.append('-fno-tree-dominator-opts')
ext_modules = [