X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Ferrs12;h=fd308d3edf1cdb4d03256c29b0e91d3bcd8e859f;hp=12f18f5bf07e65b4a0554a5c6f140c0b57b6b6bd;hb=HEAD;hpb=4726f26d74751bbc05eca069cbe6284976aed530 diff --git a/bin/errs12 b/bin/errs12 index 12f18f5..50740c4 100755 --- a/bin/errs12 +++ b/bin/errs12 @@ -1,20 +1,33 @@ -#! /bin/sh +#! /bin/bash # $Id$ -renice +19 -p $$; ionice -c3 -p $$ +#renice +19 -p $$; ionice -c3 -p $$ +renice +10 -p $$; ionice -c3 -p $$ -# For ctags -PS1=x -. ~/.bashrc +# Do not use for ctags - it would override $PATH: +# PS1=x; . ~/.bashrc +function ctags {(unset ctags; PS1=x; . ~/.bashrc; ctags; );} customss="--enable-static --disable-shared" customm="-m64" target= targets= configure="./configure" -debug="-ggdb2" -ldflags="-lmcheck" +# >=4.7 has small macros section. +if gcc --version|perl -ne 'exit(!(/(\d+)\.(\d+)/&&($1>4||($1==4&&$2>=7))));';then + debug="-g3" +else + debug="-g2" +fi +permissive="" +asan="" +#asan="-fsanitize=address -static-libasan" +mcheck="" +#mcheck="-lmcheck" fast=false +readline="" +disablebinutils="--disable-binutils --disable-gas --disable-gold --disable-gprof --disable-ld --disable-gprofng" +python="" while true do @@ -59,7 +72,36 @@ do if [ "$1" = "-s" ];then # -O0 is important to override GCC -O2. debug="-O0 -s" - ldflags="" + shift + continue + fi + + if [ "$1" = "-fpermissive" ];then + permissive="-fpermissive" + shift + continue + fi + + if [ "$1" = "--asan" ];then + asan="-fsanitize=address -static-libasan" + shift + continue + fi + + if [ "$1" = "--noasan" ];then + asan="" + shift + continue + fi + + if [ "$1" = "--nomcheck" ];then + mcheck="" + shift + continue + fi + + if [ "$1" = "--binutils" ];then + disablebinutils="--enable-gold" shift continue fi @@ -89,41 +131,83 @@ rm -f errs1.ok if ! $fast && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then targets="$targets --enable-targets=all" fi + if test ! -e readline/readline/display.c;then # $fast || + targets="$targets --with-system-readline" + fi if test -f `dirname $configure`/gcc/reload.c;then werror="--disable-werror" customm="" + # --disable-static would fail on finding built libstdc++ due to -static-libstdc++. + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49829 + #customss="" customss="--disable-static --enable-shared" else werror="" fi + if test -d readline/doc && ! test -e readline/readline.c;then + # Fedora gdb.spec prep. + readline="--with-system-readline" + fi + + if test -z "$python";then + if [ -x /usr/bin/python3 ];then + python="--with-python=/usr/bin/python3" + fi + fi + test -z "$CC" && CC=gcc : >errs1.c - for flags in \ - "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4" \ - "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions" \ - "" \ + # -Wp,-D_FORTIFY_SOURCE=2: /usr/include/features.h:329:3: error: #warning _FORTIFY_SOURCE requested but disabled [-Werror=cpp] + # -ftrack-macro-expansion=0: + # hash.c:535:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation] + # hash.c:535:5: note: ...this ‘if’ clause, but it is not + for flags in \ + "$debug -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagnostics-show-caret -Wno-error=cast-function-type -Wno-error=stringop-truncation -Wno-error=format-truncation $asan" \ + "$debug -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagnostics-show-caret $asan" \ + "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fno-diagnostics-show-caret $asan" \ + "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fno-diagnostics-show-caret" \ + "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4" \ + "$debug -pipe -Wall -fexceptions" \ + "" \ ;do if [ -z "$flags" ];then rm -f errs1.c echo >&2 "flags error" exit 1 fi - "$CC" $flags -c errs1.c -o /dev/null && break + # Use -Werror: + # cc1: warnings being treated as errors + # archive.c:1: error: -fstack-protector not supported for this target + "$CC" $flags -Werror -c errs1.c -o /dev/null && break done if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then flags="$customm $flags" fi + echo 'int main (void) { return 0; }' >errs1.c + for ldflags in \ + "-fuse-ld=gold -Wl,--gdb-index -ltcmalloc" \ + "-fuse-ld=gold -Wl,--gdb-index" \ + "-ltcmalloc" \ + "" \ + ;do + "$CC" $flags $ldflags errs1.c -o /dev/null && break + done rm -f errs1.c + if ! echo "$flags"|grep -q 'fsanitize=address';then + asan="" + fi + flags="$flags -D_GLIBCXX_DEBUG" export CFLAGS="$flags" - export CXXFLAGS="$flags" + export CXXFLAGS="$flags $permissive" export GCJFLAGS="$flags" export CFLAGS_FOR_TARGET="$flags" - export CXXFLAGS_FOR_TARGET="$flags" - export LDFLAGS="$ldflags" + export CXXFLAGS_FOR_TARGET="$flags $permissive" + export LDFLAGS="$ldflags $mcheck $asan" - time nice "$configure" $target $targets $customss --enable-debug --disable-sim --enable-gold --enable-plugins $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@" + time nice "$configure" $target $targets $customss $readline $disablebinutils $python --enable-debug --disable-sim $maintainer $werror --with-separate-debug-dir=/usr/lib/debug --without-guile "$@" +# --enable-gold --enable-plugins (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &