From f4fb9a07718068fb96e22a43be6066daada92d10 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 20 Jul 2016 11:35:13 -0700 Subject: Set default link type to dynamic on cray. Includes hooks for platform-based environment changes --- lib/spack/spack/architecture.py | 6 ++++++ lib/spack/spack/build_environment.py | 6 ++++++ lib/spack/spack/platforms/cray_xc.py | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index a7cda2bf68..2701fa9a0c 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -190,6 +190,12 @@ class Platform(object): return self.operating_sys.get(name, None) + @classmethod + def setup_platform_environment(self, env): + """ Subclass can override this method if it requires any + platform-specific build environment modifications. + """ + pass @classmethod def detect(self): diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 93fb0690f7..4e799eeea1 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -248,6 +248,11 @@ def set_build_environment_variables(pkg, env, dirty=False): ci = join_path(item, 'case-insensitive') if os.path.isdir(ci): env_paths.append(ci) + +# for item in pkg.spec.platform.env_paths: +# env_paths.append(item) + # TODO: move platform-specific knowledge to platform. + # (join_path(spack.build_env_path, 'cray')) for item in reversed(env_paths): env.prepend_path('PATH', item) @@ -444,6 +449,7 @@ def setup_package(pkg, dirty=False): set_compiler_environment_variables(pkg, spack_env) set_build_environment_variables(pkg, spack_env, dirty) + pkg.spec.architecture.platform.setup_platform_environment(spack_env) load_external_modules(pkg) # traverse in postorder so package can use vars from its dependencies spec = pkg.spec diff --git a/lib/spack/spack/platforms/cray_xc.py b/lib/spack/spack/platforms/cray_xc.py index e3c7761a94..aee375ac89 100644 --- a/lib/spack/spack/platforms/cray_xc.py +++ b/lib/spack/spack/platforms/cray_xc.py @@ -44,6 +44,13 @@ class CrayXc(Platform): self.add_operating_system(str(linux_dist), linux_dist) self.add_operating_system('CNL10', Cnl()) + @classmethod + def setup_platform_environment(self, env): + """ Change the linker to default dynamic to be more + similar to linux/standard linker behavior + """ + env.set('CRAYPE_LINK_TYPE', 'dynamic') + @classmethod def detect(self): try: -- cgit v1.2.3-70-g09d2 From 7db41700623f33a4266c8265e45b511bc1aed24a Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 20 Jul 2016 11:36:47 -0700 Subject: removed commented-out code --- lib/spack/spack/build_environment.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 4e799eeea1..8e40e9883d 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -249,11 +249,6 @@ def set_build_environment_variables(pkg, env, dirty=False): if os.path.isdir(ci): env_paths.append(ci) -# for item in pkg.spec.platform.env_paths: -# env_paths.append(item) - # TODO: move platform-specific knowledge to platform. - # (join_path(spack.build_env_path, 'cray')) - for item in reversed(env_paths): env.prepend_path('PATH', item) env.set_path(SPACK_ENV_PATH, env_paths) -- cgit v1.2.3-70-g09d2 From 412618d53108d6417c88c62d85377f69f8bf1829 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 20 Jul 2016 11:52:16 -0700 Subject: fixed flake errors --- lib/spack/spack/architecture.py | 13 ++++--------- lib/spack/spack/build_environment.py | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 2701fa9a0c..6c3c478f91 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -76,7 +76,6 @@ attributes front_os and back_os. The operating system as described earlier, will be responsible for compiler detection. """ import os -import imp import inspect from llnl.util.lang import memoized, list_modules, key_ordering @@ -206,15 +205,12 @@ class Platform(object): """ raise NotImplementedError() - def __repr__(self): return self.__str__() - def __str__(self): return self.name - def _cmp_key(self): t_keys = ''.join(str(t._cmp_key()) for t in sorted(self.targets.values())) @@ -285,7 +281,7 @@ class OperatingSystem(object): # ensure all the version calls we made are cached in the parent # process, as well. This speeds up Spack a lot. - clist = reduce(lambda x, y: x+y, compiler_lists) + clist = reduce(lambda x, y: x + y, compiler_lists) return clist def find_compiler(self, cmp_cls, *path): @@ -326,7 +322,7 @@ class OperatingSystem(object): # prefer the one with more compilers. prev_paths = [prev.cc, prev.cxx, prev.f77, prev.fc] - newcount = len([p for p in paths if p is not None]) + newcount = len([p for p in paths if p is not None]) prevcount = len([p for p in prev_paths if p is not None]) # Don't add if it's not an improvement over prev compiler. @@ -343,6 +339,7 @@ class OperatingSystem(object): d['version'] = self.version return d + @key_ordering class Arch(object): """Architecture is now a class to help with setting attributes. @@ -383,11 +380,9 @@ class Arch(object): else: return '' - def __contains__(self, string): return string in str(self) - def _cmp_key(self): if isinstance(self.platform, Platform): platform = self.platform.name @@ -430,7 +425,7 @@ def _operating_system_from_dict(os_name, plat=None): if isinstance(os_name, dict): name = os_name['name'] version = os_name['version'] - return plat.operating_system(name+version) + return plat.operating_system(name + version) else: return plat.operating_system(os_name) diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 8e40e9883d..fbcba08367 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -248,7 +248,7 @@ def set_build_environment_variables(pkg, env, dirty=False): ci = join_path(item, 'case-insensitive') if os.path.isdir(ci): env_paths.append(ci) - + for item in reversed(env_paths): env.prepend_path('PATH', item) env.set_path(SPACK_ENV_PATH, env_paths) -- cgit v1.2.3-70-g09d2 From 6983c1d30d6e4f93ee8d8a0df87e3c9ea8cde103 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 20 Jul 2016 12:04:00 -0700 Subject: Documented linker default --- lib/spack/docs/basic_usage.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/spack/docs/basic_usage.rst b/lib/spack/docs/basic_usage.rst index 50a161a175..948092047b 100644 --- a/lib/spack/docs/basic_usage.rst +++ b/lib/spack/docs/basic_usage.rst @@ -1866,6 +1866,10 @@ to call the Cray compiler wrappers during build time. For more on compiler configuration, check out :ref:`compiler-config`. +Spack sets the default Cray link type to dynamic, to better match other +other platforms. Individual packages can enable static linking (which is the +default outside of Spack on cray systems) using the -static flag. + Setting defaults and using Cray modules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3-70-g09d2 From eda1176ba7d70327ca847d6b17afa02f8cca0d5b Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 20 Jul 2016 12:26:31 -0700 Subject: added package as argument to setup_platform_environment --- lib/spack/spack/architecture.py | 2 +- lib/spack/spack/build_environment.py | 2 +- lib/spack/spack/platforms/cray_xc.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 6c3c478f91..974505ee3a 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -190,7 +190,7 @@ class Platform(object): return self.operating_sys.get(name, None) @classmethod - def setup_platform_environment(self, env): + def setup_platform_environment(self, pkg, env): """ Subclass can override this method if it requires any platform-specific build environment modifications. """ diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index fbcba08367..5affd3c7c5 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -444,7 +444,7 @@ def setup_package(pkg, dirty=False): set_compiler_environment_variables(pkg, spack_env) set_build_environment_variables(pkg, spack_env, dirty) - pkg.spec.architecture.platform.setup_platform_environment(spack_env) + pkg.spec.architecture.platform.setup_platform_environment(pkg, spack_env) load_external_modules(pkg) # traverse in postorder so package can use vars from its dependencies spec = pkg.spec diff --git a/lib/spack/spack/platforms/cray_xc.py b/lib/spack/spack/platforms/cray_xc.py index aee375ac89..2b065d5bbd 100644 --- a/lib/spack/spack/platforms/cray_xc.py +++ b/lib/spack/spack/platforms/cray_xc.py @@ -45,11 +45,14 @@ class CrayXc(Platform): self.add_operating_system('CNL10', Cnl()) @classmethod - def setup_platform_environment(self, env): + def setup_platform_environment(self, pkg, env): """ Change the linker to default dynamic to be more similar to linux/standard linker behavior """ env.set('CRAYPE_LINK_TYPE', 'dynamic') + cray_wrapper_names = join_path(spack.build_env_path, 'cray') + if os.path.isdir(cray_wrapper_names): + env.prepend_path('PATH', cray_wrapper_names) @classmethod def detect(self): -- cgit v1.2.3-70-g09d2