Replace gen-libm-test.pl with gen-libm-test.py

System Internals / glibc - Joseph Myers [codesourcery.com] - 9 August 2018 15:34 EDT

Following the recent discussion of using Python instead of Perl and Awk for glibc build / test, this patch replaces gen-libm-test.pl with a new gen-libm-test.py script. This script should work with all Python versions supported by glibc (tested by hand with Python 2.7, tested in the build system with Python 3.5; configure prefers Python 3 if available).

This script is designed to give identical output to gen-libm-test.pl for ease of verification of the change, except for generated comments referring to .py instead of .pl. (That is, identical for actual inputs passed to the script, not necessarily for all possible input; for example, this version more precisely follows the C standard syntax for floating-point constants when deciding when to add LIT macro calls.) In one place a comment notes that the generation of NON_FINITE flags is replicating a bug in the Perl script to assist in such comparisons (with the expectation that this bug can then be separately fixed in the Python script later).

Tested for x86_64, including comparison of generated files (and hand testing of the case of generating a sorted libm-test-ulps file, which isn't covered by normal "make check").

I'd expect to follow this up by extending the new script to produce the ulps tables for the manual as well (replacing manual/libm-err-tab.pl, so that then we just have one ulps file parser) - at which point the manual build would depend on both Perl and Python (eliminating the Perl dependency would require someone to rewrite summary.pl in Python, and that would only eliminate the
*direct* Perl dependency; current makeinfo is written in Perl so there would still be an indirect dependency).

I think install.texi is more or less equally out-of-date regarding Perl and Python uses before and after this patch, so I don't think this patch depends on my patch to update install.texi regarding such uses (pending review).

- math/gen-libm-test.py: New file.
- math/gen-libm-test.pl: Remove.
- math/Makefile [$(PERL) != no]: Change condition to [PYTHON]. ($(objpfx)libm-test-ulps.h): Use gen-libm-test.py instead of gen-libm-test.pl. ($(libm-test-c-noauto-obj)): Likewise. ($(libm-test-c-auto-obj)): Likewise. ($(libm-test-c-narrow-obj)): Likewise. (regen-ulps): Likewise.
- math/README.libm-test: Update references to gen-libm-test.pl.
- math/libm-test-driver.c (struct test_fj_f_data): Update comment referencing gen-libm-test.pl.
- math/libm-test-nexttoward.inc (nexttoward_test_data): Likewise.
- math/libm-test-support.c: Likewise.
- math/libm-test-support.h: Likewise.
- sysdeps/generic/libm-test-ulps: Likewise.

2813e41e90 Replace gen-libm-test.pl with gen-libm-test.py.
ChangeLog | 19 +
math/Makefile | 26 +-
math/README.libm-test | 20 +-
math/gen-libm-test.pl | 846 -----------------------------------------
math/gen-libm-test.py | 603 +++++++++++++++++++++++++++++
math/libm-test-driver.c | 2 +-
math/libm-test-nexttoward.inc | 2 +-
math/libm-test-support.c | 2 +-
math/libm-test-support.h | 4 +-
sysdeps/generic/libm-test-ulps | 2 +-
10 files changed, 651 insertions(+), 875 deletions(-)

Upstream: sourceware.org


  • Share