for-mygcc.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash -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 development snapshot in home directory called mygcc
  47. $HOME/mygcc/bin/gcc --version
  48. # recommended way to do this and CC CFLAGS will not be added to shell environment
  49. # only newest software http://gcc.gnu.org
  50. # gcc-10.1 and gcc-11 has -fanalyzer option
  51. #./configure --enable-gcc-warnings CC=$HOME/mygcc/bin/gcc CFLAGS="-O0 -g"
  52. ./configure CC=$HOME/mygcc/bin/gcc
  53. # CFLAGS=-fanalyzer -fdump-analyzer-callgraph -fdump-analyzer-exploded-graph -fdump-analyzer-supergraph -fdump-analyzer-state-purge -fcallgraph-info=da -fdump-rtl-expand -fdump-tree-expand "
  54. # CFLAGS="-fanalyzer -fdump-analyzer-callgraph -fdump-analyzer-exploded-graph -fdump-analyzer-supergraph -fdump-analyzer-state-purge -fcallgraph-info=da -fdump-rtl-expand -fdump-tree-expand "
  55. #-fanalyzer"
  56. #make CC=$HOME/mygcc/bin/gcc
  57. #./configure CC=$HOME/mygcc/bin/gcc
  58. # rtl data gcc/graph.c
  59. #./configure CC=$HOME/mygcc/bin/gcc CFLAGS="-Wall -pedantic -fdump-rtl-all-graph"
  60. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-rtl-all-graph src/rhp.c
  61. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-tree-all-graph src/rhp.c
  62. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-ipa-all-graph src/rhp.c
  63. # this generates vcg file with file extention .ci
  64. #$HOME/mygcc/bin/gcc -c -I. -I.. -fcallgraph-info src/rhp.c
  65. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info src/dp.c
  66. # da option is dynamic allocation
  67. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=da src/dp.c
  68. # su is stack usage
  69. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su src/dp.c
  70. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su,da src/dpif.c
  71. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su src/vcg.c
  72. #$HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fcallgraph-info=su,da src/vcgus.c
  73. # these should generate dot files
  74. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-callgraph src/rhp.c
  75. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-exploded-graph src/rhp.c
  76. #$HOME/mygcc/bin/gcc -c -I. -I.. -fdump-analyzer-supergraph src/rhp.c
  77. $HOME/mygcc/bin/gcc --version
  78. exit 0
  79. $HOME/mygcc/bin/gcc -c -I. -I.. -Isrc -fanalyzer -fdump-analyzer-supergraph src/dpif.c
  80. # -fdump-analyzer-state-purge
  81. # -fdump-analyzer-exploded-graph
  82. # -fdump-analyzer-callgraph
  83. # -fdump-analyzer-supergraph
  84. # -fdump-analyzer-exploded-graph -fdump-analyzer-state-purge -fdump-analyzer-supergraph src/dpif.c
  85. exit 0
  86. # tree data gcc/graph.c
  87. #./configure CC=$HOME/mygcc7/bin/gcc CFLAGS="-Wall -pedantic -fdump-tree-all-graph"
  88. # other gcc dot files do not have options and need gcc debug hacking
  89. #./configure CC=$HOME/mygcc7/bin/gcc CFLAGS="-Wall -pedantic -O2 -fdump-tree-all-graph -fdump-rtl-all-graph"
  90. #./configure CC=$HOME/mygcc/bin/gcc CFLAGS="-Wall -fdump-rtl-expand"
  91. #$HOME/mygcc/bin/gcc --version
  92. # optional support to use clang-3.5 using llvm lib
  93. #./configure CC="clang-3.5 -v"
  94. #clang-3.5 --version
  95. # to check source
  96. #clang --analyze file.c
  97. # optional support to use Linux sparse compiler but does not do c11 standard but can do c99
  98. #./configure CC="sparse"
  99. #sparse --version
  100. # easier: cd src; make CC=sparse
  101. ./configure --enable-gcc-warnings CC=$HOME/misc/src/smatch/smatch/cgcc
  102. make CHECK="~/misc/src/smatch/smatch --full-path" CC=~/misc/src/smatch/smatch/cgcc | tee warns.txt
  103. exit 0