Skip to content

Commit

Permalink
[ci] add docs and specific error messages in check_dynamic_dependenci…
Browse files Browse the repository at this point in the history
…es.py (#5582)
  • Loading branch information
jameslamb authored Nov 29, 2022
1 parent 24af9fa commit ed1771c
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions helpers/check_dynamic_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
"""Helper script for checking versions in the dynamic symbol table.
This script checks that LightGBM library is linked to the appropriate symbol versions.
Linking to newer symbol versions at compile time is problematic because it could result
in built artifacts being unusable on older platforms.
Version history for these symbols can be found at the following:
* GLIBC: https://sourceware.org/glibc/wiki/Glibc%20Timeline
* GLIBCXX: https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
* OMP/GOMP: https://github.com/gcc-mirror/gcc/blob/master/libgomp/libgomp.map
"""
import re
import sys
from pathlib import Path


def check_dependicies(objdump_string: str) -> None:
def check_dependencies(objdump_string: str) -> None:
"""Check the dynamic symbol versions.
Parameters
Expand All @@ -20,24 +29,27 @@ def check_dependicies(objdump_string: str) -> None:
versions = GLIBC_version.findall(objdump_string)
assert len(versions) > 1
for major, minor in versions:
assert int(major) <= 2
assert int(minor) <= 28
error_msg = f"found unexpected GLIBC version: '{major}.{minor}'"
assert int(major) <= 2, error_msg
assert int(minor) <= 28, error_msg

GLIBCXX_version = re.compile(r'0{16}[ \t]+GLIBCXX_(\d{1,2})[.](\d{1,2})[.]?(\d{,3})[ \t]+')
versions = GLIBCXX_version.findall(objdump_string)
assert len(versions) > 1
for major, minor, patch in versions:
assert int(major) == 3
assert int(minor) == 4
assert patch == '' or int(patch) <= 22
error_msg = f"found unexpected GLIBCXX version: '{major}.{minor}.{patch}'"
assert int(major) == 3, error_msg
assert int(minor) == 4, error_msg
assert patch == '' or int(patch) <= 22, error_msg

GOMP_version = re.compile(r'0{16}[ \t]+G?OMP_(\d{1,2})[.](\d{1,2})[.]?\d{,3}[ \t]+')
versions = GOMP_version.findall(objdump_string)
assert len(versions) > 1
for major, minor in versions:
assert int(major) <= 4
assert int(minor) <= 5
error_msg = f"found unexpected OMP/GOMP version: '{major}.{minor}'"
assert int(major) <= 4, error_msg
assert int(minor) <= 5, error_msg


if __name__ == "__main__":
check_dependicies(Path(sys.argv[1]).read_text(encoding='utf-8'))
check_dependencies(Path(sys.argv[1]).read_text(encoding='utf-8'))

0 comments on commit ed1771c

Please sign in to comment.