check_dynamic_dependencies.py 1.4 KB
Newer Older
1
2
3
4
5
6
7
# coding: utf-8
"""Helper script for checking versions in the dynamic symbol table.

This script checks that LightGBM library is linked to the appropriate symbol versions.
"""
import re
import sys
8
from pathlib import Path
9
10


11
def check_dependicies(objdump_string: str) -> None:
12
13
14
15
    """Check the dynamic symbol versions.

    Parameters
    ----------
16
    objdump_string : str
17
18
19
20
21
22
23
        The dynamic symbol table entries of the file (result of `objdump -T` command).
    """
    GLIBC_version = re.compile(r'0{16}[ \t]+GLIBC_(\d{1,2})[.](\d{1,3})[.]?\d{,3}[ \t]+')
    versions = GLIBC_version.findall(objdump_string)
    assert len(versions) > 1
    for major, minor in versions:
        assert int(major) <= 2
24
        assert int(minor) <= 28
25
26
27
28
29
30
31

    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
32
        assert patch == '' or int(patch) <= 22
33
34
35
36
37

    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:
38
39
        assert int(major) <= 4
        assert int(minor) <= 5
40
41
42


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