commit:     a13790eb155f9c5740fb0c11b56ab2d81dd7f591
Author:     Fergus Dall <sidereal <AT> google <DOT> com>
AuthorDate: Thu Sep 24 08:08:39 2020 +0000
Commit:     Aaron Bauman <bman <AT> gentoo <DOT> org>
CommitDate: Fri Nov 13 21:31:15 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a13790eb

dev-libs/ustr: Fix compilation using clang/LLVM

This package depends on old-style GCC inline functions, but the
patch to maintain this behaviour on newer compilers only works
for GCC specifically. Replace this with a check for
__GNUC_STDC_INLINE__, which is documented to work with both GCC
and clang.

Bug: https://bugs.gentoo.org/732026
Closes: https://bugs.gentoo.org/732026
Signed-off-by: Fergus Dall <sidereal <AT> google.com>
Signed-off-by: Sven Eden <sven.eden <AT> prydeworx.com>
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>

 dev-libs/ustr/files/ustr-1.0.4-inline-check.patch | 27 ++++++++
 dev-libs/ustr/ustr-1.0.4-r9.ebuild                | 83 +++++++++++++++++++++++
 2 files changed, 110 insertions(+)

diff --git a/dev-libs/ustr/files/ustr-1.0.4-inline-check.patch 
b/dev-libs/ustr/files/ustr-1.0.4-inline-check.patch
new file mode 100644
index 00000000000..b38cf7829c9
--- /dev/null
+++ b/dev-libs/ustr/files/ustr-1.0.4-inline-check.patch
@@ -0,0 +1,27 @@
+--- a/ustr-conf.h.in   2007-10-22 08:00:55.000000000 +0200
++++ b/ustr-conf.h.in   2015-09-10 12:24:34.998796842 +0200
+@@ -4,13 +4,23 @@
+ /* this is the custom version for the library itself, for everyone else
+  * ustr-import generates one depending on the options. */
+ 
++/* Ustr relies on GCC's traditional handling of inline functions, not
++ * the version that was actually standardized in C99. GCC-compatible
++ * compilers define __GNUC_STDC_INLINE__ when using the standard
++ * behavior. When this is set we must restore the old inline behavior:
++ */
++#if defined(__GNUC__) \
++ && defined(__GNUC_STDC_INLINE__)
++#  define inline inline __attribute__ ((gnu_inline))
++#endif
++
+ /* The default is now to link against libc. */
+ #ifndef USTR_CONF_INCLUDE_CODEONLY_HEADERS
+ #define USTR_CONF_INCLUDE_CODEONLY_HEADERS 0
+ #endif
+ 
+ /* We can't: if defined(__GLIBC__) && (!defined(_GNU_SOURCE) || !_GNU_SOURCE)
+- *  because by the time we've included a libc header it's too late. */ 
++ *  because by the time we've included a libc header it's too late. */
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE 1
+ #endif

diff --git a/dev-libs/ustr/ustr-1.0.4-r9.ebuild 
b/dev-libs/ustr/ustr-1.0.4-r9.ebuild
new file mode 100644
index 00000000000..632e404652a
--- /dev/null
+++ b/dev-libs/ustr/ustr-1.0.4-r9.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit toolchain-funcs multilib-minimal
+
+DESCRIPTION="Low-overhead managed string library for C"
+HOMEPAGE="http://www.and.org/ustr/";
+SRC_URI="ftp://ftp.and.org/pub/james/ustr/${PV}/${P}.tar.bz2";
+
+LICENSE="|| ( BSD-2 MIT LGPL-2 )"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~arm64 ~mips x86"
+IUSE="static-libs ustr-import"
+
+DOCS=(ChangeLog README README-DEVELOPERS AUTHORS NEWS TODO)
+
+MULTILIB_WRAPPED_HEADERS=(
+       /usr/include/ustr-conf.h
+       /usr/include/ustr-conf-debug.h
+)
+
+src_prepare() {
+       epatch "${FILESDIR}/${P}-inline-check.patch"
+       epatch "${FILESDIR}/${PN}-1.0.4-build-libs.patch"
+       multilib_copy_sources
+}
+
+_emake() {
+       emake \
+               USE_STATIC=$(usex static-libs) \
+               AR="$(tc-getAR)" \
+               CC="$(tc-getCC)" \
+               CFLAGS="${CFLAGS} ${CPPFLAGS}" \
+               LDFLAGS="${LDFLAGS}" \
+               prefix="${EPREFIX}/usr" \
+               libdir="${EPREFIX}/usr/$(get_libdir)" \
+               mandir="${EPREFIX}/usr/share/man" \
+               SHRDIR="${EPREFIX}/usr/share/${P}" \
+               DOCSHRDIR="${EPREFIX}/usr/share/doc/${PF}" \
+               HIDE= \
+               "$@"
+}
+
+multilib_src_configure() {
+       # The included configure tests require execution.
+
+       # We require vsnprintf everywhere as it's in POSIX.
+       printf '#!/bin/sh\necho 0\n' > autoconf_vsnprintf
+       chmod a+rx autoconf_vsnprintf
+
+       # Always use stdint.h as it's in POSIX.
+       sed -i '/have_stdint_h=0/s:=0:=1:' Makefile || die
+
+       # Figure out the size of size_t.
+       printf '#include <sys/types.h>\nint main() { char buf[sizeof(size_t) - 
8]; }\n' > sizet_test.c
+        $(tc-getCC) ${CPPFLAGS} ${CFLAGS} -c sizet_test.c 2>/dev/null
+       printf '#!/bin/sh\necho %s\n' $(( $? == 0 )) > autoconf_64b
+       chmod a+rx autoconf_64b
+
+       # Generate the config file now to avoid bad makefile deps.
+       _emake ustr-import
+}
+
+multilib_src_compile() {
+       _emake all-shared
+}
+
+multilib_src_install() {
+       _emake DESTDIR="${D}" install
+
+       if ! use ustr-import ; then
+               rm -r \
+                       "${ED}/usr/bin/ustr-import" \
+                       "${ED}/usr/share/man/man1/ustr-import.1" \
+                       "${ED}/usr/share/${P}" || die
+       fi
+}
+
+multilib_src_test() {
+       _emake check
+}

Reply via email to