Skip to content

Commit b311f6c

Browse files
bulbazordkastiglione
authored andcommitted
[lldb] Add ability to detect darwin host linker version to xfail tests (llvm#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. (cherry picked from commit d93a126)
1 parent e84c3ea commit b311f6c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lldb/packages/Python/lldbsuite/test/lldbplatformutil.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# System modules
77
import itertools
8+
import json
89
import re
910
import subprocess
1011
import sys
@@ -18,6 +19,7 @@
1819
from . import lldbtest_config
1920
import lldbsuite.test.lldbplatform as lldbplatform
2021
from lldbsuite.test.builders import get_builder
22+
from lldbsuite.test.lldbutil import is_exe
2123

2224

2325
def check_first_register_readable(test_case):
@@ -332,4 +334,26 @@ def expectedCompiler(compilers):
332334
if compiler in getCompiler():
333335
return True
334336

337+
# This is a helper function to determine if a specific version of Xcode's linker
338+
# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
339+
# adding a linker/linker_version conditions to a decorator is challenging due to
340+
# the number of ways linkers can enter the build process.
341+
def xcode15LinkerBug(_self=None):
342+
"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109."""
343+
darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
344+
if getPlatform() not in darwin_platforms:
345+
return False
346+
347+
try:
348+
raw_version_details = subprocess.check_output(
349+
("xcrun", "ld", "-version_details")
350+
)
351+
version_details = json.loads(raw_version_details)
352+
version = version_details.get("version", "0")
353+
version_tuple = tuple(int(x) for x in version.split("."))
354+
if (1000,) <= version_tuple <= (1109,):
355+
return True
356+
except:
357+
pass
358+
335359
return False

lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def setUp(self):
4242
bugnumber="llvm.org/pr28392",
4343
oslist=no_match(lldbplatformutil.getDarwinOSTriples()),
4444
)
45-
@expectedFailureDarwin("rdar://120676969")
45+
@expectedFailureIfFn(lldbplatformutil.xcode15LinkerBug)
4646
def test(self):
4747
"""Test thread-local storage."""
4848
self.build()

0 commit comments

Comments
 (0)