Skip to content

Commit

Permalink
Trac #30227: Use both SINGULAR_INCDIR and SINGULAR_CFLAGS
Browse files Browse the repository at this point in the history
... to set `include_dirs` and `extra_compile_args` in Cython distutils
directives. Do not rely on `extra_compile_args` for that.

Likewise for other libraries.

Otherwise, the include search order is not correct (see
https://groups.google.com/d/msg/sage-release/SdxKEn7CuLM/3ru84S_zAgAJ)

URL: https://trac.sagemath.org/30227
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): François Bissey
  • Loading branch information
Release Manager committed Aug 6, 2020
2 parents 760b7d8 + 25c60d0 commit 9911c15
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,10 @@ def cython_aliases():
aliases[var + "CFLAGS"] = pkgconfig.cflags(lib).split()
pc = pkgconfig.parse(lib)
libs = pkgconfig.libs(lib)
# INCDIR should be redundant because the -I options are also
# passed in CFLAGS
# It may seem that INCDIR is redundant because the -I options are also
# passed in CFLAGS. However, "extra_compile_args" are put at the end
# of the compiler command line. "include_dirs" go to the front; the
# include search order matters.
aliases[var + "INCDIR"] = pc['include_dirs']
aliases[var + "LIBDIR"] = pc['library_dirs']
aliases[var + "LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), libs.split()))
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/linbox/fflas.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: extra_compile_args = FFLASFFPACK_CFLAGS
# distutils: include_dirs = FFLASFFPACK_INCDIR
# distutils: libraries = FFLASFFPACK_LIBRARIES
# distutils: library_dirs = FFLASFFPACK_LIBDIR
# distutils: extra_link_args = FFLASFFPACK_LIBEXTRA
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/linbox/givaro.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: extra_compile_args = GIVARO_CFLAGS
# distutils: include_dirs = GIVARO_INCDIR
# distutils: libraries = GIVARO_LIBRARIES FFLASFFPACK_LIBRARIES
# distutils: library_dirs = GIVARO_LIBDIR
# distutils: language = c++
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/linbox/linbox.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: extra_compile_args = LINBOX_CFLAGS
# distutils: include_dirs = LINBOX_INCDIR
# distutils: libraries = LINBOX_LIBRARIES
# distutils: library_dirs = LINBOX_LIBDIR
# distutils: extra_link_args = LINBOX_LIBEXTRA
Expand Down
4 changes: 3 additions & 1 deletion src/sage/libs/pynac/pynac.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# distutils: language = c++
# distutils: libraries = pynac gmp
# distutils: extra_compile_args = -std=c++11 SINGULAR_CFLAGS
# pynac/basic.h includes factory/factory.h so this ^ is needed to find it
# distutils: include_dirs = SINGULAR_INCDIR
# pynac/basic.h includes
# factory/factory.h so this ^ is needed to find it
"""
Declarations for pynac, a Python frontend for ginac
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/singular/decl.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# distutils: include_dirs = SINGULAR_INCDIR
# distutils: extra_compile_args = SINGULAR_CFLAGS
# distutils: libraries = SINGULAR_LIBRARIES
# distutils: library_dirs = SINGULAR_LIBDIR
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_integer_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# distutils: extra_compile_args = M4RI_CFLAGS
# distutils: libraries = iml ntl gmp m CBLAS_LIBRARIES
# distutils: library_dirs = CBLAS_LIBDIR
# distutils: include_dirs = CBLAS_INCDIR
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR
"""
Dense matrices over the integer ring
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_rational_dense.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# distutils: extra_compile_args = -D_XPG6 M4RI_CFLAGS
# distutils: libraries = iml ntl m CBLAS_LIBRARIES
# distutils: library_dirs = CBLAS_LIBDIR
# distutils: include_dirs = CBLAS_INCDIR
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR

"""
Dense matrices over the rational field
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/finite_rings/element_givaro.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: extra_compile_args = GIVARO_CFLAGS
# distutils: include_dirs = GIVARO_INCDIR

from libcpp.vector cimport vector
ctypedef vector[int] intvec
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/polynomial/polynomial_gf2x.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# distutils: libraries = gmp ntl
# distutils: extra_compile_args = M4RI_CFLAGS
# distutils: include_dirs = M4RI_INCDIR
# distutils: language = c++
"""
Univariate Polynomials over GF(2) via NTL's GF2X
Expand Down

0 comments on commit 9911c15

Please sign in to comment.