diff options
-rw-r--r-- | .style.yapf | 2 | ||||
-rw-r--r-- | flake8.ini | 4 | ||||
-rw-r--r-- | lib/spack/docs/packaging_guide.rst | 16 | ||||
-rwxr-xr-x | lib/spack/env/cc | 39 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/compiler.py | 18 | ||||
-rw-r--r-- | lib/spack/spack/compilers/nag.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/test/cc.py | 5 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/openmpi/package.py | 63 |
9 files changed, 121 insertions, 51 deletions
diff --git a/.style.yapf b/.style.yapf index 4741fb4f3b..a4b3f65252 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,3 +1,3 @@ [style] based_on_style = pep8 -column_limit = 80 +column_limit = 79 diff --git a/flake8.ini b/flake8.ini index 757c71705e..32ced73dd7 100644 --- a/flake8.ini +++ b/flake8.ini @@ -1,3 +1,3 @@ [flake8] -ignore = W391,F403 -max-line-length = 120
\ No newline at end of file +ignore = W391,F403,E221,F821 +max-line-length = 79 diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst index 31c676d4f5..1b7941ab24 100644 --- a/lib/spack/docs/packaging_guide.rst +++ b/lib/spack/docs/packaging_guide.rst @@ -1803,15 +1803,15 @@ Compile-time library search paths * ``-L$dep_prefix/lib`` * ``-L$dep_prefix/lib64`` Runtime library search paths (RPATHs) - * ``-Wl,-rpath,$dep_prefix/lib`` - * ``-Wl,-rpath,$dep_prefix/lib64`` + * ``$rpath_flag$dep_prefix/lib`` + * ``$rpath_flag$dep_prefix/lib64`` Include search paths * ``-I$dep_prefix/include`` An example of this would be the ``libdwarf`` build, which has one dependency: ``libelf``. Every call to ``cc`` in the ``libdwarf`` build will have ``-I$LIBELF_PREFIX/include``, -``-L$LIBELF_PREFIX/lib``, and ``-Wl,-rpath,$LIBELF_PREFIX/lib`` +``-L$LIBELF_PREFIX/lib``, and ``$rpath_flag$LIBELF_PREFIX/lib`` inserted on the command line. This is done transparently to the project's build system, which will just think it's using a system where ``libelf`` is readily available. Because of this, you **do @@ -1831,6 +1831,14 @@ successfully find ``libdwarf.h`` and ``libdwarf.so``, without the packager having to provide ``--with-libdwarf=/path/to/libdwarf`` on the command line. +.. note:: + + For most compilers, ``$rpath_flag`` is ``-Wl,-rpath,``. However, NAG + passes its flags to GCC instead of passing them directly to the linker. + Therefore, its ``$rpath_flag`` is doubly wrapped: ``-Wl,-Wl,,-rpath,``. + ``$rpath_flag`` can be overriden on a compiler specific basis in + ``lib/spack/spack/compilers/$compiler.py``. + Compiler flags ~~~~~~~~~~~~~~ In rare circumstances such as compiling and running small unit tests, a package @@ -1848,8 +1856,6 @@ package supports additional variants like variant('openmp', default=True, description="Enable OpenMP support.") - - Message Parsing Interface (MPI) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is common for high performance computing software/packages to use ``MPI``. diff --git a/lib/spack/env/cc b/lib/spack/env/cc index cb07a2ffea..4564e84bd2 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -38,15 +38,20 @@ # -Wl,-rpath arguments for dependency /lib directories. # -# This is the list of environment variables that need to be set before +# This is an array of environment variables that need to be set before # the script runs. They are set by routines in spack.build_environment # as part of spack.package.Package.do_install(). -parameters=" -SPACK_PREFIX -SPACK_ENV_PATH -SPACK_DEBUG_LOG_DIR -SPACK_COMPILER_SPEC -SPACK_SHORT_SPEC" +parameters=( + SPACK_PREFIX + SPACK_ENV_PATH + SPACK_DEBUG_LOG_DIR + SPACK_COMPILER_SPEC + SPACK_CC_RPATH_ARG + SPACK_CXX_RPATH_ARG + SPACK_F77_RPATH_ARG + SPACK_FC_RPATH_ARG + SPACK_SHORT_SPEC +) # The compiler input variables are checked for sanity later: # SPACK_CC, SPACK_CXX, SPACK_F77, SPACK_FC @@ -64,7 +69,7 @@ function die { exit 1 } -for param in $parameters; do +for param in ${parameters[@]}; do if [[ -z ${!param} ]]; then die "Spack compiler must be run from Spack! Input '$param' is missing." fi @@ -85,6 +90,7 @@ done # ccld compile & link command=$(basename "$0") +comp="CC" case "$command" in cpp) mode=cpp @@ -92,18 +98,22 @@ case "$command" in cc|c89|c99|gcc|clang|icc|pgcc|xlc) command="$SPACK_CC" language="C" + comp="CC" ;; c++|CC|g++|clang++|icpc|pgc++|xlc++) command="$SPACK_CXX" language="C++" + comp="CXX" ;; f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor) command="$SPACK_FC" language="Fortran 90" + comp="FC" ;; f77|gfortran|ifort|pgfortran|xlf|nagfor) command="$SPACK_F77" language="Fortran 77" + comp="F77" ;; ld) mode=ld @@ -142,6 +152,9 @@ if [[ -z $mode ]]; then done fi +# Set up rpath variable according to language. +eval rpath=\$SPACK_${comp}_RPATH_ARG + # Dump the version and exit if we're in testing mode. if [[ $SPACK_TEST_COMMAND == dump-mode ]]; then echo "$mode" @@ -188,7 +201,7 @@ for dep in "${deps[@]}"; do # Prepend lib and RPATH directories if [[ -d $dep/lib ]]; then if [[ $mode == ccld ]]; then - $add_rpaths && args=("-Wl,-rpath,$dep/lib" "${args[@]}") + $add_rpaths && args=("$rpath$dep/lib" "${args[@]}") args=("-L$dep/lib" "${args[@]}") elif [[ $mode == ld ]]; then $add_rpaths && args=("-rpath" "$dep/lib" "${args[@]}") @@ -199,7 +212,7 @@ for dep in "${deps[@]}"; do # Prepend lib64 and RPATH directories if [[ -d $dep/lib64 ]]; then if [[ $mode == ccld ]]; then - $add_rpaths && args=("-Wl,-rpath,$dep/lib64" "${args[@]}") + $add_rpaths && args=("$rpath$dep/lib64" "${args[@]}") args=("-L$dep/lib64" "${args[@]}") elif [[ $mode == ld ]]; then $add_rpaths && args=("-rpath" "$dep/lib64" "${args[@]}") @@ -210,9 +223,11 @@ done # Include all -L's and prefix/whatever dirs in rpath if [[ $mode == ccld ]]; then - $add_rpaths && args=("-Wl,-rpath,$SPACK_PREFIX/lib" "-Wl,-rpath,$SPACK_PREFIX/lib64" "${args[@]}") + $add_rpaths && args=("$rpath$SPACK_PREFIX/lib64" "${args[@]}") + $add_rpaths && args=("$rpath$SPACK_PREFIX/lib" "${args[@]}") elif [[ $mode == ld ]]; then - $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "-rpath" "$SPACK_PREFIX/lib64" "${args[@]}") + $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib64" "${args[@]}") + $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "${args[@]}") fi # diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index cd9f647ddf..8961886049 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -98,21 +98,27 @@ def set_compiler_environment_variables(pkg, env): # and return it # TODO : add additional kwargs for better diagnostics, like requestor, ttyout, ttyerr, etc. link_dir = spack.build_env_path - env.set('CC', join_path(link_dir, pkg.compiler.link_paths['cc'])) + env.set('CC', join_path(link_dir, pkg.compiler.link_paths['cc'])) env.set('CXX', join_path(link_dir, pkg.compiler.link_paths['cxx'])) env.set('F77', join_path(link_dir, pkg.compiler.link_paths['f77'])) - env.set('FC', join_path(link_dir, pkg.compiler.link_paths['fc'])) + env.set('FC', join_path(link_dir, pkg.compiler.link_paths['fc'])) # Set SPACK compiler variables so that our wrapper knows what to call compiler = pkg.compiler if compiler.cc: - env.set('SPACK_CC', compiler.cc) + env.set('SPACK_CC', compiler.cc) if compiler.cxx: env.set('SPACK_CXX', compiler.cxx) if compiler.f77: env.set('SPACK_F77', compiler.f77) if compiler.fc: - env.set('SPACK_FC', compiler.fc) + env.set('SPACK_FC', compiler.fc) + + # Set SPACK compiler rpath flags so that our wrapper knows what to use + env.set('SPACK_CC_RPATH_ARG', compiler.cc_rpath_arg) + env.set('SPACK_CXX_RPATH_ARG', compiler.cxx_rpath_arg) + env.set('SPACK_F77_RPATH_ARG', compiler.f77_rpath_arg) + env.set('SPACK_FC_RPATH_ARG', compiler.fc_rpath_arg) env.set('SPACK_COMPILER_SPEC', str(pkg.spec.compiler)) return env diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 030dc449fc..0f208caaf3 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -91,8 +91,22 @@ class Compiler(object): # version suffix for gcc. suffixes = [r'-.*'] - # Names of generic arguments used by this compiler - arg_rpath = '-Wl,-rpath,%s' + # Default flags used by a compiler to set an rpath + @property + def cc_rpath_arg(self): + return '-Wl,-rpath,' + + @property + def cxx_rpath_arg(self): + return '-Wl,-rpath,' + + @property + def f77_rpath_arg(self): + return '-Wl,-rpath,' + + @property + def fc_rpath_arg(self): + return '-Wl,-rpath,' def __init__(self, cspec, cc, cxx, f77, fc): diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index e9038c1039..49b77eae6b 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -31,6 +31,17 @@ class Nag(Compiler): # However, it can be mixed with a compiler that does support it return "-std=c++11" + # Unlike other compilers, the NAG compiler passes options to GCC, which + # then passes them to the linker. Therefore, we need to doubly wrap the + # options with '-Wl,-Wl,,' + @property + def f77_rpath_arg(self): + return '-Wl,-Wl,,-rpath,' + + @property + def fc_rpath_arg(self): + return '-Wl,-Wl,,-rpath,' + @classmethod def default_version(self, comp): """The '-V' option works for nag compilers. diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py index 594cd6efe9..35392d9d6d 100644 --- a/lib/spack/spack/test/cc.py +++ b/lib/spack/spack/test/cc.py @@ -67,6 +67,11 @@ class CompilerTest(unittest.TestCase): os.environ['SPACK_COMPILER_SPEC'] = "gcc@4.4.7" os.environ['SPACK_SHORT_SPEC'] = "foo@1.2" + os.environ['SPACK_CC_RPATH_ARG'] = "-Wl,-rpath," + os.environ['SPACK_CXX_RPATH_ARG'] = "-Wl,-rpath," + os.environ['SPACK_F77_RPATH_ARG'] = "-Wl,-rpath," + os.environ['SPACK_FC_RPATH_ARG'] = "-Wl,-rpath," + # Make some fake dependencies self.tmp_deps = tempfile.mkdtemp() self.dep1 = join_path(self.tmp_deps, 'dep1') diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py index d0dd2d657f..c656f78dab 100644 --- a/var/spack/repos/builtin/packages/openmpi/package.py +++ b/var/spack/repos/builtin/packages/openmpi/package.py @@ -1,6 +1,8 @@ -from spack import * import os +from spack import * + + class Openmpi(Package): """Open MPI is a project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) @@ -26,17 +28,26 @@ class Openmpi(Package): patch('configure.patch', when="@1.10.0:1.10.1") variant('psm', default=False, description='Build support for the PSM library.') - variant('pmi', default=True, description='Build support for PMI-based launchers') + variant('psm2', default=False, description='Build support for the Intel PSM2 library.') + variant('pmi', default=False, description='Build support for PMI-based launchers') variant('verbs', default=False, description='Build support for OpenFabrics verbs.') + variant('mxm', default=False, description='Build Mellanox Messaging support') + + variant('thread_multiple', default=False, description='Enable MPI_THREAD_MULTIPLE support') - # TODO : variant support for other schedulers is missing + # TODO : variant support for alps, loadleveler is missing variant('tm', default=False, description='Build TM (Torque, PBSPro, and compatible) support') + variant('slurm', default=False, description='Build SLURM scheduler component') + + variant('sqlite3', default=False, description='Build sqlite3 support') + + # TODO : support for CUDA is missing provides('mpi@:2.2', when='@1.6.5') provides('mpi@:3.0', when='@1.7.5:') depends_on('hwloc') - + depends_on('sqlite', when='+sqlite3') def url_for_version(self, version): return "http://www.open-mpi.org/software/ompi/v%s/downloads/openmpi-%s.tar.bz2" % (version.up_to(2), version) @@ -54,30 +65,35 @@ class Openmpi(Package): self.spec.mpifc = join_path(self.prefix.bin, 'mpif90') self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77') + @property + def verbs(self): + # Up through version 1.6, this option was previously named --with-openib + if self.spec.satisfies('@:1.6'): + return 'openib' + # In version 1.7, it was renamed to be --with-verbs + elif self.spec.satisfies('@1.7:'): + return 'verbs' def install(self, spec, prefix): config_args = ["--prefix=%s" % prefix, "--with-hwloc=%s" % spec['hwloc'].prefix, "--enable-shared", "--enable-static"] - - # Variants - if '+tm' in spec: - config_args.append("--with-tm") # necessary for Torque support - - if '+psm' in spec: - config_args.append("--with-psm") - - if '+pmi' in spec: - config_args.append("--with-pmi") #TODO: let user specify directory when possible - - if '+verbs' in spec: - # Up through version 1.6, this option was previously named --with-openib - if spec.satisfies('@:1.6'): - config_args.append("--with-openib") - # In version 1.7, it was renamed to be --with-verbs - elif spec.satisfies('@1.7:'): - config_args.append("--with-verbs") + # Variant based arguments + config_args.extend([ + # Schedulers + '--with-tm' if '+tm' in spec else '--without-tm', + '--with-slurm' if '+slurm' in spec else '--without-slurm', + # Fabrics + '--with-psm' if '+psm' in spec else '--without-psm', + '--with-psm2' if '+psm2' in spec else '--without-psm2', + ('--with-%s' % self.verbs) if '+verbs' in spec else ('--without-%s' % self.verbs), + '--with-mxm' if '+mxm' in spec else '--without-mxm', + # Other options + '--enable-mpi-thread-multiple' if '+thread_multiple' in spec else '--disable-mpi-thread-multiple', + '--with-pmi' if '+pmi' in spec else '--without-pmi', + '--with-sqlite3' if '+sqlite3' in spec else '--without-sqlite3' + ]) # TODO: use variants for this, e.g. +lanl, +llnl, etc. # use this for LANL builds, but for LLNL builds, we need: @@ -85,9 +101,6 @@ class Openmpi(Package): if self.version == ver("1.6.5") and '+lanl' in spec: config_args.append("--with-platform=contrib/platform/lanl/tlcc2/optimized-nopanasas") - # TODO: Spack should make it so that you can't actually find - # these compilers if they're "disabled" for the current - # compiler configuration. if not self.compiler.f77 and not self.compiler.fc: config_args.append("--enable-mpi-fortran=no") |