diff --git a/mpcdf_common.py b/mpcdf_common.py index d8c4e9239232881d324c9c100040486fe9b5f952..d351382df3f0066f591d69d5161146d9ab71bb4f 100644 --- a/mpcdf_common.py +++ b/mpcdf_common.py @@ -67,22 +67,11 @@ def dist_prjconf_tags(distribution): Optflags: x86_64 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection """).strip() - sles15_prjconf_tags = textwrap.dedent( - """ - %if "%{_repository}" == "gcc_6" || "%{_repository}" == "gcc_7" - # gcc6/7 cannot deal with "-fstack-clash-protection" that has been added in SLE15 by default - Optflags: x86_64 -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables - %endif - """ - ).strip() - res = "" if "CentOS" in distribution: res += centos_prjconf_tags if "CentOS_8" in distribution: res += "\n" + centos8_prjconf_tags - if "SLE_15" in distribution: - res += sles15_prjconf_tags return res @@ -215,21 +204,29 @@ def valid_mpi(compiler, mpi): return True -def prefers(reponame): - prefer_ps = None +def repo_tags(reponame, distribution=None): + if "gcc_6" in reponame or "gcc_7" in reponame and distribution == "SLE_15": + # gcc6/7 cannot deal with "-fstack-clash-protection" that has been added in SLE15 by default + optflags = ("Optflags: * -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables",) + else: + optflags = () + + ps = None if reponame in compiler_parallel_studio: - prefer_ps = compiler_parallel_studio[reponame]["ps"] + ps = compiler_parallel_studio[reponame]["ps"] else: for mpi in mpi_parallel_studio: if reponame.startswith(mpi): - prefer_ps = mpi_parallel_studio[mpi]["ps"] + ps = mpi_parallel_studio[mpi]["ps"] - if prefer_ps: - preferred_mkl = intel_parallel_studio[prefer_ps]["mkl"] - unprefer_other_mkls = sorted("!" + mkl for mkl in all_mkls if mkl != preferred_mkl) - return (prefer_ps,) + tuple(unprefer_other_mkls) + (preferred_mkl,) + if ps: + preferred_mkl = "Prefer: " + intel_parallel_studio[ps]["mkl"] + unprefer_other_mkls = sorted("Prefer: !" + mkl for mkl in all_mkls if mkl != preferred_mkl) + prefers = ("Prefer: " + ps,) + tuple(unprefer_other_mkls) + (preferred_mkl,) else: - return () + prefers = () + + return optflags + prefers def valid_cuda(cuda, compiler): @@ -613,8 +610,8 @@ def mpcdf_setup_subproject(api_url, project, distribution, microarchitecture, old_repos = set() for line in prjconf_ours: line = line.rstrip("\n") - if cur_repo is None and line.startswith("%if %_repository =="): - cur_repo = line.split()[-1] + if cur_repo is None and (line.startswith("%if %_repository ==") or line.startswith("%if \"%{_repository}\" == ")) and len(line.split()) == 4: + cur_repo = line.split()[-1].strip('"') old_repos.add(cur_repo) prjconf_repos[cur_repo] = [] if cur_repo is not None: @@ -646,7 +643,7 @@ Macros: for oldrepo in root.findall("./repository"): root.remove(oldrepo) - def repo(name, dependencies, compiler=False, mpi=False, cuda=False, cuda_mpi=False, additional_prefers=(), **macros): + def repo(name, dependencies, compiler=False, mpi=False, cuda=False, cuda_mpi=False, additional_tags=(), **macros): old_repos.discard(name) have_compiler = compiler or mpi or cuda or cuda_mpi have_mpi = mpi or cuda_mpi @@ -685,11 +682,11 @@ Macros: # the cases this makes sense matching_mkl = [] repoconf = [] - repoconf.append("%if %_repository == {0}".format(name)) - for prefer in prefers(name) + additional_prefers: - if prefer.startswith("mkl_"): - matching_mkl.append(prefer) - repoconf.append("Prefer: " + prefer) + repoconf.append("%if \"%{{_repository}}\" == \"{0}\"".format(name)) + for tag in repo_tags(name, distribution=distribution) + additional_tags: + if tag.startswith("Prefer: mkl"): + matching_mkl.append(tag.split()[1]) + repoconf.append(tag) repoconf.append("Macros:") @@ -759,7 +756,7 @@ Macros: dependencies = () repo(compiler, dependencies, compiler=True, compiler_repository=compiler, compiler_module=compiler_module(compiler), - additional_prefers=("mpcdf_compiler_" + compiler,)) + additional_tags=("Prefer: mpcdf_compiler_" + compiler,)) for mpi in filter(partial(valid_mpi, compiler), mpis): repo(mpi + "_" + compiler, ((project, compiler),), mpi=True, @@ -768,7 +765,7 @@ Macros: for cuda in cudas: for compiler in filter(partial(valid_cuda, cuda), compilers): repo(cuda + "_" + compiler, ((project, compiler),), cuda=True, cuda_repository=cuda, - additional_prefers=("mpcdf_" + cuda,)) + additional_tags=("Prefer: mpcdf_" + cuda,)) for mpi in filter(partial(valid_mpi, compiler), mpis): repo(cuda + "_" + mpi + "_" + compiler, ((project, cuda + "_" + compiler),