Skip to content

Commit

Permalink
Trac #29785: Move Extension options from src/module_list.py to "distu…
Browse files Browse the repository at this point in the history
…tils:" directives in the individual files (part 3: Get rid of uname_specific)

Follow-up from #29706.

We get rid of the use of `uname_specific` to define an `Extension`
option in `module_list`, replacing it by use of `cython_aliases`.

URL: https://trac.sagemath.org/29785
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Jonathan Kliem
  • Loading branch information
Release Manager committed Jun 24, 2020
2 parents b4ca018 + 2ba1d7b commit d5756d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/module_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@
#############################################################

from sage_setup.optional_extension import OptionalExtension
UNAME = os.uname()

def uname_specific(name, value, alternative):
if name in UNAME[0]:
return value
else:
return alternative


ext_modules = [

Expand Down Expand Up @@ -501,10 +493,7 @@ def uname_specific(name, value, alternative):
language = 'c++'),

Extension('sage.libs.libecm',
sources = ['sage/libs/libecm.pyx'],
libraries = ['ecm'],
extra_link_args = uname_specific("Linux", ["-Wl,-z,noexecstack"],
[])),
sources = ['sage/libs/libecm.pyx']),

Extension('sage.libs.lrcalc.lrcalc',
sources = ["sage/libs/lrcalc/lrcalc.pyx"]),
Expand Down
12 changes: 12 additions & 0 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,18 @@ def cython_aliases():
aliases[var + "LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), libs.split()))
aliases[var + "LIBRARIES"] = pc['libraries']

# uname-specific flags
UNAME = os.uname()

def uname_specific(name, value, alternative):
if name in UNAME[0]:
return value
else:
return alternative

aliases["LINUX_NOEXECSTACK"] = uname_specific("Linux", ["-Wl,-z,noexecstack"],
[])

# LinBox needs special care because it actually requires C++11 with
# GNU extensions: -std=c++11 does not work, you need -std=gnu++11
# (this is true at least with GCC 7.2.0).
Expand Down
2 changes: 2 additions & 0 deletions src/sage/libs/libecm.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# distutils: libraries = ecm
# distutils: extra_link_args = LINUX_NOEXECSTACK
r"""
The Elliptic Curve Method for Integer Factorization (ECM)
Expand Down

0 comments on commit d5756d4

Please sign in to comment.