Fix missing inline function definition

The coreutils-i18n-expand-unexpand.patch adds 3 definitions of the
mbfile_multi_getc function.  2 of the definitions are marked with
the inline keyword, which means that there must also be an externally
visible definition.  The 3rd definition is marked extern inline, which statisfies
this requirement.  However, the 3rd definition is defined in mbfile.c
which is not compiled or linked in to any executable.  This causes build
failures if the compiler decides not to inline the function (which it is
allowed to do) e.g.

src/expand.c:153: undefined reference to `mbfile_multi_getc'

clang does not inline this function, but gcc does which is why
you will not see this failure when compiling with gcc.  However,
gcc could choose not to inline this, so even though the build succeeds,
it is depending on an implementation detail of gcc rather than the
C specification.

In order to fix this problem, mbfile.c was added to the list of sources for
any executable that uses mbfile_multi_getc.
This commit is contained in:
Tom Stellard 2020-04-17 04:12:34 +00:00
parent d27f8523e2
commit f4a53e34d0
2 changed files with 20 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Co-authored-by: Pádraig Brady <pbrady@redhat.com>
lib/mbfile.h | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
m4/mbfile.m4 | 14 +++
src/expand.c | 43 +++++----
src/local.mk | 4 +-
src/unexpand.c | 54 +++++++----
tests/expand/mb.sh | 98 ++++++++++++++++++++
tests/local.mk | 2 +
@ -458,6 +459,21 @@ index 9fa2e10..380e020 100644
}
}
diff --git a/src/local.mk b/src/local.mk
index 72db9c704..ef3bfa469 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -415,8 +415,8 @@ src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS)
src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
-src_expand_SOURCES = src/expand.c src/expand-common.c
-src_unexpand_SOURCES = src/unexpand.c src/expand-common.c
+src_expand_SOURCES = src/expand.c src/expand-common.c lib/mbfile.c
+src_unexpand_SOURCES = src/unexpand.c src/expand-common.c lib/mbfile.c
# Ensure we don't link against libcoreutils.a as that lib is
# not compiled with -fPIC which causes issues on 64 bit at least
diff --git a/src/unexpand.c b/src/unexpand.c
index 7801274..569a7ee 100644
--- a/src/unexpand.c

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.32
Release: 3%{?dist}
Release: 4%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@ -259,6 +259,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Fri Apr 17 2020 Tom Stellard <tstellar@redhat.com> - 8.32-4
- Fix missing inline function definition
* Wed Mar 11 2020 Kamil Dudka <kdudka@redhat.com> - 8.32-3
- uniq: remove collation handling as required by newer POSIX