Skip to content

Commit

Permalink
[ci] check dynamic symbol versions at CI side (#1812)
Browse files Browse the repository at this point in the history
* renamed helper folder to helpers

* added library dependencies check
  • Loading branch information
StrikerRUS authored and guolinke committed Nov 1, 2018
1 parent 4570fc9 commit dfe0fae
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .ci/test.sh
Expand Up @@ -39,7 +39,7 @@ if [[ $TRAVIS == "true" ]] && [[ $TASK == "check-docs" ]]; then
# check the consistency of parameters' descriptions and other stuff
cp $BUILD_DIRECTORY/docs/Parameters.rst $BUILD_DIRECTORY/docs/Parameters-backup.rst
cp $BUILD_DIRECTORY/src/io/config_auto.cpp $BUILD_DIRECTORY/src/io/config_auto-backup.cpp
python $BUILD_DIRECTORY/helper/parameter_generator.py || exit -1
python $BUILD_DIRECTORY/helpers/parameter_generator.py || exit -1
diff $BUILD_DIRECTORY/docs/Parameters-backup.rst $BUILD_DIRECTORY/docs/Parameters.rst || exit -1
diff $BUILD_DIRECTORY/src/io/config_auto-backup.cpp $BUILD_DIRECTORY/src/io/config_auto.cpp || exit -1
exit 0
Expand Down Expand Up @@ -131,6 +131,10 @@ if [[ $TASK == "regular" ]]; then
if [[ $OS_NAME == "macos" ]]; then
cp $BUILD_DIRECTORY/lib_lightgbm.so $BUILD_ARTIFACTSTAGINGDIRECTORY/lib_lightgbm.dylib
else
if [[ $COMPILER == "gcc" ]]; then
objdump -T $BUILD_DIRECTORY/lib_lightgbm.so > $BUILD_DIRECTORY/objdump.log || exit -1
python $BUILD_DIRECTORY/helpers/check_dynamic_dependencies.py $BUILD_DIRECTORY/objdump.log || exit -1
fi
cp $BUILD_DIRECTORY/lib_lightgbm.so $BUILD_ARTIFACTSTAGINGDIRECTORY/lib_lightgbm.so
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion docs/Parameters.rst
@@ -1,4 +1,4 @@
.. List of parameters is auto generated by LightGBM\helper\parameter_generator.py from LightGBM\include\LightGBM\config.h file.
.. List of parameters is auto generated by LightGBM\helpers\parameter_generator.py from LightGBM\include\LightGBM\config.h file.
.. role:: raw-html(raw)
:format: html
Expand Down
2 changes: 1 addition & 1 deletion docs/README.rst
Expand Up @@ -5,7 +5,7 @@ Documentation for LightGBM is generated using `Sphinx <http://www.sphinx-doc.org

List of parameters and their descriptions in `Parameters.rst <./Parameters.rst>`__
is generated automatically from comments in `config file <https://github.com/Microsoft/LightGBM/blob/master/include/LightGBM/config.h>`__
by `this script <https://github.com/Microsoft/LightGBM/blob/master/helper/parameter_generator.py>`__.
by `this script <https://github.com/Microsoft/LightGBM/blob/master/helpers/parameter_generator.py>`__.

After each commit on ``master``, documentation is updated and published to `Read the Docs <https://lightgbm.readthedocs.io/>`__.

Expand Down
43 changes: 43 additions & 0 deletions helpers/check_dynamic_dependencies.py
@@ -0,0 +1,43 @@
# 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


def check_dependicies(objdump_string):
"""Check the dynamic symbol versions.
Parameters
----------
objdump_string : string
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
assert int(minor) <= 14

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) <= 19

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) == 1
assert int(minor) == 0


if __name__ == "__main__":
with open(sys.argv[1], 'r') as f:
check_dependicies(f.read())
Expand Up @@ -260,7 +260,7 @@ def gen_parameter_code(config_hpp, config_out_cpp):
keys, infos = get_parameter_infos(config_hpp)
names = get_names(infos)
alias = get_alias(infos)
str_to_write = "/// This file is auto generated by LightGBM\\helper\\parameter_generator.py from LightGBM\\include\\LightGBM\\config.h file.\n"
str_to_write = "/// This file is auto generated by LightGBM\\helpers\\parameter_generator.py from LightGBM\\include\\LightGBM\\config.h file.\n"
str_to_write += "#include<LightGBM/config.h>\nnamespace LightGBM {\n"
# alias table
str_to_write += "std::unordered_map<std::string, std::string> Config::alias_table({\n"
Expand Down
2 changes: 1 addition & 1 deletion src/io/config_auto.cpp
@@ -1,4 +1,4 @@
/// This file is auto generated by LightGBM\helper\parameter_generator.py from LightGBM\include\LightGBM\config.h file.
/// This file is auto generated by LightGBM\helpers\parameter_generator.py from LightGBM\include\LightGBM\config.h file.
#include<LightGBM/config.h>
namespace LightGBM {
std::unordered_map<std::string, std::string> Config::alias_table({
Expand Down

0 comments on commit dfe0fae

Please sign in to comment.