all: better support for clang Static Analyzer (scan-build)

This commit is contained in:
Markus F.X.J. Oberhumer
2023-01-19 19:17:26 +01:00
parent 0a8876443a
commit 213ac3ac73
9 changed files with 55 additions and 21 deletions
@@ -6,10 +6,10 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
# create the image from Dockerfile
# using a rootless Podman container
# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20221212-v3,
# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20221212-v4,
# so you have to create that image first
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
image=upx-cross-compile-20230115-v1
image=upx-cross-compile-20230115-v2
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
@@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
# run an interactive shell in the image
# using a rootless Podman container
image=upx-cross-compile-20230115-v1
image=upx-cross-compile-20230115-v2
flags=( -ti --read-only --rm )
flags+=( --cap-drop=all ) # drop all capabilities
@@ -37,12 +37,17 @@ podman run "${flags[@]}" "$image" bash -l
# rm -rf ./build/extra/cross-windows-mingw64/release
# make build/extra/cross-windows-mingw64/release
# lots of other cross-compilers are installed; see "ls /usr/bin/*g++*"
# and we can run the clang Static Analyzer (scan-build)
# cd /home/upx/src/upx
# rm -rf ./build/extra/scan-build/release
# make build/extra/scan-build/release
# and see misc/cross-compile-upx-with-podman/build-all-inside-container.sh; after
# running that script we can do cool things like:
# and lots of other cross-compilers are installed; see "ls /usr/bin/*g++*"
# and finally see misc/cross-compile-upx-with-podman/build-all-inside-container.sh
# after running that script we can do cool things like:
# cd /home/upx/src/upx/build/cross-compile-upx-with-podman/alpha-linux-gnu/debug
# qemu-alpha -L /usr/alpha-linux-gnu upx --version
# cd /home/upx/src/upx/build/cross-compile-upx-with-podman/hppa-linux-gnu/debug
# qemu-hppa -L /usr/hppa-linux-gnu upx --version
# (similar for many other archs)
# (similar for many other architectures/builds)
@@ -1,8 +1,8 @@
# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20221212-v3,
# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20221212-v4,
# so you have to create that image first
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
FROM localhost/upx-stubtools-20221212-v3
ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-20230115-v1
FROM localhost/upx-stubtools-20221212-v4
ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-20230115-v2
ARG DEBIAN_FRONTEND=noninteractive
USER root
@@ -43,6 +43,12 @@ RUN apt-get install -y \
# misc
gdb lsb-release valgrind \
&& true
RUN cd /usr/bin \
# create unversioned clang symlinks
&& for f in clang*-14 llvm-*-14 scan-*-14; do ln -s -v ../../bin/$f /usr/local/bin/${f%-14}; done \
&& ln -s -v ../../bin/obj2yaml-14 /usr/local/bin/llvm-obj2yaml \
&& ln -s -v ../../bin/yaml2obj-14 /usr/local/bin/llvm-yaml2obj \
&& true
# switch back to default user upx 2000:2000
USER upx
@@ -33,6 +33,10 @@ function run_config_and_build {
# avoid warnings about arm libstdc++ ABI change in gcc-7
arm-linux-*) CXX="$CXX -Wno-psabi" ;;
esac
if [[ 1 == 1 ]]; then
# prefer building with Ninja (ninja-build)
cmake_config_flags="$cmake_config_flags -G Ninja -DUPX_CONFIG_CMAKE_DISABLE_INSTALL=ON"
fi
# for all build types
for build_type in Debug Release; do
bdir=build/cross-compile-upx-with-podman/$toolchain/${build_type,,}
@@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
# create the image from Dockerfile
# using a rootless Podman container
image=upx-stubtools-20221212-v3
image=upx-stubtools-20221212-v4
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
@@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
# run an interactive shell in the image
# using a rootless Podman container
image=upx-stubtools-20221212-v3
image=upx-stubtools-20221212-v4
flags=( -ti --read-only --rm )
flags+=( --cap-drop=all ) # drop all capabilities
+4 -4
View File
@@ -1,5 +1,5 @@
FROM docker.io/library/ubuntu:22.04
ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20221212-v3
ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20221212-v4
ARG DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
@@ -13,9 +13,9 @@ RUN dpkg --add-architecture i386 \
# the following packages are not required for rebuilding the stubs, but
# they do make the image much more convenient and also allow building
# the full UPX binary inside the container via CMake:
7zip bfs bzip2 cmake elfutils fd-find file fzf g++ gdb htop hyperfine \
libzstd-dev lzip lzop ninja-build p7zip patch patchelf pax-utils ripgrep \
rsync screen universal-ctags unzip vim zip zlib1g-dev zsh zstd \
7zip bfs bzip2 cmake curl elfutils fd-find file fzf g++ gdb gojq htop hyperfine \
jq libzstd-dev lsb-release lzip lzop ninja-build p7zip patch patchelf pax-utils \
ripgrep rsync screen universal-ctags unzip vim zip zlib1g-dev zsh zstd \
# extra packages for compiling with "gcc -m32" and and "gcc -mx32":
gcc-multilib g++-multilib \
&& true