Skip to content

Commit b20eb73

Browse files
authored
Use CMAKE_OBJDUMP when importing profiles in test-suite (#37)
When collecting profiles with `lnt runtest test-suite --use-perf=profile`, it needs a path to objdump to extract the symbols and disassembly. Normally it will try to use `CMAKE_OBJDUMP` from the environment, but AFIAK `lnt` is normally invoked from the command line so no CMake variables are set, so it falls back to just plain old `objdump`. When running LNT in a cross compilation scenario this leads to a different `objdump` than what CMake uses, which may not support the target (or just straight up not exist). So the profile imports will silently fail to include any code from the binary. This fixes it by plumbing through the `CMAKE_OBJDUMP` from the actual llvm-test-suite build. I've left behind the old `os.getenv` as a fallback since `Profile.fromFile` is called from a bunch of other places including `lnt runtest profile`. With this patch, using LNT to cross-compile and profile the tests on a remote machine should hopefully "just work"
1 parent 11b8842 commit b20eb73

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lnt/testing/profile/profile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ def __init__(self, impl):
2121
self.impl = impl
2222

2323
@staticmethod
24-
def fromFile(f):
24+
def fromFile(f, objdump=None):
2525
"""
2626
Load a profile from a file.
2727
"""
28+
if objdump is None:
29+
objdump = os.getenv("CMAKE_OBJDUMP", "objdump")
2830
for impl in lnt.testing.profile.IMPLEMENTATIONS.values():
2931
if impl.checkFile(f):
3032
ret = None
3133
with open(f, 'rb') as fd:
3234
if impl is lnt.testing.profile.perf.LinuxPerfProfile:
3335
ret = impl.deserialize(
3436
fd,
35-
objdump=os.getenv('CMAKE_OBJDUMP', 'objdump'),
37+
objdump,
3638
binaryCacheRoot=os.getenv('LNT_BINARY_CACHE_ROOT', ''))
3739
else:
3840
ret = impl.deserialize(fd)

lnt/tests/test_suite.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import datetime
1717
from collections import defaultdict
18+
from functools import partial
1819
import jinja2
1920
import click
2021

@@ -94,7 +95,7 @@
9495
"""
9596

9697

97-
def _importProfile(name_filename):
98+
def _importProfile(objdump, name_filename):
9899
"""_importProfile imports a single profile. It must be at the top level
99100
(and not within TestSuiteTest) so that multiprocessing can import it
100101
correctly."""
@@ -104,7 +105,7 @@ def _importProfile(name_filename):
104105
logger.warning('Profile %s does not exist' % filename)
105106
return None
106107

107-
pf = lnt.testing.profile.profile.Profile.fromFile(filename)
108+
pf = lnt.testing.profile.profile.Profile.fromFile(filename, objdump)
108109
if not pf:
109110
return None
110111

@@ -692,7 +693,8 @@ def _extract_cmake_vars_from_cache(self):
692693
"CMAKE_C_FLAGS_RELEASE",
693694
"CMAKE_C_FLAGS_RELWITHDEBINFO",
694695
"CMAKE_C_COMPILER_TARGET",
695-
"CMAKE_CXX_COMPILER_TARGET")]
696+
"CMAKE_CXX_COMPILER_TARGET",
697+
"CMAKE_OBJDUMP")]
696698
cmake_vars = {}
697699
for line in cmake_lah_output.split("\n"):
698700
for pattern, varname in pattern2var:
@@ -828,7 +830,8 @@ def _parse_lit_output(self, path, data, cmake_vars, only_test=False):
828830
TIMEOUT = 800
829831
try:
830832
pool = multiprocessing.Pool()
831-
waiter = pool.map_async(_importProfile, profiles_to_import)
833+
func = partial(_importProfile, cmake_vars["CMAKE_OBJDUMP"])
834+
waiter = pool.map_async(func, profiles_to_import)
832835
samples = waiter.get(TIMEOUT)
833836
test_samples.extend([sample
834837
for sample in samples

0 commit comments

Comments
 (0)