diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/likwid/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/likwid/package.py | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/var/spack/repos/builtin/packages/likwid/package.py b/var/spack/repos/builtin/packages/likwid/package.py index 8b42efd0ba..20710f183c 100644 --- a/var/spack/repos/builtin/packages/likwid/package.py +++ b/var/spack/repos/builtin/packages/likwid/package.py @@ -6,6 +6,8 @@ import glob import os +import llnl.util.tty as tty + from spack.package import * @@ -64,6 +66,13 @@ class Likwid(Package): variant("fortran", default=True, description="with fortran interface") variant("cuda", default=False, description="with Nvidia GPU profiling support") + variant( + "accessmode", + default="perf_event", + values=("perf_event", "accessdaemon"), + description="the default mode for MSR access", + ) + # NOTE: There is no way to use an externally provided hwloc with Likwid. # The reason is that the internal hwloc is patched to contain extra # functionality and functions are prefixed with "likwid_". @@ -126,11 +135,17 @@ class Likwid(Package): ) filter_file("^PREFIX .*", "PREFIX = " + prefix, "config.mk") - # FIXME: once https://github.com/spack/spack/issues/4432 is - # resolved, install as root by default and remove this - filter_file("^ACCESSMODE .*", "ACCESSMODE = perf_event", "config.mk") - filter_file("^BUILDFREQ .*", "BUILDFREQ = false", "config.mk") - filter_file("^BUILDDAEMON .*", "BUILDDAEMON = false", "config.mk") + filter_file( + "^ACCESSMODE .*", + "ACCESSMODE = {}".format(spec.variants["accessmode"].value), + "config.mk", + ) + if "accessmode=accessdaemon" in spec: + # Disable the chown, see the `spack_perms_fix` template and script + filter_file("^INSTALL_CHOWN .*", "INSTALL_CHOWN =", "config.mk") + else: + filter_file("^BUILDFREQ .*", "BUILDFREQ = false", "config.mk") + filter_file("^BUILDDAEMON .*", "BUILDDAEMON = false", "config.mk") if "+fortran" in self.spec: filter_file("^FORTRAN_INTERFACE .*", "FORTRAN_INTERFACE = true", "config.mk") @@ -187,3 +202,33 @@ class Likwid(Package): env["PWD"] = os.getcwd() make() make("install") + + # Until tty output works better from build steps, this ends up in + # the build log. See https://github.com/spack/spack/pull/10412. + @run_after("install") + def caveats(self): + if "accessmode=accessdaemon" in self.spec: + perm_script = "spack_perms_fix.sh" + perm_script_path = join_path(self.spec.prefix, perm_script) + daemons = glob.glob(join_path(self.spec.prefix, "sbin", "*")) + with open(perm_script_path, "w") as f: + env = spack.tengine.make_environment(dirs=self.package_dir) + t = env.get_template(perm_script + ".j2") + f.write( + t.render({"prefix": self.spec.prefix, "chowns": daemons, "chmods": daemons}) + ) + tty.warn( + """ + For full functionality, you'll need to chown and chmod some files + after installing the package. This has security implications. + + We've installed a script that will make the necessary changes; + read through it and then execute it as root (e.g. via sudo). + + The script is named: + + {0} + """.format( + perm_script_path + ) + ) |