From 1570f90fde7a3c6623a1635bbe68f6a028369bf9 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Sun, 11 Dec 2016 01:23:39 +0100 Subject: clang: do xcode mockup iff requested by a package (#2544) * clang: do xcode mockup iff requested by a package * add a note * add pkg to setup_custom_environment() and decide whether or not to use mockup XCode there based on the package --- lib/spack/spack/build_environment.py | 2 +- lib/spack/spack/compiler.py | 2 +- lib/spack/spack/compilers/clang.py | 10 +++++++--- lib/spack/spack/package.py | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 5e99d4552b..619877275d 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -224,7 +224,7 @@ def set_compiler_environment_variables(pkg, env): for mod in compiler.modules: load_module(mod) - compiler.setup_custom_environment(env) + compiler.setup_custom_environment(pkg, env) return env diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 0d9727c69e..92fa1ac4db 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -286,7 +286,7 @@ class Compiler(object): """ return path - def setup_custom_environment(self, env): + def setup_custom_environment(self, pkg, env): """Set any environment variables necessary to use the compiler.""" pass diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index b2095defe5..14dc9d6476 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -148,7 +148,7 @@ class Clang(Compiler): def f77_version(cls, f77): return cls.fc_version(f77) - def setup_custom_environment(self, env): + def setup_custom_environment(self, pkg, env): """Set the DEVELOPER_DIR environment for the Xcode toolchain. On macOS, not all buildsystems support querying CC and CXX for the @@ -160,9 +160,13 @@ class Clang(Compiler): the 'DEVELOPER_DIR' environment variables to cause the xcrun and related tools to use this Xcode.app. """ - super(Clang, self).setup_custom_environment(env) + super(Clang, self).setup_custom_environment(pkg, env) - if not self.is_apple: + if not self.is_apple or not pkg.use_xcode: + # if we do it for all packages, we get into big troubles with MPI: + # filter_compilers(self) will use mockup XCode compilers on macOS + # with Clang. Those point to Spack's compiler wrappers and + # consequently render MPI non-functional outside of Spack. return xcode_select = Executable('xcode-select') diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 9c946844c6..31d08be456 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -487,6 +487,10 @@ class PackageBase(object): """By default do not run tests within package's install()""" run_tests = False + # FIXME: this is a bad object-oriented design, should be moved to Clang. + """By default do not setup mockup XCode on macOS with Clang""" + use_xcode = False + """Most packages are NOT extendable. Set to True if you want extensions.""" extendable = False -- cgit v1.2.3-60-g2f50