Skip to content

Commit

Permalink
Fix version string handling in compilers.py to work with monorepo builds
Browse files Browse the repository at this point in the history
We should never have a case where we have separate LLVM + clang commit hashes
at this point.

Remove the code from compilers.py that supports separate revisions. It is no
longer correct to have this code, and it can prevent LNT from picking up the
monorepo revision.

Update testcases to reflect this.
  • Loading branch information
Jessica Paquette committed Jan 22, 2020
1 parent 10f1592 commit 7aaef2a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 48 deletions.
19 changes: 0 additions & 19 deletions lnt/testing/util/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,6 @@ def get_cc_info(path, cc_flags=[]):
cc_build = 'DEV'
else:
cc_build = 'DEV'

# Newer Clang's can report separate versions for LLVM and Clang. Parse
# the cc_extra text so we can get the maximum SVN version.
if cc_extra.startswith('(') and cc_extra.endswith(')'):
m = re.match(r'\((.+) ([^ ]+)\)', cc_extra)
if m:
cc_alt_src_branch, cc_alt_src_revision = m.groups()

# With a CMake build, the branch is not emitted.
if cc_src_branch and not cc_src_revision and \
cc_src_branch.isdigit():
cc_alt_src_revision = cc_alt_src_branch
cc_alt_src_branch = ""

else:
logger.error('unable to determine '
'Clang development build info: %r' %
((cc_name, cc_build_string, cc_extra), ))

elif cc_name == 'gcc' and 'LLVM build' in cc_extra:
llvm_capable = True
cc_norm_name = 'llvm-gcc'
Expand Down
1 change: 1 addition & 0 deletions tests/SharedInputs/FakeCompilers/clang-monorepo
1 change: 1 addition & 0 deletions tests/SharedInputs/FakeCompilers/clang-monorepo2
29 changes: 11 additions & 18 deletions tests/SharedInputs/FakeCompilers/fakecompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,12 @@ def print_verbose_info(self):
g_program,), file=sys.stderr)


# Clang build from a git repository.
class Clang_git(LLVMCompiler):
compiler_name = "clang-git"

# Monorepo clang build
class Clang_monorepo(LLVMCompiler):
compiler_name = "clang-monorepo"
def print_verbose_info(self):
print("""\
clang version 3.1\
(git:/git/clang.git 37ce0feee598d82e7220fa0a4b110619cae6ea72)\
(git:/git/llvm.git 60fca4f64e697ad834ce7ee8c2e478cae394c7dc)
clang version 1.2.3 (ssh://something.com/llvm-project.git 597522d740374f093a089a2acbec5b20466b2f34)
Target: arm-apple-darwin11.4.0
Thread model: posix
InstalledDir: /home/foo/bin
Expand All @@ -121,23 +118,19 @@ def print_verbose_info(self):
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
g_program,), file=sys.stderr)


# Clang build from a git repository.
class Clang_git_2(LLVMCompiler):
compiler_name = "clang-git-2"

# Monorepo clang build with some extra stuff after the version string
class Clang_monorepo2(LLVMCompiler):
compiler_name = "clang-monorepo2"
def print_verbose_info(self):
print("""\
clang version 3.2\
(/d/g/pz/clang.git git:/git/pz/clang.git 8ab09316f63ea99ff23b2684c454b1008b8d5f10)\
(http://llvm.org/git/llvm.git /d/g/pz/llvm.git git:/git/pb/llvm.git 7c53f795961cc2d35b85d315aadb2ac135a0fdb2)
Target: x86_64-apple-darwin12.2.0
Thread model: posix""", file=sys.stderr)
clang version 1.2.3 (ssh://something.com/llvm-project.git 597522d740374f093a089a2acbec5b20466b2f34) (extra) (stuff) (here)
Thread model: posix
InstalledDir: /home/foo/bin
""", file=sys.stderr)
print("""\
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
g_program,), file=sys.stderr)


class AppleClang_138_1(LLVMCompiler):
compiler_name = "apple-clang-138.1"

Expand Down
24 changes: 13 additions & 11 deletions tests/testing/Compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@ def get_info(name):
assert info['cc_build'] == 'PROD'
assert info['inferred_run_order'] == '138.1'

# Check a Clang built from git repositories.
info = get_info("clang-git")
# Check a monorepo Clang.
info = get_info("clang-monorepo")
pprint.pprint(info)
assert info['cc_name'] == 'clang'
assert info['cc_build'] == 'DEV'
assert info['inferred_run_order'] == '%s,%s' % (
'37ce0feee598d82e7220fa0a4b110619cae6ea72',
'60fca4f64e697ad834ce7ee8c2e478cae394c7dc')
assert info['cc_src_branch'] == 'ssh://something.com/llvm-project.git'
assert info['cc_src_revision'] == '597522d740374f093a089a2acbec5b20466b2f34'
assert info['inferred_run_order'] == info['cc_src_revision']
assert info['cc_version_number'] == '1.2.3'

info = get_info("clang-git-2")
# Same as clang-monorepo, except the version string has some extra parens at
# the end. Verify that we can still match this.
info = get_info("clang-monorepo2")
pprint.pprint(info)
assert info['cc_name'] == 'clang'
assert info['cc_build'] == 'DEV'
assert info['inferred_run_order'] == '%s,%s' % (
'8ab09316f63ea99ff23b2684c454b1008b8d5f10',
'7c53f795961cc2d35b85d315aadb2ac135a0fdb2')
assert info['cc_src_branch'] == 'ssh://something.com/llvm-project.git'
assert info['cc_src_revision'] == '597522d740374f093a089a2acbec5b20466b2f34'
assert info['inferred_run_order'] == info['cc_src_revision']
assert info['cc_version_number'] == '1.2.3'

# Check a Clang that prints no info.
info = get_info("clang-no-info")
Expand Down

0 comments on commit 7aaef2a

Please sign in to comment.