summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-10-25 12:41:32 +0100
committerSam James <sam@gentoo.org>2022-10-25 12:42:25 +0100
commitbec6a7be57fc3493dccef497b5d4b513c315f5f1 (patch)
tree9cbdd9ffd02c4bcc3f9bfa8cf76639be0f2cae0f /sys-devel/flex
parentmedia-libs/flac: Stabilize 1.4.2 arm64, #878251 (diff)
downloadgentoo-bec6a7be57fc3493dccef497b5d4b513c315f5f1.tar.gz
gentoo-bec6a7be57fc3493dccef497b5d4b513c315f5f1.tar.bz2
gentoo-bec6a7be57fc3493dccef497b5d4b513c315f5f1.zip
sys-devel/flex: backport "config.h" fix too
We already have the patch to config.h/configure.ac backported but we don't have the fix to actually *use* config.h everywhere, and clearly from bug #705800 it wasn't sufficient to just backport it (for reasons covered in the bug & upstream bug). Bug: https://bugs.gentoo.org/628744 Bug: https://bugs.gentoo.org/705800 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'sys-devel/flex')
-rw-r--r--sys-devel/flex/files/flex-2.6.4-implicit-func-decl.patch50
-rw-r--r--sys-devel/flex/flex-2.6.4-r3.ebuild95
2 files changed, 145 insertions, 0 deletions
diff --git a/sys-devel/flex/files/flex-2.6.4-implicit-func-decl.patch b/sys-devel/flex/files/flex-2.6.4-implicit-func-decl.patch
new file mode 100644
index 000000000000..1900ae0529b9
--- /dev/null
+++ b/sys-devel/flex/files/flex-2.6.4-implicit-func-decl.patch
@@ -0,0 +1,50 @@
+https://github.com/westes/flex/commit/4b5111d9772b5c160340ca96f08d30d7f6db5cda
+https://github.com/westes/flex/issues/436
+https://bugs.gentoo.org/705800
+https://developers.redhat.com/blog/2019/04/22/implicit-function-declarations-flexs-use-of-reallocarray
+
+From 4b5111d9772b5c160340ca96f08d30d7f6db5cda Mon Sep 17 00:00:00 2001
+From: Explorer09 <explorer09@gmail.com>
+Date: Mon, 4 Sep 2017 08:28:53 +0800
+Subject: [PATCH] scanner: Include flexdef.h at %top block of scan.l
+
+config.h may define macros that alter the API of the standard library
+funtions, and so it should be included before any other standard
+header, even before the skeleton's standard header inclusion.
+
+For example: config.h may #define _GNU_SOURCE that would expose the
+reallocarray() prototype from <stdlib.h> on glibc 2.26+ systems. If we
+include <stdlib.h> before config.h, reallocarray() would not be
+available for use in lex file since the second include doesn't help
+due to header guard.
+
+For now our config.h might `#define malloc rpl_malloc` -- this
+substitution must work before including stdlib.h, or else the compiler
+will complain about missing prototypes, and may result in incorrect
+code in scan.l (gcc warning: return makes pointer from integer without
+a cast [-Wint-conversion]).
+
+Fixes #247.
+--- a/src/scan.l
++++ b/src/scan.l
+@@ -1,5 +1,11 @@
+ /* scan.l - scanner for flex input -*-C-*- */
+
++%top{
++/* flexdef.h includes config.h, which may contain macros that alter the API */
++/* of libc functions. Must include first before any libc header. */
++#include "flexdef.h"
++}
++
+ %{
+ /* Copyright (c) 1990 The Regents of the University of California. */
+ /* All rights reserved. */
+@@ -32,7 +38,6 @@
+ /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+ /* PURPOSE. */
+
+-#include "flexdef.h"
+ #include "parse.h"
+ extern bool tablesverify, tablesext;
+ extern int trlcontxt; /* Set in parse.y for each rule. */
+
diff --git a/sys-devel/flex/flex-2.6.4-r3.ebuild b/sys-devel/flex/flex-2.6.4-r3.ebuild
new file mode 100644
index 000000000000..1f1ebfe61893
--- /dev/null
+++ b/sys-devel/flex/flex-2.6.4-r3.ebuild
@@ -0,0 +1,95 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic libtool multilib-minimal toolchain-funcs
+
+DESCRIPTION="The Fast Lexical Analyzer"
+HOMEPAGE="https://github.com/westes/flex"
+SRC_URI="https://github.com/westes/${PN}/releases/download/v${PV}/${P}.tar.gz"
+
+LICENSE="FLEX"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="nls static test"
+RESTRICT="!test? ( test )"
+
+# We want bison explicitly and not yacc in general, bug #381273
+RDEPEND="sys-devel/m4"
+BDEPEND="${RDEPEND}
+ nls? ( sys-devel/gettext )
+ test? ( sys-devel/bison )"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-2.6.4-libobjdir.patch
+ "${FILESDIR}"/${PN}-2.6.4-fix-build-with-glibc2.6+.patch
+ "${FILESDIR}"/${P}-implicit-func-decl.patch
+)
+
+src_prepare() {
+ default
+
+ # Disable running in the tests/ subdir as it has a bunch of built sources
+ # that cannot be made conditional (automake limitation). bug #568842
+ if ! use test ; then
+ sed -i \
+ -e '/^SUBDIRS =/,/^$/{/tests/d}' \
+ Makefile.in || die
+ fi
+
+ # Prefix always needs this
+ elibtoolize
+}
+
+src_configure() {
+ use static && append-ldflags -static
+
+ multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+ if tc-is-cross-compiler ; then
+ # Similar to workaround for procps:
+ # - bug #705800
+ # - https://sourceforge.net/p/psmisc/bugs/71/
+ # - https://lists.gnu.org/archive/html/autoconf/2011-04/msg00019.html
+ export ac_cv_func_malloc_0_nonnull=yes \
+ ac_cv_func_realloc_0_nonnull=yes
+ fi
+
+ # Do not install shared libs, #503522
+ ECONF_SOURCE="${S}" econf \
+ CC_FOR_BUILD="$(tc-getBUILD_CC)" \
+ --disable-shared \
+ $(use_enable nls)
+}
+
+multilib_src_compile() {
+ if multilib_is_native_abi; then
+ default
+ else
+ emake -C src -f Makefile -f - lib <<< 'lib: $(lib_LTLIBRARIES)'
+ fi
+}
+
+multilib_src_test() {
+ multilib_is_native_abi && emake check
+}
+
+multilib_src_install() {
+ if multilib_is_native_abi; then
+ default
+ else
+ emake -C src DESTDIR="${D}" install-libLTLIBRARIES install-includeHEADERS
+ fi
+}
+
+multilib_src_install_all() {
+ einstalldocs
+ dodoc ONEWS
+ find "${ED}" -name '*.la' -type f -delete || die
+ rm "${ED}"/usr/share/doc/${PF}/COPYING || die
+
+ dosym flex /usr/bin/lex
+}