From 528c1ed9ba2ee09710c1cf46cdcce6c8fc9404c0 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Sat, 8 Jun 2024 02:08:55 +0200 Subject: binutils: detect the "gold" and "headers" variants (#40214) Co-authored-by: Massimiliano Culpo --- var/spack/repos/builtin/packages/binutils/package.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/var/spack/repos/builtin/packages/binutils/package.py b/var/spack/repos/builtin/packages/binutils/package.py index 3f7b25cb79..5661c26521 100644 --- a/var/spack/repos/builtin/packages/binutils/package.py +++ b/var/spack/repos/builtin/packages/binutils/package.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import pathlib import re import spack.build_systems.autotools @@ -177,6 +178,20 @@ class Binutils(AutotoolsPackage, GNUMirrorPackage): match = re.search(r"GNU (nm|readelf).* (\S+)", output) return Version(match.group(2)).dotted.up_to(3) if match else None + @classmethod + def determine_variants(cls, exes, version_str): + bin_dir = pathlib.Path(exes[0]).parent + include_dir = bin_dir.parent / "include" + plugin_h = include_dir / "plugin-api.h" + + variants = "+gold" if find(str(bin_dir), "gold", recursive=False) else "~gold" + if find(str(include_dir), str(plugin_h), recursive=False): + variants += "+headers" + else: + variants += "~headers" + + return variants + def flag_handler(self, name, flags): spec = self.spec -- cgit v1.2.3-70-g09d2