for-mygcc.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/sh -x
  2. #
  3. # (or use sh -x to see what is going on)
  4. #
  5. # /*
  6. # *
  7. # * This program is free software: you can redistribute it and/or modify
  8. # * it under the terms of the GNU General Public License as published by
  9. # * the Free Software Foundation, either version 3 of the License, or
  10. # * (at your option) any later version.
  11. # *
  12. # * This program is distributed in the hope that it will be useful,
  13. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # * GNU General Public License for more details.
  16. # *
  17. # * You should have received a copy of the GNU General Public License
  18. # * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # *
  20. # * These are the four essential freedoms with GNU GPL software:
  21. # * 1: freedom to run the program, for any purpose
  22. # * 2: freedom to study how the program works, and change it to make it do what you wish
  23. # * 3: freedom to redistribute copies to help your Free Software girlfriends and friends
  24. # * 4: freedom to distribute copies of your modified versions to your Free Software girlfriends and friends
  25. # *
  26. # * , ,
  27. # * / \
  28. # * ((__-^^-,-^^-__))
  29. # * `-_---' `---_-'
  30. # * `--|o` 'o|--'
  31. # * \ ` /
  32. # * ): :(
  33. # * :o_o:
  34. # * "-"
  35. # *
  36. # * SPDX-License-Identifier: GPL-3.0+
  37. # * License-Filename: LICENSE
  38. # *
  39. # */
  40. #
  41. # this is c source checking using smatch c checker on sourceforge
  42. # this uses Linux kernel sparse compiler but with many extra checks
  43. #./configure --enable-gcc-warnings CC=$HOME/misc/src/smatch/smatch/cgcc
  44. #make CHECK="~/misc/src/smatch/smatch --full-path" CC=~/misc/src/smatch/smatch/cgcc
  45. #exit 0
  46. # gcc version 12 owm development version
  47. autoreconf -fvim
  48. ./configure --enable-gcc-warnings CC=$HOME/mygcc12/bin/gcc CFLAGS="-g -O0 -fanalyzer"
  49. make CC=$HOME/mygcc12/bin/gcc CFLAGS="-O0 -fanalyzer " 1>O1 2>O2
  50. grep warn O2 >O3
  51. exit 0
  52. # using gcc-10 on debian 11
  53. # using gcc-11.2 on fedora 34
  54. rm -v -f O1 O2 O3
  55. autoreconf -fvim
  56. CFLAGS="$CFLAGS -fanalyzer "
  57. ./configure --with-gtk=3 --enable-gcc-warnings CFLAGS=" -fanalyzer "
  58. make clean
  59. make CC=gcc CFLAGS="-O0 -fanalyzer " 1>O1 2>O2
  60. grep warn O2 >O3
  61. exit 0
  62. # GCC development snapshot in home directory called mygcc
  63. $HOME/mygcc/bin/gcc --version
  64. autoreconf -fvim
  65. # recommended way to do this and CC CFLAGS will not be added to shell environment
  66. # only newest software http://gcc.gnu.org
  67. # gcc-10.1 and gcc-11 has -fanalyzer option
  68. #./configure --enable-gcc-warnings CC=$HOME/mygcc/bin/gcc CFLAGS="-O0 -g -fcallgraph-info "
  69. #./configure --enable-gcc-warnings CC=$HOME/mygcc12/bin/gcc CFLAGS="-g -O0 -fdump-rtl-all-graph -fdump-tree-all-graph -fdump-ipa-all-graph"
  70. #./configure --enable-gcc-warnings CC=$HOME/mygcc12/bin/gcc CFLAGS="-g -O0 -fanalyzer -fdump-analyzer-callgraph -fdump-analyzer-exploded-graph"
  71. ./configure --enable-gcc-warnings CC=$HOME/mygcc12/bin/gcc CFLAGS=" -fanalyzer -fcallgraph-info "
  72. #./configure --enable-gcc-warnings CC=$HOME/mygcc/bin/gcc CFLAGS=" -fanalyzer "
  73. make clean
  74. #make
  75. #exit 0
  76. # set to 1/0
  77. doit="0"
  78. if test "$doit" -eq 1; then
  79. CC=$HOME/mygcc/bin/gcc
  80. CFLAGS=" -fanalyzer -Wall -Wextra -fdump-analyzer-callgraph"
  81. $CC $CFLAGS -c -I. -Isrc src/lex.yy.c 1>O1 2>O2
  82. grep warn O2 >O3
  83. exit 0
  84. fi
  85. #make CC=$HOME/mygcc/bin/gcc CFLAGS="-O0 -fcallgraph-info " 1>O1 2>O2
  86. #exit 0
  87. #make CC=$HOME/mygcc12/bin/gcc CFLAGS="-O0 -fanalyzer -fdump-analyzer-callgraph" 1>O1 2>O2
  88. #make CC=$HOME/mygcc12/bin/gcc CFLAGS="-O0 -fanalyzer -fcallgraph-info" 1>O1 2>O2
  89. make CC=$HOME/mygcc/bin/gcc CFLAGS="-O0 -fanalyzer " 1>O1 2>O2
  90. grep warn O2 >O3
  91. #./configure CC=$HOME/mygcc/bin/gcc
  92. # rtl data gcc/graph.c
  93. #./configure CC=$HOME/mygcc/bin/gcc CFLAGS="-Wall -pedantic -fdump-rtl-all-graph"
  94. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-rtl-all-graph src/rhp.c
  95. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-tree-all-graph src/rhp.c
  96. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-ipa-all-graph src/rhp.c
  97. # this generates vcg file with file extention .ci
  98. #$HOME/mygcc/bin/gcc -c -I. -I.. -fcallgraph-info src/rhp.c
  99. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info src/dp.c
  100. # da option is dynamic allocation
  101. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=da src/dp.c
  102. # su is stack usage
  103. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su src/dp.c
  104. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su,da src/dpif.c
  105. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su src/vcg.c
  106. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su,da src/vcgus.c
  107. # these should generate dot files
  108. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-callgraph src/rhp.c
  109. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-exploded-graph src/rhp.c
  110. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-supergraph src/rhp.c
  111. $HOME/mygcc/bin/gcc --version
  112. exit 0
  113. $HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fanalyzer -fdump-analyzer-supergraph src/dpif.c
  114. # -fdump-analyzer-state-purge
  115. # -fdump-analyzer-exploded-graph
  116. # -fdump-analyzer-callgraph
  117. # -fdump-analyzer-supergraph
  118. # -fdump-analyzer-exploded-graph -fdump-analyzer-state-purge -fdump-analyzer-supergraph src/dpif.c
  119. exit 0
  120. # tree data gcc/graph.c
  121. #./configure CC=$HOME/mygcc7/bin/gcc CFLAGS="-Wall -pedantic -fdump-tree-all-graph"
  122. # other gcc dot files do not have options and need gcc debug hacking
  123. #./configure CC=$HOME/mygcc7/bin/gcc CFLAGS="-Wall -pedantic -O2 -fdump-tree-all-graph -fdump-rtl-all-graph"
  124. #./configure CC=$HOME/mygcc/bin/gcc CFLAGS="-Wall -fdump-rtl-expand"
  125. #$HOME/mygcc/bin/gcc --version
  126. # optional support to use clang-3.5 using llvm lib
  127. #./configure CC="clang-3.5 -v"
  128. #clang-3.5 --version
  129. # to check source
  130. #clang --analyze file.c
  131. # optional support to use Linux sparse compiler but does not do c11 standard but can do c99
  132. #./configure CC="sparse"
  133. #sparse --version
  134. # easier: cd src; make CC=sparse
  135. ./configure --enable-gcc-warnings CC=$HOME/misc/src/smatch/smatch/cgcc
  136. make CHECK="~/misc/src/smatch/smatch --full-path" CC=~/misc/src/smatch/smatch/cgcc | tee warns.txt
  137. exit 0