Backport upstream patch to fix C99 issue in kill

It is again necessary to run autotools during the build.

Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
This commit is contained in:
Florian Weimer 2022-12-17 21:40:37 +01:00
parent 260ccc24c5
commit d65ce0b32c
2 changed files with 56 additions and 6 deletions

46
util-linux-kill-c99.patch Normal file
View File

@ -0,0 +1,46 @@
commit 84732a8849a08d42a9a95dcbee9005116be78eb8
Author: Khem Raj <raj.khem@gmail.com>
Date: Sun Aug 7 14:39:19 2022 -0700
check for sys/pidfd.h
This header in newer glibc defines the signatures of functions
pidfd_send_signal() and pidfd_open() and when these functions are
defined by libc then we need to include the relevant header to get
the definitions. Clang 15+ has started to error out when function
signatures are missing.
Fixes errors like
misc-utils/kill.c:402:6: error: call to undeclared function 'pidfd_send_signal'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (pidfd_send_signal(pfd, ctl->numsig, &info, 0) < 0)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
diff --git a/configure.ac b/configure.ac
index d8b4d475103c2bab..4a35d17f81375c29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -339,6 +339,7 @@ AC_CHECK_HEADERS([ \
sys/mkdev.h \
sys/mount.h \
sys/param.h \
+ sys/pidfd.h \
sys/prctl.h \
sys/resource.h \
sys/sendfile.h \
diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
index eddede9767478be2..d9e33cbc57ae38c8 100644
--- a/include/pidfd-utils.h
+++ b/include/pidfd-utils.h
@@ -4,8 +4,10 @@
#ifdef HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
# if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
+# ifdef HAVE_SYS_PIDFD_H
+# include <sys/pidfd.h>
+# endif
# include <sys/types.h>
-
# ifndef HAVE_PIDFD_SEND_SIGNAL
static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
unsigned int flags)

View File

@ -2,7 +2,7 @@
Summary: Collection of basic system utilities
Name: util-linux
Version: 2.38.1
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
URL: https://en.wikipedia.org/wiki/Util-linux
@ -38,10 +38,10 @@ BuildRequires: librtas-devel
%endif
# enable if make changes to build-system
#BuildRequires: autoconf
#BuildRequires: automake
#BuildRequires: libtool
#BuildRequires: bison
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: bison
### Sources
Source0: https://www.kernel.org/pub/linux/utils/util-linux/v%{upstream_major}/util-linux-%{upstream_version}.tar.xz
@ -93,6 +93,7 @@ Patch0: login-lastlog-create.patch
# Add `/run/motd.d` to the hardcoded MOTD_FILE
# https://github.com/coreos/console-login-helper-messages/issues/60
Patch1: login-default-motd-file.patch
Patch2: util-linux-kill-c99.patch
%description
The util-linux package contains a large variety of low-level system
@ -288,7 +289,7 @@ chfn and chsh utilities with dependence on libuser.
unset LINGUAS || :
# enable only when make a change to the build-system
#./autogen.sh
./autogen.sh
export CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS"
@ -909,6 +910,9 @@ fi
%{_libdir}/python*/site-packages/libmount/
%changelog
* Sat Dec 17 2022 Florian Weimer <fweimer@redhat.com> - 2.38.1-3
- Backport upstream patch to fix C99 issue in kill
* Mon Aug 22 2022 Karel Zak <kzak@redhat.com> - 2.38.1-2
- improve tmpfiles.d use in spec file