From 544d3b72627aa0c69ae0d3808b1541689131f47f Mon Sep 17 00:00:00 2001 From: Fergus Dall Date: Thu, 24 Sep 2020 18:08:39 +1000 Subject: [PATCH] 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. Closes: https://bugs.gentoo.org/732026 Signed-off-by: Fergus Dall --- .../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(+) create mode 100644 dev-libs/ustr/files/ustr-1.0.4-inline-check.patch create mode 100644 dev-libs/ustr/ustr-1.0.4-r9.ebuild 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 0000000000..b38cf7829c --- /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 0000000000..632e404652 --- /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 \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 +} -- 2.28.0.681.g6f77f65b4e-goog