From 5b109c9ad27aea39ce49d1da8ef0c957ccaef3b9 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Thu, 20 Jun 2019 14:07:01 -0400 Subject: correct missing argument for IntelClFortranCompiler ifort passes all tests cleanup logic --- mesonbuild/backend/ninjabackend.py | 6 +++--- mesonbuild/compilers/fortran.py | 20 +++++++++++--------- mesonbuild/environment.py | 4 ++-- mesonbuild/interpreter.py | 16 ++++++++-------- 4 files changed, 24 insertions(+), 22 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 54535ff52..a454e6ab5 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2164,7 +2164,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) # outdir argument instead. # https://github.com/mesonbuild/meson/issues/1348 if not is_generated: - abs_src = os.path.join(build_dir, rel_src) + abs_src = Path(build_dir) / rel_src extra_deps += self.get_fortran_deps(compiler, abs_src, target) # Dependency hack. Remove once multiple outputs in Ninja is fixed: # https://groups.google.com/forum/#!topic/ninja-build/j-2RfBIOd_8 @@ -2802,7 +2802,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi # a common occurrence, which would lead to lots of # distracting noise. continue - srcfile = srcdir / tdeps[usename].fname + srcfile = srcdir / tdeps[usename].fname # type: Path if not srcfile.is_file(): if srcfile.name != src.name: # generated source file pass @@ -2824,7 +2824,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi ancestor_child = '_'.join(parents) if ancestor_child not in tdeps: raise MesonException("submodule {} relies on ancestor module {} that was not found.".format(submodmatch.group(2).lower(), ancestor_child.split('_')[0])) - submodsrcfile = srcdir / tdeps[ancestor_child].fname + submodsrcfile = srcdir / tdeps[ancestor_child].fname # type: Path if not submodsrcfile.is_file(): if submodsrcfile.name != src.name: # generated source file pass diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index fe23b6b81..244e6f616 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -65,10 +65,13 @@ class FortranCompiler(CLikeCompiler, Compiler): extra_flags = environment.coredata.get_external_args(self.for_machine, self.language) extra_flags += environment.coredata.get_external_link_args(self.for_machine, self.language) extra_flags += self.get_always_args() - # %% build the test executable - pc = subprocess.Popen(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)]) - pc.wait() - if pc.returncode != 0: + # %% build the test executable "sanitycheckf" + # cwd=work_dir is necessary on Windows especially for Intel compilers to avoid error: cannot write on sanitycheckf.obj + # this is a defect with how Windows handles files and ifort's object file-writing behavior vis concurrent ProcessPoolExecutor. + # This simple workaround solves the issue. + returncode = subprocess.run(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)], + cwd=work_dir).returncode + if returncode != 0: raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string()) if self.is_cross: if self.exe_wrapper is None: @@ -79,9 +82,8 @@ class FortranCompiler(CLikeCompiler, Compiler): cmdlist = [str(binary_name)] # %% Run the test executable try: - pe = subprocess.Popen(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - pe.wait() - if pe.returncode != 0: + returncode = subprocess.run(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode + if returncode != 0: raise EnvironmentException('Executables created by Fortran compiler %s are not runnable.' % self.name_string()) except OSError: raise EnvironmentException('Executables created by Fortran compiler %s are not runnable.' % self.name_string()) @@ -271,8 +273,8 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler): 'custom': [], } - def __init__(self, exelist, version, is_cross, target: str, exe_wrapper=None): - FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) + def __init__(self, exelist, for_machine: MachineChoice, version, is_cross, target: str, exe_wrapper=None): + FortranCompiler.__init__(self, exelist, for_machine, version, is_cross, exe_wrapper) IntelVisualStudioLikeCompiler.__init__(self, target) default_warn_args = ['/warn:general', '/warn:truncated_source'] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 555c21c65..adae8f17b 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -854,7 +854,7 @@ class Environment: return cls(ccache + compiler, version, for_machine, exe_wrap) raise EnvironmentException('Could not find suitable CUDA compiler: "' + ' '.join(compilers) + '"') - def detect_fortran_compiler(self, for_machine): + def detect_fortran_compiler(self, for_machine: MachineChoice): popen_exceptions = {} compilers, ccache, exe_wrap = self._get_compilers('fortran', for_machine) is_cross = not self.machines.matches_build_machine(for_machine) @@ -901,7 +901,7 @@ class Environment: if 'Intel(R) Visual Fortran' in err: version = search_version(err) target = 'x86' if 'IA-32' in err else 'x86_64' - return IntelClFortranCompiler(compiler, version, is_cross, target, exe_wrap) + return IntelClFortranCompiler(compiler, version, for_machine, is_cross, target, exe_wrap) if 'ifort (IFORT)' in out: return IntelFortranCompiler(compiler, version, for_machine, is_cross, exe_wrap, full_version=full_version) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index dbe623c81..59a3642ae 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -40,7 +40,7 @@ from collections import namedtuple from itertools import chain from pathlib import PurePath import functools -import typing +from typing import Sequence, List, Union, Optional, Iterator, Dict, Any import importlib @@ -874,10 +874,10 @@ class RunTargetHolder(InterpreterObject, ObjectHolder): return r.format(self.__class__.__name__, h.get_id(), h.command) class Test(InterpreterObject): - def __init__(self, name: str, project: str, suite: typing.List[str], exe: build.Executable, - depends: typing.List[typing.Union[build.CustomTarget, build.BuildTarget]], - is_parallel: bool, cmd_args: typing.List[str], env: build.EnvironmentVariables, - should_fail: bool, timeout: int, workdir: typing.Optional[str], protocol: str): + def __init__(self, name: str, project: str, suite: List[str], exe: build.Executable, + depends: List[Union[build.CustomTarget, build.BuildTarget]], + is_parallel: bool, cmd_args: List[str], env: build.EnvironmentVariables, + should_fail: bool, timeout: int, workdir: Optional[str], protocol: str): InterpreterObject.__init__(self) self.name = name self.suite = suite @@ -2773,7 +2773,7 @@ external dependencies (including libraries) must go to "dependencies".''') self.validate_arguments(args, 0, []) raise Exception() - def add_languages(self, args, required): + def add_languages(self, args: Sequence[str], required: bool) -> bool: success = self.add_languages_for(args, required, MachineChoice.BUILD) success &= self.add_languages_for(args, required, MachineChoice.HOST) return success @@ -3831,7 +3831,7 @@ different subdirectory. # TODO make cross agnostic, just taking into account for_machine # TODO PerMachine[T], Iterator[T] - def get_argdict_on_crossness(self, dicts_per_machine: PerMachine, kwargs) -> typing.Iterator: + def get_argdict_on_crossness(self, dicts_per_machine: PerMachine, kwargs) -> Iterator: for_native = kwargs.get('native', not self.environment.is_cross_build()) if not isinstance(for_native, bool): raise InterpreterException('Keyword native must be a boolean.') @@ -4218,7 +4218,7 @@ This will become a hard error in the future.''', location=self.current_node) return varname in self.variables @staticmethod - def machine_from_native_kwarg(kwargs: typing.Dict[str, typing.Any]) -> MachineChoice: + def machine_from_native_kwarg(kwargs: Dict[str, Any]) -> MachineChoice: native = kwargs.get('native', False) if not isinstance(native, bool): raise InvalidArguments('Argument to "native" must be a boolean.') -- cgit v1.2.3 From 838c8d642c2ae0251b7c965a97c2a8d9e6be4d8b Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Thu, 20 Jun 2019 20:03:05 -0400 Subject: BUGFIX: typo for PGI C/CPP --- mesonbuild/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index adae8f17b..0cf511f82 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -792,7 +792,7 @@ class Environment: else: compiler_type = CompilerType.PGI_STANDARD cls = PGICCompiler if lang == 'c' else PGICPPCompiler - return cls(ccache + compiler, version, compiler_type, for_machine, is_cross, compiler_type, exe_wrap) + return cls(ccache + compiler, version, compiler_type, for_machine, is_cross, exe_wrap) if '(ICC)' in out: if self.machines[for_machine].is_darwin(): compiler_type = CompilerType.ICC_OSX -- cgit v1.2.3 From 9a3bc754108b10eb1a9fd4016e8bf7c98f3450c9 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 21 Jun 2019 01:24:54 -0400 Subject: intel windows coarray args --- mesonbuild/dependencies/misc.py | 4 ++++ test cases/fortran/13 coarray/meson.build | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index e5fab6459..80bacd247 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -66,6 +66,10 @@ class CoarrayDependency(ExternalDependency): self.is_found = True self.link_args = ['-coarray=shared'] self.compile_args = self.link_args + elif cid == 'intel-cl': + """ Coarrays are built into Intel compilers, no external library needed """ + self.is_found = True + self.compile_args = ['/Qcoarray:shared'] elif cid == 'nagfor': """ NAG doesn't require any special arguments for Coarray """ self.is_found = True diff --git a/test cases/fortran/13 coarray/meson.build b/test cases/fortran/13 coarray/meson.build index 57aa29edb..3160aa6b0 100644 --- a/test cases/fortran/13 coarray/meson.build +++ b/test cases/fortran/13 coarray/meson.build @@ -1,4 +1,5 @@ -project('Fortran coarray', 'fortran') +project('Fortran coarray', 'fortran', + meson_version: '>=0.50') # coarray is required because single-image fallback is an intrinsic feature coarray = dependency('coarray', required : true) -- cgit v1.2.3 From cf7935be614158b14cf903aed292eaad6a866f4b Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 21 Jun 2019 01:27:31 -0400 Subject: update compiler ID for windows INtel MPI --- mesonbuild/dependencies/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 80bacd247..483d73e70 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -217,7 +217,7 @@ class MPIDependency(ExternalDependency): if not self.is_found and mesonlib.is_windows(): # only Intel Fortran compiler is compatible with Microsoft MPI at this time. - if language == 'fortran' and environment.detect_fortran_compiler(self.for_machine).name_string() != 'intel': + if language == 'fortran' and environment.detect_fortran_compiler(self.for_machine).name_string() != 'intel-ci': return result = self._try_msmpi() if result is not None: -- cgit v1.2.3 From 1d6ed8cac832f1440ebcc74c21db018d8eb485a9 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 21 Jun 2019 03:53:58 -0400 Subject: windows ifort can't do shared_library sanely --- mesonbuild/compilers/fortran.py | 6 ++---- test cases/fortran/6 dynamic/meson.build | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 244e6f616..502cd1dac 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -139,9 +139,7 @@ class FortranCompiler(CLikeCompiler, Compiler): return filename def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): - code = '''program main - call exit(0) - end program main''' + code = '''stop; end program''' return self.find_library_impl(libname, env, extra_dirs, code, libtype) def has_multi_arguments(self, args, env): @@ -160,7 +158,7 @@ class FortranCompiler(CLikeCompiler, Compiler): 'the compiler you are using. has_link_argument or ' 'other similar method can be used instead.' .format(arg)) - code = 'program main\ncall exit(0)\nend program main' + code = 'stop; end program' return self.has_arguments(args, env, code, mode='compile') diff --git a/test cases/fortran/6 dynamic/meson.build b/test cases/fortran/6 dynamic/meson.build index e5e259fc8..244a38b56 100644 --- a/test cases/fortran/6 dynamic/meson.build +++ b/test cases/fortran/6 dynamic/meson.build @@ -1,5 +1,11 @@ project('dynamic_fortran', 'fortran') +if meson.get_compiler('fortran').get_id() == 'intel-cl' + error('MESON_SKIP_TEST: Windows ifort does not use shared_library in a sane way') + # !DEC$ ATTRIBUTES DLLEXPORT must be used! + # https://software.intel.com/en-us/node/535306 +endif + dynamic = shared_library('dynamic', 'dynamic.f90') exe = executable('test_exe', 'main.f90', link_with : dynamic) test('dynamic-fortran', exe) -- cgit v1.2.3 From c89aa2094170b2ffd7151187c1c092db2a178f44 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 21 Jun 2019 09:53:58 -0400 Subject: known Python 3.5 on windows workaround for subprocess(cwd=str(Path)) --- mesonbuild/compilers/fortran.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 502cd1dac..effdbadf9 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -69,8 +69,9 @@ class FortranCompiler(CLikeCompiler, Compiler): # cwd=work_dir is necessary on Windows especially for Intel compilers to avoid error: cannot write on sanitycheckf.obj # this is a defect with how Windows handles files and ifort's object file-writing behavior vis concurrent ProcessPoolExecutor. # This simple workaround solves the issue. + # FIXME: cwd=str(work_dir) is for Python 3.5 on Windows, when 3.5 is deprcated, this can become cwd=work_dir returncode = subprocess.run(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)], - cwd=work_dir).returncode + cwd=str(work_dir)).returncode if returncode != 0: raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string()) if self.is_cross: -- cgit v1.2.3 From f990c3eee456a186548dcc48f1d2dca5d8172fe4 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Mon, 24 Jun 2019 14:07:32 -0400 Subject: typo --- mesonbuild/dependencies/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 483d73e70..1bb1b6e32 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -217,7 +217,7 @@ class MPIDependency(ExternalDependency): if not self.is_found and mesonlib.is_windows(): # only Intel Fortran compiler is compatible with Microsoft MPI at this time. - if language == 'fortran' and environment.detect_fortran_compiler(self.for_machine).name_string() != 'intel-ci': + if language == 'fortran' and environment.detect_fortran_compiler(self.for_machine).name_string() != 'intel-cl': return result = self._try_msmpi() if result is not None: -- cgit v1.2.3