dependencies/hdf5: Use the correct compilers for the machine

Instead of the default ones, this is especially important when cross
compiling or when using compilers that aren't compatible with the
default ones.
squash! dependencies/hdf5: Use the actual system compilers
pull/7758/head
Dylan Baker 5 years ago
parent b7cb30e175
commit 54329eeed7
  1. 3
      docs/markdown/snippets/hdf5_dependnecy_improvements.md
  2. 2
      mesonbuild/coredata.py
  3. 22
      mesonbuild/dependencies/hdf5.py

@ -4,3 +4,6 @@ HDF5 has been improved so that the internal representations have been split.
This allows selecting pkg-config and config-tool dependencies separately. This allows selecting pkg-config and config-tool dependencies separately.
Both work as proper dependencies of their type, so `get_variable` and similar Both work as proper dependencies of their type, so `get_variable` and similar
now work correctly. now work correctly.
It has also been fixed to use the selected compiler for the build instead of
the default compiler.

@ -390,7 +390,7 @@ class CoreData:
) # type: PerMachine[T.defaultdict[str, OptionDictType]] ) # type: PerMachine[T.defaultdict[str, OptionDictType]]
self.base_options = {} # type: OptionDictType self.base_options = {} # type: OptionDictType
self.cross_files = self.__load_config_files(options, scratch_dir, 'cross') self.cross_files = self.__load_config_files(options, scratch_dir, 'cross')
self.compilers = PerMachine(OrderedDict(), OrderedDict()) self.compilers = PerMachine(OrderedDict(), OrderedDict()) # type: PerMachine[T.Dict[str, Compiler]]
build_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD) build_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD)
host_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD) host_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD)

@ -15,12 +15,13 @@
# This file contains the detection logic for miscellaneous external dependencies. # This file contains the detection logic for miscellaneous external dependencies.
import functools import functools
import subprocess import os
import shutil
import re import re
import shutil
import subprocess
from pathlib import Path from pathlib import Path
from ..mesonlib import OrderedSet from ..mesonlib import OrderedSet, join_args
from .base import ( from .base import (
DependencyException, DependencyMethods, ConfigToolDependency, DependencyException, DependencyMethods, ConfigToolDependency,
PkgConfigDependency, factory_methods PkgConfigDependency, factory_methods
@ -94,10 +95,13 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
raise DependencyException('Language {} is not supported with HDF5.'.format(language)) raise DependencyException('Language {} is not supported with HDF5.'.format(language))
if language == 'c': if language == 'c':
cenv = 'CC'
tools = ['h5cc'] tools = ['h5cc']
elif language == 'cpp': elif language == 'cpp':
cenv = 'CXX'
tools = ['h5c++'] tools = ['h5c++']
elif language == 'fortran': elif language == 'fortran':
cenv = 'FC'
tools = ['h5fc'] tools = ['h5fc']
else: else:
raise DependencyException('How did you get here?') raise DependencyException('How did you get here?')
@ -108,7 +112,17 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
nkwargs = kwargs.copy() nkwargs = kwargs.copy()
nkwargs['tools'] = tools nkwargs['tools'] = tools
# Override the compiler that the config tools are going to use by
# setting the environment variables that they use for the compiler and
# linkers.
compiler = environment.coredata.compilers[for_machine][language]
try:
os.environ['HDF5_{}'.format(cenv)] = join_args(compiler.get_exelist())
os.environ['HDF5_{}LINKER'.format(cenv)] = join_args(compiler.get_linker_exelist())
super().__init__(name, environment, nkwargs, language) super().__init__(name, environment, nkwargs, language)
finally:
del os.environ['HDF5_{}'.format(cenv)]
del os.environ['HDF5_{}LINKER'.format(cenv)]
if not self.is_found: if not self.is_found:
return return
@ -126,7 +140,7 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
nkwargs = kwargs.copy() nkwargs = kwargs.copy()
nkwargs['language'] = 'c' nkwargs['language'] = 'c'
# I'm being too clever for mypy and pylint # I'm being too clever for mypy and pylint
self.is_found = self._add_sub_dependency(hdf5_factory(environment, self.for_machine, nkwargs)) # type: ignore # pylint: disable=no-value-for-parameter self.is_found = self._add_sub_dependency(hdf5_factory(environment, for_machine, nkwargs)) # type: ignore # pylint: disable=no-value-for-parameter
def _sanitize_version(self, ver: str) -> str: def _sanitize_version(self, ver: str) -> str:
v = re.search(r'\s*HDF5 Version: (\d+\.\d+\.\d+)', ver) v = re.search(r'\s*HDF5 Version: (\d+\.\d+\.\d+)', ver)

Loading…
Cancel
Save