Bug 258508 - misc/rump: fix build with clang 13
Summary: misc/rump: fix build with clang 13
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vanilla I. Shu
URL:
Keywords:
Depends on:
Blocks: 258209
  Show dependency treegraph
 
Reported: 2021-09-14 21:36 UTC by Dimitry Andric
Modified: 2021-09-15 07:57 UTC (History)
0 users

See Also:
vanilla: maintainer-feedback+


Attachments
misc/rump: fix or suppress clang 13 warnings (1.79 KB, patch)
2021-09-14 21:37 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2021-09-14 21:36:34 UTC
During an exp-run for llvm 13 (see bug 258209), it turned out that misc/rump fails to build with clang 13:

#   compile  librump/nist_ctr_drbg.pico
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/bin/x86_64--netbsd-clang -O2 -O2 -pipe -Wno-address-of-packed-member -fstack-protector-strong -fno-strict-aliasing -ffreestandin
g -fno-strict-aliasing -mno-red-zone -mno-mmx -mno-sse -mno-avx -msoft-float  -std=gnu99     -Wno-sign-compare -Wno-pointer-sign  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -W
no-sign-compare  -Wa,--fatal-warnings -Wreturn-type -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter -Wno-varargs -Wno-sign-compare -Werror -Wno-format-zero-length -Wno
-pointer-sign     -DRUMPUSER_CONFIG=yes -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/autoconf -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/compat/i
nclude -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/dest.stage/usr/include  -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -nostdinc -imacros /wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b
914579/src/lib/librump/../../sys/rump/include/opt/opt_rumpkernel.h -imacros /wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/include/opt_buildrump.h -I/wrkdirs/usr/ports/misc/ru
mp/work/buildrump.sh-b914579/src/lib/librump -I. -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../../common/include -I/wrkdirs/usr/ports/misc/rump/work/b
uildrump.sh-b914579/src/lib/librump/../../sys/rump/include -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/include/opt -I/wrkdirs/usr/ports/misc/rump/work/
buildrump.sh-b914579/src/lib/librump/../../sys/rump/../arch -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/.. -DRUMP_USE_CTOR -DRUMP_CURLWP=RUMP_CURLWP___
THREAD -DKTRACE -U__FreeBSD__ -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/librump/rumpkern -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src
/lib/librump/../../sys/rump/../lib/libkern/arch/x86_64  -D_RUMPKERNEL -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/li
bc/quad -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/libc/string -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b91
4579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/libc/arch/x86_64/string -I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libke
rn/../../../common/include  -c    -fPIC /wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../crypto/nist_ctr_drbg/nist_ctr_drbg.c -o nist_ctr_drbg.pico
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../crypto/nist_ctr_drbg/nist_ctr_drbg.c:156:32: error: performing pointer subtraction with a null pointer has
 undefined behavior [-Werror,-Wnull-pointer-subtraction]
        intptr_t ip = (const char *)p - (const char *)0;
                                      ^ ~~~~~~~~~~~~~~~

This particular new clang 13 warning is indeed a bug and should be fixed, by simply casting the pointer 'p' directly to intptr_t instead.

The other new clang 13 warning emitted quite a lot is -Wunused-but-set-variable. As this occurs quite often, and is not very useful to patch without involving upstream, I propose disabling the warning for now.
Comment 1 Dimitry Andric freebsd_committer 2021-09-14 21:37:16 UTC
Created attachment 227907 [details]
misc/rump: fix or suppress clang 13 warnings
Comment 2 Vanilla I. Shu freebsd_committer 2021-09-14 22:51:14 UTC
it seems ok to me, please feel free to commit, thanks.
Comment 3 commit-hook freebsd_committer 2021-09-15 07:55:33 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9a10eff03e919e71578cdb66d588b756a0cd1bb6

commit 9a10eff03e919e71578cdb66d588b756a0cd1bb6
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-09-14 21:30:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-09-15 07:54:56 +0000

    misc/rump: fix or suppress clang 13 warnings

    Fix a null pointer subtraction bug reported by clang 13, and suppress
    the new clang 13 -Wunused-but-set-variable warning, as it triggers quite
    often in the NetBSD src tree.

    PR:             258508
    Approved by:    vanilla (maintainer)
    MFH:            2021Q3

 misc/rump/Makefile                                            | 10 +++++++---
 ...tch-src_sys_crypto_nist__ctr__drbg_nist__ctr__drbg.c (new) | 11 +++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)