User:Ris/sandbox/tmptst

From Gentoo Wiki
Jump to:navigation Jump to:search

[bonus] minimize self-contained source using cvise

Now to the fun part! Let's shrink .i down to a manageable size with help of dev-util/cvise.

  1. root #emerge --ask dev-util/cvise
  2. Write a test.sh tester:
    FILE test.sh
    LANG=C gcc-7.3.0 -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -march=prescott -mfpmath=sse -O2 -pipe -fomit-frame-pointer -fwrapv -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I./Include -I. -I/var/tmp/portage/dev-lang/python-3.6.5/work/Python-3.6.5/Include -I/var/tmp/portage/dev-lang/python-3.6.5/work/Python-3.6.5 -c cmathmodule.i -o cmathmodule.o \
    >gcc_out.txt 2>&1
    grep "internal compiler error" gcc_out.txt >/dev/null 2>&1
    
  3. Validate tester
    user $./test.sh
    user $echo $?
    0
  4. Reduce!
    user $cvise test.sh cmathmodule.i
    ===< 2430 >===

running 4 interestingness tests in parallel ===< pass_includes :: 0 >=== ===< pass_unifdef :: 0 >=== ===< pass_comments :: 0 >=== ===< pass_blank :: 0 >=== (1.2 %, 733906 bytes) (27.4 %, 539234 bytes) ===< pass_clang_binsrch :: replace-function-def-with-decl >=== (29.5 %, 523834 bytes) (30.2 %, 518466 bytes) (32.0 %, 505350 bytes) ... ******** cmathmodule.i ******** typedef struct { double a } b; b c; d, e, f; g() { _setjmp(); b h; if (e) h.a = copysign(f, d); c = h; }

Done!

cmathmodule.i contains the same shrunk example.

You can also pass the tester command directly to cvise without creating a shell script, e.g.:

user $LANG=C cvise --commands "gcc-7.3.0 -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -march=prescott -mfpmath=sse -O2 -pipe -fomit-frame-pointer -fwrapv -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I./Include -I. -I/var/tmp/portage/dev-lang/python-3.6.5/work/Python-3.6.5/Include -I/var/tmp/portage/dev-lang/python-3.6.5/work/Python-3.6.5 -c cmathmodule.i -o cmathmodule.o |& fgrep \"internal compiler error\"" cmathmodule.i