binutils: detect the "gold" and "headers" variants (#40214)

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Bernhard Kaindl 2024-06-08 02:08:55 +02:00 committed by GitHub
parent 52cc603245
commit 528c1ed9ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 @@ def determine_version(cls, exe):
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