From d348d37c5a18a1e3a9fd5407faa633fb4a79e3b8 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Fri, 21 Aug 2026 02:43:37 +0200 Subject: [PATCH] autotools: skip compiler prefixes in autoreconf search path --- .../builtin/build_systems/autotools.py | 7 ++++++- tests/build_systems.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/repos/spack_repo/builtin/build_systems/autotools.py b/repos/spack_repo/builtin/build_systems/autotools.py index bcdff9159ea..8866c5e5d67 100644 --- a/repos/spack_repo/builtin/build_systems/autotools.py +++ b/repos/spack_repo/builtin/build_systems/autotools.py @@ -6,6 +6,7 @@ import subprocess from typing import Callable, List, Optional, Set, Tuple, Union +from spack import deptypes from spack.package import ( BuilderWithDefaults, Executable, @@ -856,7 +857,11 @@ def _autoreconf_search_path_args(spec: Spec) -> List[str]: except OSError: pass - for dep in spec.dependencies(deptype="build"): + for edge in spec.edges_to_dependencies(depflag=deptypes.BUILD): + # compiler prefixes might have foreign aclocal files which we do not want to include + if any(language in edge.virtuals for language in ("c", "cxx", "fortran")): + continue + dep = edge.spec path = dep.prefix.share.aclocal # Skip non-existing aclocal paths try: diff --git a/tests/build_systems.py b/tests/build_systems.py index 3d094af92e5..aa374aba8e6 100644 --- a/tests/build_systems.py +++ b/tests/build_systems.py @@ -448,6 +448,24 @@ def test_autoreconf_search_path_args_external_order( ] +def test_autoreconf_search_path_args_skip_compiler( + default_mock_concretization, tmp_path: pathlib.Path +): + """Compiler prefixes are not aclocal macro providers.""" + spec = default_mock_concretization("dttop") + compiler, macro_provider = spec.dependencies(deptype="build") + compiler_aclocal = tmp_path / "compiler" / "share" / "aclocal" + provider_aclocal = tmp_path / "provider" / "share" / "aclocal" + compiler_aclocal.mkdir(parents=True) + provider_aclocal.mkdir(parents=True) + compiler.external_path = str(tmp_path / "compiler") + macro_provider.set_prefix(str(tmp_path / "provider")) + compiler_edge = next(edge for edge in spec.edges_to_dependencies() if edge.spec is compiler) + compiler_edge.virtuals = ("c", "cxx") + + assert autotools._autoreconf_search_path_args(spec) == ["-I", str(provider_aclocal)] + + def test_autoreconf_search_path_skip_nonexisting( default_mock_concretization, tmp_path: pathlib.Path ):