8000 ENH: enabled extra_link_args in OpenBLAS segment by zerothi · Pull Request #6328 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: enabled extra_link_args in OpenBLAS segment #6328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ENH: enabled extra_link_args in OpenBLAS segment
The extra_link_args is sadly not intrinsically used
for many parts of the system_info code.

This commit adds the linking properties stored
when using extra_link_args in the openblas section
to bypass any difficulties in the usage of OpenBLAS.

This is especially helpful when linking against external
LAPACK libraries which requires -lgfortran and possibly
-lm for correct linking.
  • Loading branch information
< 8000 div class="commit-meta clearfix p-2 d-flex flex-column flex-md-row flex-md-items-center">
zerothi committed Sep 17, 2015
commit 62e87ab001710bcafa54786a2b3d413f77398066
15 changes: 13 additions & 2 deletions numpy/distutils/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,10 @@ def calc_info(self):
if info is None:
return

# Add extra info for OpenBLAS
extra_info = self.calc_extra_info()
dict_append(info, **extra_info)

if not self.check_embedded_lapack(info):
return

Expand All @@ -1729,13 +1733,19 @@ def check_embedded_lapack(self, info):
}"""
src = os.path.join(tmpdir, 'source.c')
out = os.path.join(tmpdir, 'a.out')
# Add the additional "extra" arguments
try:
extra_args = info['extra_link_args']
except:
extra_args = []
try:
with open(src, 'wt') as f:
f.write(s)
obj = c.compile([src], output_dir=tmpdir)
try:
c.link_executable(obj, out, libraries=info['libraries'],
library_dirs=info['library_dirs'])
library_dirs=info['library_dirs'],
extra_postargs=extra_args)
res = True
except distutils.ccompiler.LinkError:
res = False
Expand All @@ -1752,7 +1762,8 @@ def check_embedded_lapack(self, info):
obj = c.compile([src], output_dir=tmpdir)
try:
c.link_executable(obj, out, libraries=info['libraries'],
library_dirs=info['library_dirs'])
library_dirs=info['library_dirs'],
extra_postargs=extra_args)
res = True
except distutils.ccompiler.LinkError:
res = False
Expand Down
2 changes: 1 addition & 1 deletion site.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
# extra_compile_args = -g -ftree-vectorize
#
# extra_link_args
# Add additional arguments to when libraries/executables
# Add additional arguments when libraries/executables
# are linked.
# Simple variable with no parsing done.
# Provide a single line with all complete flags.
Expand Down
0