dev-libs/ffcall: fix compilation with clang

patch from upstream

Closes: https://bugs.gentoo.org/829663
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42572
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Z. Liu
2025-06-13 12:27:31 +08:00
committed by Sam James
parent d4cb6ce893
commit 2e3cc0b99d
2 changed files with 134 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit flag-o-matic libtool
MY_PV="libffcall-${PV}"
DESCRIPTION="Build foreign function call interfaces in embedded interpreter"
HOMEPAGE="https://www.gnu.org/software/libffcall/"
SRC_URI="mirror://gnu/libffcall/${MY_PV}.tar.gz"
S="${WORKDIR}"/${MY_PV}
# "Ffcall is under GNU GPL. As a special exception, if used in GNUstep
# or in derivate works of GNUstep, the included parts of ffcall are
# under GNU LGPL." -ffcall author
LICENSE="GPL-2+"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
PATCHES=(
# bug 842915, drop on next version bump
"${FILESDIR}"/${PN}-2.4-vacall-riscv-pic.patch
"${FILESDIR}"/${PN}-2.4-slibtool.patch # 776976
"${FILESDIR}"/${PN}-2.4-create-a-read-only-.eh_frame-section-on-all-p.patch # 829663
)
src_prepare() {
# The build system is a strange mix of autogenerated
# files and manual tweaks on top. Uses $CFLAGS / $LDFLAGS randomly.
# We are adding them consistently here and a bit over the top:
# bugs: #334581
local mfi
for mfi in {,*/,*/*/,}Makefile.in ; do
einfo "Patching '${mfi}'"
# usually uses only assembler here, but -march=
# and -Wa, are a must to pass here.
sed -e 's/$(CC) /&$(CFLAGS) /g' \
-i "${mfi}" || die
done
default
elibtoolize
}
src_configure() {
append-flags -fPIC
# Doc goes in datadir
econf \
--datadir="${EPREFIX}"/usr/share/doc/${PF} \
--enable-shared \
--disable-static
}
src_compile() {
# TODO. Remove -j1
emake -j1
}
src_install() {
dodoc NEWS README
dodir /usr/share/man
default
find "${ED}" -name '*.la' -delete || die
}

View File

@@ -0,0 +1,65 @@
https://git.savannah.gnu.org/cgit/libffcall.git/commit/?id=580f0bb144c0d63560c61229291e172e55971437
From 580f0bb144c0d63560c61229291e172e55971437 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 26 Jun 2021 18:19:21 +0200
Subject: [PATCH] x86_64: Create a read-only .eh_frame section on all
platforms.
Reported by Thomas Klausner <tk@giga.or.at> at
<https://savannah.gnu.org/bugs/?60815>.
* common/asm-x86_64.h (EH_FRAME_SECTION): Use flags "a" (instead of
"aw") on all platforms.
diff --git a/ChangeLog b/ChangeLog
index 1e87b99..d2bde2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-06-26 Bruno Haible <bruno@clisp.org>
+
+ x86_64: Create a read-only .eh_frame section on all platforms.
+ Reported by Thomas Klausner <tk@giga.or.at> at
+ <https://savannah.gnu.org/bugs/?60815>.
+ * common/asm-x86_64.h (EH_FRAME_SECTION): Use flags "a" (instead of
+ "aw") on all platforms.
+
2021-06-13 Bruno Haible <bruno@clisp.org>
maint: Don't require an internet connection for running autogen.sh.
diff --git a/common/asm-x86_64.h b/common/asm-x86_64.h
index b4713d7..edb1ea5 100644
--- a/common/asm-x86_64.h
+++ b/common/asm-x86_64.h
@@ -279,11 +279,24 @@
// Solaris/ELF
#define EH_FRAME_SECTION .eh_frame,"aL",link=.text,@unwind
#else
-#if defined __FreeBSD__
-// FreeBSD/ELF
+// The eh_frame section was usually writable (flags "aw") in older OS versions,
+// but can be made read-only (flags "a") under specific conditions, depending
+// on the assembler's behaviour (look for EH_TABLES_CAN_BE_READ_ONLY in
+// gcc-11.1.0/gcc/defaults.h).
+// To determine whether the eh_frame section is writable or read-only by
+// default, compile a simple program:
+// gcc -S -fno-dwarf2-cfi-asm hello.c (GCC >= 4.4)
+// or
+// gcc -S hello.c (GCC < 4.4)
+// The result is that all modern systems (at least Ubuntu >= 16.04,
+// Red Hat Enterprise Linux >= 5, Fedora >= 13, Alpine Linux >= 3.7,
+// FreeBSD >= 11, DragonFly BSD >= 6, NetBSD >= 7, OpenBSD >= 6)
+// use a read-only eh_frame section.
+#if 1
+// all modern systems
#define EH_FRAME_SECTION .eh_frame,"a",@progbits
#else
-// Linux/ELF
+// only very old systems
#define EH_FRAME_SECTION .eh_frame,"aw",@progbits
#endif
#endif
--
2.45.2