fix building with strict C99
Resolves: rhbz#2144903
This commit is contained in:
parent
9a37cd0827
commit
225f16ca87
129
ksh-1.0.6-fix-strict-c99-compatibilty.patch
Normal file
129
ksh-1.0.6-fix-strict-c99-compatibilty.patch
Normal file
@ -0,0 +1,129 @@
|
||||
From da983e28d4fd2793c0cc06f5fd012c2e287b3875 Mon Sep 17 00:00:00 2001
|
||||
From: Johnothan King <johnothanking@protonmail.com>
|
||||
Date: Sat, 9 Sep 2023 14:40:20 -0700
|
||||
Subject: [PATCH] Fix problems in relation to Fedora's C99 instrumentation
|
||||
(#665)
|
||||
|
||||
This commit applies the necessary changes to the ksh codebase to
|
||||
fix C99 compilation when using Red Hat's instrumented GCC[*],
|
||||
though note that a patch to redhat-rpm-config is also required and
|
||||
must be applied separately[*2].
|
||||
|
||||
[*1] https://fedoraproject.org/wiki/Toolchain/PortingToModernC
|
||||
[*2] https://github.com/ksh93/ksh/issues/664#issuecomment-1608870665
|
||||
|
||||
src/lib/libast/comp/conf.tab:
|
||||
- Add include directives to fix implicit function declarations that
|
||||
cause the PID_MAX test to silently fail. This compile error
|
||||
occurs on all platforms when compiling with strict C99, but
|
||||
wasn't exposed even after setting IFFEFLAGS to -d1 or -d2 (that's
|
||||
likely a separate bug in conf.sh that'll need fixing). As a
|
||||
consequence, it could cause following bug in the getconf builtin
|
||||
(now fixed as of this commit):
|
||||
$ /opt/ast/bin/getconf PID_MAX
|
||||
30000 # Wrong, should be the platform value (e.g., 4194304)
|
||||
|
||||
src/lib/libast/{features/lib,sfio/sfhdr.h}:
|
||||
- Delete the lib_poll_fd_2 feature test and associated code, which
|
||||
allowed ksh to used non-compliant implementations of poll(3).
|
||||
This feature test fails on POSIX-compliant systems with
|
||||
int-conversion errors, which is the expected result. However, the
|
||||
C99 instrumentation used by Red Hat marks the entire build as a
|
||||
failure because of the fact those errors exist at all, even
|
||||
though the build proceeds as normal. Fortunately, the operating
|
||||
systems supported by ksh (AFAIK) all have proper, POSIX-compliant
|
||||
versions of poll() and thus don't need this test. To work around
|
||||
the flawed instrumentation, the unnecessary test has been
|
||||
jettisoned.
|
||||
|
||||
Cherry-picked-by: Lukáš Zaoral <lzaoral@redhat.com>
|
||||
Upstream-commit: da983e28d4fd2793c0cc06f5fd012c2e287b3875
|
||||
|
||||
---
|
||||
src/lib/libast/comp/conf.tab | 3 +++
|
||||
src/lib/libast/features/lib | 24 +-----------------------
|
||||
src/lib/libast/sfio/sfhdr.h | 9 ---------
|
||||
3 files changed, 4 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/src/lib/libast/comp/conf.tab b/src/lib/libast/comp/conf.tab
|
||||
index cd50e8bf78bc..4124752412ea 100644
|
||||
--- a/src/lib/libast/comp/conf.tab
|
||||
+++ b/src/lib/libast/comp/conf.tab
|
||||
@@ -390,6 +390,9 @@ PBS_MESSAGE POSIX SC 2 FUW
|
||||
PBS_TRACK POSIX SC 2 FUW
|
||||
PHYS_PAGES SUN SC 1 0
|
||||
PID_MAX SVID SC 1 LMU 30000 cc{
|
||||
+ #include <fcntl.h>
|
||||
+ #include <stdio.h>
|
||||
+ #include <stdlib.h>
|
||||
int main(void)
|
||||
{
|
||||
long v;
|
||||
diff --git a/src/lib/libast/features/lib b/src/lib/libast/features/lib
|
||||
index d8307ad0aa78..7e68e89075cc 100644
|
||||
--- a/src/lib/libast/features/lib
|
||||
+++ b/src/lib/libast/features/lib
|
||||
@@ -68,7 +68,7 @@ tst tst_errno note{ errno can be assigned }end link{
|
||||
int main(void) { errno = 0; error(); strerror(); return 0; }
|
||||
}end
|
||||
|
||||
-tst lib_poll_fd_1 note{ fd is first arg to poll() }end execute{
|
||||
+tst lib_poll note{ poll() args comply with the POSIX standard }end execute{
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
extern int pipe(int*);
|
||||
@@ -87,28 +87,6 @@ tst lib_poll_fd_1 note{ fd is first arg to poll() }end execute{
|
||||
}
|
||||
}end
|
||||
|
||||
-tst lib_poll_fd_2 note{ fd is second arg to poll() }end execute{
|
||||
- #include <poll.h>
|
||||
- #include <unistd.h>
|
||||
- extern int pipe(int*);
|
||||
- int
|
||||
- main(void)
|
||||
- { int rw[2];
|
||||
- struct pollfd fd;
|
||||
- if (pipe(rw) < 0) return 1;
|
||||
- fd.fd = rw[0];
|
||||
- fd.events = POLLIN;
|
||||
- fd.revents = 0;
|
||||
- return poll(1, &fd, 0) < 0;
|
||||
- if (poll(1, &fd, 0) < 0 || fd.revents != 0) return 1;
|
||||
- if (write(rw[1], "x", 1) != 1) return 1;
|
||||
- if (poll(1, &fd, 0) < 0 || fd.revents == 0) return 1;
|
||||
- return 0;
|
||||
- }
|
||||
-}end
|
||||
-
|
||||
-exp _lib_poll _lib_poll_fd_1||_lib_poll_fd_2
|
||||
-
|
||||
tst lib_poll_notimer note{ poll with no fds ignores timeout }end execute{
|
||||
#include <sys/types.h>
|
||||
#include <poll.h>
|
||||
diff --git a/src/lib/libast/sfio/sfhdr.h b/src/lib/libast/sfio/sfhdr.h
|
||||
index 755bb2add8e1..64ee68ed5eba 100644
|
||||
--- a/src/lib/libast/sfio/sfhdr.h
|
||||
+++ b/src/lib/libast/sfio/sfhdr.h
|
||||
@@ -103,21 +103,12 @@
|
||||
#if _sys_select
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
-#else
|
||||
-#if _lib_poll_fd_1 || _lib_poll_fd_2
|
||||
-#define _lib_poll 1
|
||||
-#endif
|
||||
#endif /*_lib_select_*/
|
||||
|
||||
#if _lib_poll
|
||||
#include <poll.h>
|
||||
-
|
||||
-#if _lib_poll_fd_1
|
||||
#define SFPOLL(pfd,n,tm) poll((pfd),(ulong)(n),(tm))
|
||||
-#else
|
||||
-#define SFPOLL(pfd,n,tm) poll((ulong)(n),(pfd),(tm))
|
||||
#endif
|
||||
-#endif /*_lib_poll*/
|
||||
|
||||
#if _stream_peek
|
||||
#include <stropts.h>
|
8
ksh.spec
8
ksh.spec
@ -4,12 +4,15 @@ URL: http://www.kornshell.com/
|
||||
License: EPL-2.0
|
||||
Epoch: 3
|
||||
Version: 1.0.6
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||
Source1: kshcomp.conf
|
||||
Source2: kshrc.rhs
|
||||
Source3: dotkshrc
|
||||
|
||||
# ksh: Porting to C99 (#2144903)
|
||||
Patch1: ksh-1.0.6-fix-strict-c99-compatibilty.patch
|
||||
|
||||
Conflicts: pdksh
|
||||
Requires: coreutils, diffutils
|
||||
BuildRequires: gcc
|
||||
@ -131,6 +134,9 @@ fi
|
||||
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
|
||||
|
||||
%changelog
|
||||
* Wed Sep 13 2023 Lukáš Zaoral <lzaoral@redhat.com> - 3:1.0.6-3
|
||||
- fix building with strict C99 (rhbz#2144903)
|
||||
|
||||
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3:1.0.6-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user