On 1/6/26 2:41 PM, Ales Musil via dev wrote:
> Currently the sanitizers option would be honored only with Clang,
> make sure we can also use it with GCC, for this we require extra
> linker flag and 2 packages for Fedora, Ubuntu has them installed
> by default with GCC.
> 
> Reported-at: https://issues.redhat.com/browse/FDP-2671
> Signed-off-by: Ales Musil <[email protected]>
> ---

Hi Ales,

Thanks for the patch, this is very good to have indeed!

>  .ci/linux-build.sh                     | 40 +++++++++++++++++++-------
>  utilities/containers/fedora/Dockerfile |  2 ++
>  2 files changed, 31 insertions(+), 11 deletions(-)
> 
> diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
> index a82027698..baea46cd1 100755
> --- a/.ci/linux-build.sh
> +++ b/.ci/linux-build.sh
> @@ -69,12 +69,18 @@ function configure_ovn()
>      { cat config.log; exit 1; }
>  }
>  
> +function configure_sanitizers()
> +{
> +    # If AddressSanitizer and UndefinedBehaviorSanitizer are requested,
> +    # enable them, but only for OVN, not for OVS.  However, disable some
> +    # optimizations for OVS, to make sanitizer reports user friendly.
> +    COMMON_CFLAGS="${COMMON_CFLAGS} -O1 -fno-omit-frame-pointer -fno-common 
> -g"
> +    OVN_CFLAGS="${OVN_CFLAGS} -fsanitize=address,undefined"
> +}
> +
>  function configure_gcc()
>  {
> -    if [ "$ARCH" = "x86_64" ] && [ "$USE_SPARSE" = "yes" ]; then
> -        # Enable sparse only for x86_64 architecture.
> -        OPTS="$OPTS --enable-sparse"
> -    elif [ "$ARCH" = "x86" ]; then
> +    if [ "$ARCH" = "x86" ]; then
>          # Adding m32 flag directly to CC to avoid any possible issues
>          # with API/ABI difference on 'configure' and 'make' stages.
>          export CC="$CC -m32"
> @@ -87,19 +93,31 @@ function configure_gcc()
>              # Install equivalent of gcc-multilib for Fedora.
>              sudo dnf -y install glibc-devel.i686
>          fi
> +
> +        return
> +    fi
> +
> +    if [ "$ARCH" = "x86_64" ] && [ "$USE_SPARSE" = "yes" ]; then
> +        # Enable sparse only for x86_64 architecture.
> +        OPTS="$OPTS --enable-sparse"
>      fi
> -}
>  
> -function configure_clang()
> -{
>      # If AddressSanitizer and UndefinedBehaviorSanitizer are requested,
>      # enable them, but only for OVN, not for OVS.  However, disable some
>      # optimizations for OVS, to make sanitizer reports user friendly.

This comment is now duplicated.

> +
> +    if [ "$SANITIZERS" ]; then
> +        configure_sanitizers
> +        # Unlike for clang we also need to statically link the libraries.
> +        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94328
> +        OVN_CFLAGS="${OVN_CFLAGS} -static-libasan -static-libubsan"
> +    fi
> +}
> +
> +function configure_clang()
> +{
>      if [ "$SANITIZERS" ]; then
> -       # Use the default options configured in tests/atlocal.in,
> -       # in UBSAN_OPTIONS.
> -       COMMON_CFLAGS="${COMMON_CFLAGS} -O1 -fno-omit-frame-pointer 
> -fno-common -g"
> -       OVN_CFLAGS="${OVN_CFLAGS} -fsanitize=address,undefined"
> +        configure_sanitizers
>      fi
>      COMMON_CFLAGS="${COMMON_CFLAGS} -Wno-error=unused-command-line-argument"
>  }
> diff --git a/utilities/containers/fedora/Dockerfile 
> b/utilities/containers/fedora/Dockerfile
> index ace35147c..af05dac62 100755
> --- a/utilities/containers/fedora/Dockerfile
> +++ b/utilities/containers/fedora/Dockerfile
> @@ -25,8 +25,10 @@ RUN dnf -y update \
>          jemalloc-devel \
>          kernel-devel \
>          kmod \
> +        libasan-static \
>          libcap-ng-devel \
>          libtool \
> +        libubsan-static \
>          llvm-devel \
>          net-tools \
>          nfdump \

With the dup comment removed, applied to main.

Regards,
Dumitru


_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to