diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2017-07-19 04:49:32 -0400 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2017-08-04 20:07:08 -0400 |
commit | 271601124e22695bfa0b0791543473b7164948b1 (patch) | |
tree | 7a3b69a844cd8b29a24b393fc8d80d975f3a70c5 /mesonbuild | |
parent | 17b051c8b1939177c1e3f81bae58c7ce40cdbce3 (diff) | |
download | meson-271601124e22695bfa0b0791543473b7164948b1.zip meson-271601124e22695bfa0b0791543473b7164948b1.tar.gz meson-271601124e22695bfa0b0791543473b7164948b1.tar.bz2 |
Filter out extra args from MPI wrappers.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/dependencies/misc.py | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 71f7369..4773f2f 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -331,15 +331,15 @@ class MPIDependency(ExternalDependency): if result is not None: self.is_found = True self.version = result[0] - self.compile_args = result[1] - self.link_args = result[2] + self.compile_args = self._filter_compile_args(result[1]) + self.link_args = self._filter_link_args(result[2]) break result = self._try_other_wrapper(prog) if result is not None: self.is_found = True self.version = result[0] - self.compile_args = result[1] - self.link_args = result[2] + self.compile_args = self._filter_compile_args(result[1]) + self.link_args = self._filter_link_args(result[2]) break if self.is_found: @@ -349,6 +349,48 @@ class MPIDependency(ExternalDependency): if required: raise DependencyException('MPI dependency {!r} not found'.format(self.name)) + def _filter_compile_args(self, args): + """ + MPI wrappers return a bunch of garbage args. + Drop -O2 and everything that is not needed. + """ + result = [] + multi_args = ('-I', ) + if self.language == 'fortran': + fc = self.env.coredata.compilers['fortran'] + multi_args += fc.get_module_incdir_args() + + include_next = False + for f in args: + if f.startswith(('-D', '-f') + multi_args) or f == '-pthread' \ + or (f.startswith('-W') and f != '-Wall' and not f.startswith('-Werror')): + result.append(f) + if f in multi_args: + # Path is a separate argument. + include_next = True + elif include_next: + include_next = False + result.append(f) + return result + + def _filter_link_args(self, args): + """ + MPI wrappers return a bunch of garbage args. + Drop -O2 and everything that is not needed. + """ + result = [] + include_next = False + for f in args: + if f.startswith(('-L', '-l', '-Xlinker')) or f == '-pthread' \ + or (f.startswith('-W') and f != '-Wall' and not f.startswith('-Werror')): + result.append(f) + if f in ('-L', '-Xlinker'): + include_next = True + elif include_next: + include_next = False + result.append(f) + return result + def _try_openmpi_wrapper(self, prog): prog = ExternalProgram(prog, silent=True) if prog.found(): |