warnings-transitions.pl

ABSTRACT

Identify Perl 5 commit at which a given build-time warning first appeared

SYNOPSIS

perl warnings-transitions.pl \
    --git_checkout_dir="$GIT_WORKDIR/perl2" \
    --workdir="$HOMEDIR/learn/perl/multisect/testing/gcc" \
    --first=d7fb2be259ba2ec08e8fa0e88ad0ee860d59dab9 \
    --last=043ae7481cd3d05b453e0830b34573b7eef2aade \
    --pattern_sought="Opcode.xs:_:_: warning: overflow in implicit constant conversion [Woverflow]"

DESCRIPTION

This program uses methods from Devel::Git::MultiBisect::BuildTransitions to identify the commit in Perl 5 blead where a specified build-time warning first appeared.

USAGE

Call this program with command-line switches. At the present time there are 4 command-line switches whose values the user must provide, as there are no defaults. There is 1 command-line switch which is recommended and for which a value must be provided. There are currently 4 other command-line switches for which defaults are provided. All switches are called in "long option" style, i.e. starting with two hyphens (--).

Required Command-Line Switches

  • --git_checkout_dir

    Full path to a directory holding a git checkout of the Perl 5 core distribution.

  • --workdir

    Full path to a directory where files created in the course of running the program will be deposited.

  • --first

    Full (40 character) SHA of the first (chronologically earliest) git commit to the Perl 5 repository to be tested during bisection.

  • --last

    Full (40 character) SHA of the last (chronologically latest) git commit to the Perl 5 repository to be tested during bisection.

  • --pattern_sought

    String holding the build-time (make) warning whose first appearance you are trying to ascertain, subject to these modifications:

  • Substitute one underscore character (_) for the line number (vertical) and character number (horizontal).

  • Remove the hyphen (-) between the open bracket (\[) and the upper-case 'W' (W) in the warnings category.

Hence, a warning which appears in captured make output like this:

Opcode.xs: In function ‘XS_Opcode_invert_opset’:
Opcode.xs:363:25: warning: overflow in implicit constant conversion [-Woverflow]
  bitmap[opset_len-1] &= ~(0xFF << (PL_maxo & 0x07));
                         ^

... will be called on the command-line like this:

--pattern_sought="Opcode.xs:_:_: warning: overflow in implicit constant conversion [Woverflow]"

If this switch is called, a value must be provided. But if the switch is not called, the program will simply avoid running the code which uses the value.

Note: If the pattern contains any single-quote mark (') or similar characters, you are probably better off double-quoting the pattern on the command line (as above).

Optional Command-Line Switches

  • compiler

    Compiler (and possibly compiler version) which is generating the warning. The warning pattern is currently observed in various versions of gcc, g++ and clang. Defaults to gcc. Note that if your default version of gcc is 7 but you wish to track a warning generated by a different version of gcc, you would call something like gcc-8 (on Linux) or gcc8 on FreeBSD.

    --compiler='gcc-8'

    Needless to say, you must have these alternate compiler versions installed.

  • branch

    Branch of the Perl 5 core distribution you are testing for the warning. Defaults to blead.

    --branch=blead
  • configure_command

    String holding the invocation of ./Configure used in builds where the warning's first appearance is being explored. Defaults to:

    --configure_command='sh ./Configure -des -Dusedevel -Dcc=gcc 1>/dev/null 2>&1'
  • make_command

    String holding the invocation of make used in the builds under investigation. Defaults to:

    --make_command='make -j${TEST_JOBS} 1>/dev/null'

PREREQUISITES

Once you have installed the Devel-Git-MultiBisect distribution from CPAN, the only non-core distribution you need is Data-Dump.

OUTPUTS

Like all programs using Devel::Git::MultiBisect::BuildTransistions, the program prints a log to STDOUT of each commit tested. In the course of testing a given commit, a file is created in the workdir directory which logs the build-time warnings observed. Example:

$ 02b85d3.make.warnings.rpt.txt
Opcode.xs:_:_: warning: overflow in implicit constant conversion [Woverflow]

When all older-to-newer transitions have been identified, the program creates one additional file in the workdir directory. This file is named using the compiler used, e.g., transistions.gcc.pl and looks like this:

$ cat transitions.gcc.pl
{
  newest => {
    file => "/home/username/testing/gcc/043ae74.make.warnings.rpt.txt",
    idx => 7,
    md5_hex => "157705edf5caf23f889135270fe56ef7",
  },
  oldest => {
    file => "/home/username/testing/gcc/d7fb2be.make.warnings.rpt.txt",
    idx => 0,
    md5_hex => "19ae20b703848111b41f08bdbc0b2eb7",
  },
  transitions => [
    {
      newer => {
                 file => "/home/username/testing/gcc/aa4119b.make.warnings.rpt.txt",
                 idx => 1,
                 md5_hex => "d41d8cd98f00b204e9800998ecf8427e",
               },
      older => {
                 file => "/home/username/testing/gcc/d7fb2be.make.warnings.rpt.txt",
                 idx => 0,
                 md5_hex => "19ae20b703848111b41f08bdbc0b2eb7",
               },
    },
    {
      newer => {
                 file => "/home/username/testing/gcc/02b85d3.make.warnings.rpt.txt",
                 idx => 2,
                 md5_hex => "157705edf5caf23f889135270fe56ef7",
               },
      older => {
                 file => "/home/username/testing/gcc/aa4119b.make.warnings.rpt.txt",
                 idx => 1,
                 md5_hex => "d41d8cd98f00b204e9800998ecf8427e",
               },
    },
  ],
}

The elements in the transitions array above are the points where the build-time warnings changed. The user should then manually inspect those elements to determine where the warning under investigation first appeared. In addition, if a value is provided for --pattern_sought, then the SHA of the commit is printed to STDOUT. However, this functionality should be considered experimental and YMMV. See the discussion of that command-line switch above.

AUTHOR

Copyright 2020 James E Keenan (JKEENAN). Last revised March 31 2020. License: same terms as Devel::Git::MultiBisect.