diff mbox series

[1/6] scripts/run-scan-build: update

Message ID 20210714181343.58880-1-cgzones@googlemail.com (mailing list archive)
State Accepted
Headers show
Series [1/6] scripts/run-scan-build: update | expand

Commit Message

Christian Göttsche July 14, 2021, 6:13 p.m. UTC
- use multiple jobs
- define _FORTIFY_SOURCE=2 to enable checks on standard string handling
  functions due to macro/intrinsic overloads or function attributes
- allow to override clang and scan-build binaries, i.e. for using
  versioned ones
- set PYTHON_SETUP_ARGS accordingly on Debian
- enable common warning -Wextra
- print build result

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 scripts/run-scan-build | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

James Carter July 19, 2021, 4:58 p.m. UTC | #1
On Wed, Jul 14, 2021 at 2:16 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> - use multiple jobs
> - define _FORTIFY_SOURCE=2 to enable checks on standard string handling
>   functions due to macro/intrinsic overloads or function attributes
> - allow to override clang and scan-build binaries, i.e. for using
>   versioned ones
> - set PYTHON_SETUP_ARGS accordingly on Debian
> - enable common warning -Wextra
> - print build result
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For all six patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  scripts/run-scan-build | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/run-scan-build b/scripts/run-scan-build
> index ae5aa48b..ef07fefc 100755
> --- a/scripts/run-scan-build
> +++ b/scripts/run-scan-build
> @@ -1,6 +1,10 @@
>  #!/bin/sh
>  # Run clang's static analyzer (scan-build) and record its output in output-scan-build/
>
> +# Allow overriding binariy names, like clang-12
> +export CC=${CC:-clang}
> +SCAN_BUILD=${SCAN_BUILD:-scan-build}
> +
>  # Ensure the current directory is where this script is
>  cd "$(dirname -- "$0")" || exit $?
>
> @@ -20,14 +24,24 @@ export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH
>  export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
>  export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
>
> +if [ -f /etc/debian_version ]; then
> +    export PYTHON_SETUP_ARGS='--install-layout=deb'
> +fi
> +
>  # Build and analyze
> -make -C .. CC=clang clean distclean -j"$(nproc)"
> -scan-build -analyze-headers -o "$OUTPUTDIR" make -C .. \
> -    CC=clang \
> +make -C .. clean distclean -j"$(nproc)"
> +$SCAN_BUILD -analyze-headers -o "$OUTPUTDIR" make -C .. \
>      DESTDIR="$DESTDIR" \
> -    CFLAGS="-O2 -Wall -D__CHECKER__ -I$DESTDIR/usr/include" \
> +    CFLAGS="-O2 -Wall -Wextra -D_FORTIFY_SOURCE=2 -D__CHECKER__ -I$DESTDIR/usr/include" \
> +    -j"$(nproc)" \
>      install install-pywrap install-rubywrap all test
>
> +if [ $? -eq 0 ]; then
> +    echo "++ Build succeeded"
> +else
> +    echo "++ Build failed"
> +fi
> +
>  # Reduce the verbosity in order to keep the message from scan-build saying
>  # "scan-build: Run 'scan-view /.../output-scan-build/2018-...' to examine bug reports.
>  set +x
> --
> 2.32.0
>
James Carter July 22, 2021, 1:18 p.m. UTC | #2
On Mon, Jul 19, 2021 at 12:58 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Wed, Jul 14, 2021 at 2:16 PM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > - use multiple jobs
> > - define _FORTIFY_SOURCE=2 to enable checks on standard string handling
> >   functions due to macro/intrinsic overloads or function attributes
> > - allow to override clang and scan-build binaries, i.e. for using
> >   versioned ones
> > - set PYTHON_SETUP_ARGS accordingly on Debian
> > - enable common warning -Wextra
> > - print build result
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For all six patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

This series has been merged.

Thanks,
Jim

> > ---
> >  scripts/run-scan-build | 22 ++++++++++++++++++----
> >  1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/run-scan-build b/scripts/run-scan-build
> > index ae5aa48b..ef07fefc 100755
> > --- a/scripts/run-scan-build
> > +++ b/scripts/run-scan-build
> > @@ -1,6 +1,10 @@
> >  #!/bin/sh
> >  # Run clang's static analyzer (scan-build) and record its output in output-scan-build/
> >
> > +# Allow overriding binariy names, like clang-12
> > +export CC=${CC:-clang}
> > +SCAN_BUILD=${SCAN_BUILD:-scan-build}
> > +
> >  # Ensure the current directory is where this script is
> >  cd "$(dirname -- "$0")" || exit $?
> >
> > @@ -20,14 +24,24 @@ export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH
> >  export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
> >  export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
> >
> > +if [ -f /etc/debian_version ]; then
> > +    export PYTHON_SETUP_ARGS='--install-layout=deb'
> > +fi
> > +
> >  # Build and analyze
> > -make -C .. CC=clang clean distclean -j"$(nproc)"
> > -scan-build -analyze-headers -o "$OUTPUTDIR" make -C .. \
> > -    CC=clang \
> > +make -C .. clean distclean -j"$(nproc)"
> > +$SCAN_BUILD -analyze-headers -o "$OUTPUTDIR" make -C .. \
> >      DESTDIR="$DESTDIR" \
> > -    CFLAGS="-O2 -Wall -D__CHECKER__ -I$DESTDIR/usr/include" \
> > +    CFLAGS="-O2 -Wall -Wextra -D_FORTIFY_SOURCE=2 -D__CHECKER__ -I$DESTDIR/usr/include" \
> > +    -j"$(nproc)" \
> >      install install-pywrap install-rubywrap all test
> >
> > +if [ $? -eq 0 ]; then
> > +    echo "++ Build succeeded"
> > +else
> > +    echo "++ Build failed"
> > +fi
> > +
> >  # Reduce the verbosity in order to keep the message from scan-build saying
> >  # "scan-build: Run 'scan-view /.../output-scan-build/2018-...' to examine bug reports.
> >  set +x
> > --
> > 2.32.0
> >
diff mbox series

Patch

diff --git a/scripts/run-scan-build b/scripts/run-scan-build
index ae5aa48b..ef07fefc 100755
--- a/scripts/run-scan-build
+++ b/scripts/run-scan-build
@@ -1,6 +1,10 @@ 
 #!/bin/sh
 # Run clang's static analyzer (scan-build) and record its output in output-scan-build/
 
+# Allow overriding binariy names, like clang-12
+export CC=${CC:-clang}
+SCAN_BUILD=${SCAN_BUILD:-scan-build}
+
 # Ensure the current directory is where this script is
 cd "$(dirname -- "$0")" || exit $?
 
@@ -20,14 +24,24 @@  export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH
 export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
 export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
 
+if [ -f /etc/debian_version ]; then
+    export PYTHON_SETUP_ARGS='--install-layout=deb'
+fi
+
 # Build and analyze
-make -C .. CC=clang clean distclean -j"$(nproc)"
-scan-build -analyze-headers -o "$OUTPUTDIR" make -C .. \
-    CC=clang \
+make -C .. clean distclean -j"$(nproc)"
+$SCAN_BUILD -analyze-headers -o "$OUTPUTDIR" make -C .. \
     DESTDIR="$DESTDIR" \
-    CFLAGS="-O2 -Wall -D__CHECKER__ -I$DESTDIR/usr/include" \
+    CFLAGS="-O2 -Wall -Wextra -D_FORTIFY_SOURCE=2 -D__CHECKER__ -I$DESTDIR/usr/include" \
+    -j"$(nproc)" \
     install install-pywrap install-rubywrap all test
 
+if [ $? -eq 0 ]; then
+    echo "++ Build succeeded"
+else
+    echo "++ Build failed"
+fi
+
 # Reduce the verbosity in order to keep the message from scan-build saying
 # "scan-build: Run 'scan-view /.../output-scan-build/2018-...' to examine bug reports.
 set +x