diff options
author | Alex Langford <alangford@apple.com> | 2024-03-07 15:04:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 18:04:42 -0500 |
commit | d93a126090b6e772d3b96f201cdd44ea0d6360ef (patch) | |
tree | 4bc54ce1aa7e3a22cad8b079f984a90572cc035c | |
parent | 909ab0e0d1903ad2329ca9fdf248d21330f9437f (diff) | |
download | llvm-d93a126090b6e772d3b96f201cdd44ea0d6360ef.zip llvm-d93a126090b6e772d3b96f201cdd44ea0d6360ef.tar.gz llvm-d93a126090b6e772d3b96f201cdd44ea0d6360ef.tar.bz2 |
[lldb] Add ability to detect darwin host linker version to xfail tests (#83941)
When Apple released its new linker, it had a subtle bug that caused
LLDB's TLS tests to fail. Unfortunately this means that TLS tests are
not going to work on machines that have affected versions of the linker,
so we should annotate the tests so that they only work when we are
confident the linker has the required fix.
I'm not completely satisfied with this implementation. That being said,
I believe that adding suport for linker versions in general is a
non-trivial change that would require far more thought. There are a few
challenges involved:
- LLDB's testing infra takes an argument to change the compiler, but
there's no way to switch out the linker.
- There's no standard way to ask a compiler what linker it will use.
- There's no standard way to ask a linker what its version is. Many
platforms have the same name for their linker (ld).
- Some platforms automatically switch out the linker underneath you. We
do this for Windows tests (where we use LLD no matter what).
Given that this is affecting the tests on our CI, I think this is an
acceptable solution in the interim.
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbplatformutil.py | 27 | ||||
-rw-r--r-- | lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index c4d063d..187d16a 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -3,6 +3,7 @@ architecture and/or the platform dependent nature of the tests. """ # System modules import itertools +import json import re import subprocess import sys @@ -16,6 +17,7 @@ from . import configuration from . import lldbtest_config import lldbsuite.test.lldbplatform as lldbplatform from lldbsuite.test.builders import get_builder +from lldbsuite.test.lldbutil import is_exe def check_first_register_readable(test_case): @@ -333,3 +335,28 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def xcode15LinkerBug(): + """Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" + darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) + if getPlatform() not in darwin_platforms: + return False + + try: + raw_version_details = subprocess.check_output( + ("xcrun", "ld", "-version_details") + ) + version_details = json.loads(raw_version_details) + version = version_details.get("version", "0") + version_tuple = tuple(int(x) for x in version.split(".")) + if (1000,) <= version_tuple <= (1109,): + return True + except: + pass + + return False diff --git a/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py b/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py index dfe29b4..2bffd2e 100644 --- a/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py +++ b/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py @@ -40,6 +40,7 @@ class TlsGlobalTestCase(TestBase): @skipIfWindows @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) @skipIf(oslist=no_match([lldbplatformutil.getDarwinOSTriples(), "linux"])) + @expectedFailureIf(lldbplatformutil.xcode15LinkerBug()) def test(self): """Test thread-local storage.""" self.build() |