Cray compiler: fix implicit rpaths for classic versions (#17310)
* check link dirs for existence
This commit is contained in:
parent
c12885768d
commit
212299a021
4 changed files with 40 additions and 13 deletions
|
@ -152,6 +152,10 @@ def _parse_non_system_link_dirs(string):
|
|||
"""
|
||||
link_dirs = _parse_link_paths(string)
|
||||
|
||||
# Remove directories that do not exist. Some versions of the Cray compiler
|
||||
# report nonexistent directories
|
||||
link_dirs = [d for d in link_dirs if os.path.isdir(d)]
|
||||
|
||||
# Return set of directories containing needed compiler libs, minus
|
||||
# system paths. Note that 'filter_system_paths' only checks for an
|
||||
# exact match, while 'in_system_subdirectory' checks if a path contains
|
||||
|
|
|
@ -159,7 +159,13 @@ def __init__(self):
|
|||
default_compiler_entry['paths']['f77']],
|
||||
environment={})
|
||||
|
||||
_get_compiler_link_paths = Compiler._get_compiler_link_paths
|
||||
def _get_compiler_link_paths(self, paths):
|
||||
# Mock os.path.isdir so the link paths don't have to exist
|
||||
old_isdir = os.path.isdir
|
||||
os.path.isdir = lambda x: True
|
||||
ret = super(MockCompiler, self)._get_compiler_link_paths(paths)
|
||||
os.path.isdir = old_isdir
|
||||
return ret
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -222,6 +228,7 @@ def call_compiler(exe, *args, **kwargs):
|
|||
('f77', 'fflags'),
|
||||
('f77', 'cppflags'),
|
||||
])
|
||||
@pytest.mark.enable_compiler_link_paths
|
||||
def test_get_compiler_link_paths(monkeypatch, exe, flagname):
|
||||
# create fake compiler that emits mock verbose output
|
||||
compiler = MockCompiler()
|
||||
|
@ -261,6 +268,7 @@ def test_get_compiler_link_paths_no_verbose_flag():
|
|||
assert dirs == []
|
||||
|
||||
|
||||
@pytest.mark.enable_compiler_link_paths
|
||||
def test_get_compiler_link_paths_load_env(working_env, monkeypatch, tmpdir):
|
||||
gcc = str(tmpdir.join('gcc'))
|
||||
with open(gcc, 'w') as f:
|
||||
|
|
|
@ -619,12 +619,20 @@ def dirs_with_libfiles(tmpdir_factory):
|
|||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def disable_compiler_execution(monkeypatch):
|
||||
def disable_compiler_execution(monkeypatch, request):
|
||||
"""
|
||||
This fixture can be disabled for tests of the compiler link path
|
||||
functionality by::
|
||||
|
||||
@pytest.mark.enable_compiler_link_paths
|
||||
|
||||
If a test is marked in that way this is a no-op."""
|
||||
if 'enable_compiler_link_paths' not in request.keywords:
|
||||
def noop(*args):
|
||||
return []
|
||||
|
||||
# Compiler.determine_implicit_rpaths actually runs the compiler. So this
|
||||
# replaces that function with a noop that simulates finding no implicit
|
||||
# Compiler.determine_implicit_rpaths actually runs the compiler. So
|
||||
# replace that function with a noop that simulates finding no implicit
|
||||
# RPATHs
|
||||
monkeypatch.setattr(
|
||||
spack.compiler.Compiler,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
import spack.paths
|
||||
|
@ -13,6 +13,13 @@
|
|||
'compiler_verbose_output')
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def allow_nonexistent_paths(monkeypatch):
|
||||
# Allow nonexistent paths to be detected as part of the output
|
||||
# for testing purposes.
|
||||
monkeypatch.setattr(os.path, 'isdir', lambda x: True)
|
||||
|
||||
|
||||
def check_link_paths(filename, paths):
|
||||
with open(os.path.join(datadir, filename)) as file:
|
||||
output = file.read()
|
||||
|
|
Loading…
Reference in a new issue