oseledets / ttpy

Python implementation of the TT-Toolbox
MIT License
236 stars 67 forks source link

Compilation error with gfortran 11.1 on macOS with homebrew #82

Closed mkoeppe closed 2 years ago

mkoeppe commented 3 years ago

Installing ttpy (latest on PyPI or current git master) on macOS Big Sur (Intel) with homebrew leads to multiple compilation errors like the following:

  Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/COMPLEX(8)).
  tt/tt-fort/ort.f90:273:22:

    273 |    call dgemv('n',n,r,-1.d0,yy,n,gv,1, 1.d0,x,1)
        |                      1
  ......
    346 |     call dgemv('n',n,ru,-one,u,n,gu,1, one,x,1)
        |                        2
dimpase commented 3 years ago

The errors are in a git submodule, I've opened the issue in the corresponding repo: https://github.com/oseledets/tt-fort/issues/6

oseledets commented 3 years ago

Should we update the submodule now?

dimpase commented 3 years ago

The submodule is updated, but the fix is in its Makefile.in, which is not used here.

One has to figure out how to tell tt/setup.py to use the flag --fallow-argument-mismatch while calling gfortran in config.add_library('mytt', sources=...)

dimpase commented 3 years ago

the submodule actually even has working github actions test now :-)

dimpase commented 3 years ago

But for the life of me, I don't grok numpy.distutils, it's such a pile of .... Something like this:

config.add_library('mytt', sources=[join(TTFORT_DIR, x) for x in TTFORT_SRC], extra_f90_compiler_args=['--fallow-argument-mismatch'])

doesn't work.

dimpase commented 3 years ago

OK, I got it to build with gfortran 11, with the following changes:

diff --git a/tt/core/setup.py b/tt/core/setup.py
index 8f28de6..26a4f3f 100644
--- a/tt/core/setup.py
+++ b/tt/core/setup.py
@@ -40,6 +40,7 @@ def configuration(parent_package='', top_path=None):
     config.add_extension(
         'core_f90',
         sources=ttcore_src,
+        extra_f90_compile_args=['-fallow-argument-mismatch'],
     )

     return config
diff --git a/tt/eigb/setup.py b/tt/eigb/setup.py
index dd6240b..87d7a77 100644
--- a/tt/eigb/setup.py
+++ b/tt/eigb/setup.py
@@ -39,6 +39,7 @@ def configuration(parent_package='', top_path=None):
             'mytt',
             'print_lib',
         ],
+        extra_f90_compile_args=['-fallow-argument-mismatch'],
     )

     return config
diff --git a/tt/ksl/setup.py b/tt/ksl/setup.py
index 3bc950f..a9d9857 100644
--- a/tt/ksl/setup.py
+++ b/tt/ksl/setup.py
@@ -37,6 +37,8 @@ def configuration(parent_package='', top_path=None):
     config.add_library(
         'expokit',
         sources=expokit_src,
+            extra_f90_compile_args=['-fallow-argument-mismatch'],
+            extra_f77_compile_args=['-fallow-argument-mismatch'],
     )
     config.add_extension(
         'dyn_tt',
@@ -51,6 +53,7 @@ def configuration(parent_package='', top_path=None):
             'expokit',
             'mytt',
         ],
+        extra_f90_compile_args=['-fallow-argument-mismatch'],
     )

     return config
diff --git a/tt/setup.py b/tt/setup.py
index 277f90f..b4fc38a 100644
--- a/tt/setup.py
+++ b/tt/setup.py
@@ -59,9 +59,12 @@ def configuration(parent_package='', top_path=None):
         delegate_options_to_subpackages=True,
         quiet=False,
     )
-
+    buildinfo={}
+    buildinfo['extra_f90_compiler_args']=['--fallow-argument-mismatch']
     config.add_library('print_lib', sources=[join(PRINT_DIR, x) for x in PRINT_SRC])
-    config.add_library('mytt', sources=[join(TTFORT_DIR, x) for x in TTFORT_SRC])
+    config.add_library('mytt', sources=[join(TTFORT_DIR, x) for x in TTFORT_SRC],
+            extra_f90_compile_args=['-fallow-argument-mismatch'],
+    )

     config.add_subpackage('core')
     config.add_subpackage('amen')

this needs more work to make it conditional on the version of gfortran, as this option is not understood by version 9 or earlier.

dimpase commented 3 years ago

The diff above is here: https://github.com/dimpase/ttpy/commit/ba9619f61d63d4079585e8056883aa34fa7e1f21

daskol commented 3 years ago

PR #85 solves the issue. Also, I have created an issue oseledets/tt-fort#12 in the upstream repo in order to remember issue and track progress.

mkoeppe commented 3 years ago

Thank you, I can confirm that it solves the issue.

I'm using pip install with ttpy @ the specific commit in https://trac.sagemath.org/ticket/31998 now; do you have plans to release a new version of ttpy on PyPI any time soon?

ocbx33 commented 2 years ago

Hello, I still have the problem with python 3.8 and gcc-11(macos 11.6). The test on line 8 of the file distutils.py if fcompiler.get_version() >= '11.0': does not work, because fcompiler.get_version() returns 11 Could you change '11.0' in '11' ?

dimpase commented 2 years ago

this sounds familiar...

dimpase commented 2 years ago

Please see #90

daskol commented 2 years ago

Merged.