diff options
author | Viorel Munteanu <ceamac@gentoo.org> | 2024-08-23 17:39:13 +0300 |
---|---|---|
committer | Viorel Munteanu <ceamac@gentoo.org> | 2024-08-26 07:28:37 +0300 |
commit | c4a94ba86475049c1806eb81fe28200ee3020a59 (patch) | |
tree | 1dd64cb21da2ace823457103c210e32da626dc02 /sys-boot | |
parent | dev-python/python-mimeparse: Bump to 2.0.0 (diff) | |
download | gentoo-c4a94ba86475049c1806eb81fe28200ee3020a59.tar.gz gentoo-c4a94ba86475049c1806eb81fe28200ee3020a59.tar.bz2 gentoo-c4a94ba86475049c1806eb81fe28200ee3020a59.zip |
sys-boot/gnu-efi: Fix compilation on musl amd64
On amd64, musl typedefs wchar_t to int, conflicting with -fshort-wchar.
Also, /usr/include is searched before the compiler provided include
directory.
As a workaround, use -nostdinc and switch them around.
Closes: https://bugs.gentoo.org/933080
Bug: https://bugs.gentoo.org/938012
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
Diffstat (limited to 'sys-boot')
-rw-r--r-- | sys-boot/gnu-efi/gnu-efi-3.0.18-r4.ebuild | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/sys-boot/gnu-efi/gnu-efi-3.0.18-r4.ebuild b/sys-boot/gnu-efi/gnu-efi-3.0.18-r4.ebuild new file mode 100644 index 000000000000..b34d3a74c7db --- /dev/null +++ b/sys-boot/gnu-efi/gnu-efi-3.0.18-r4.ebuild @@ -0,0 +1,128 @@ +# Copyright 2004-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit flag-o-matic toolchain-funcs + +DESCRIPTION="Library for build EFI Applications" +HOMEPAGE="https://sourceforge.net/projects/gnu-efi/" +SRC_URI="https://downloads.sourceforge.net/gnu-efi/${P}.tar.bz2" + +# inc/, lib/ dirs (README.efilib) +# - BSD-2 +# gnuefi dir: +# - BSD (3-cluase): crt0-efi-ia32.S +# - GPL-2+ : setjmp_ia32.S +LICENSE="GPL-2+ BSD BSD-2" +SLOT="0" +KEYWORDS="-* ~amd64 ~arm ~arm64 ~ia64 ~riscv ~x86" +IUSE="abi_x86_32 abi_x86_64 custom-cflags" +REQUIRED_USE=" + amd64? ( || ( abi_x86_32 abi_x86_64 ) ) + x86? ( || ( abi_x86_32 abi_x86_64 ) ) +" + +# for ld.bfd and objcopy +BDEPEND="sys-devel/binutils" + +# These objects get run early boot (i.e. not inside of Linux), +# so doing these QA checks on them doesn't make sense. +QA_EXECSTACK="usr/*/lib*efi.a:* usr/*/crt*.o" +RESTRICT="strip" + +PATCHES=( + "${FILESDIR}"/${P}-clang.patch + "${FILESDIR}"/${PN}-3.0.18-remove-linux-headers.patch +) + +check_and_set_objcopy() { + if [[ ${MERGE_TYPE} != "binary" ]]; then + # bug #931792 + # llvm-objcopy does not support EFI target, try to use binutils objcopy or fail + tc-export OBJCOPY + OBJCOPY="${OBJCOPY/llvm-/}" + LANG=C LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die "${OBJCOPY} (objcopy) does not support EFI target" + fi +} + +check_comppiler() { + if [[ ${MERGE_TYPE} != "binary" ]]; then + tc-is-gcc || tc-is-clang || die "Unsupported compiler" + fi +} + +pkg_pretend() { + check_comppiler + check_and_set_objcopy +} + +pkg_setup() { + check_and_set_objcopy +} + +src_prepare() { + default + sed -i -e "s/-Werror//" Make.defaults || die +} + +efimake() { + local arch= + case ${CHOST} in + arm*) arch=arm ;; + aarch64*) arch=aarch64 ;; + ia64*) arch=ia64 ;; + i?86*) arch=ia32 ;; + riscv64*) arch=riscv64;; + x86_64*) arch=x86_64 ;; + *) die "Unknown CHOST" ;; + esac + + local args=( + ARCH="${arch}" + HOSTCC="${BUILD_CC}" + CC="${CC}" + AS="${AS}" + LD="${LD}" + AR="${AR}" + OBJCOPY="${OBJCOPY}" + PREFIX="${EPREFIX}/usr" + LIBDIR='$(PREFIX)'/$(get_libdir) + ) + emake -j1 "${args[@]}" "$@" +} + +src_compile() { + tc-export BUILD_CC AR AS CC LD OBJCOPY + + if ! use custom-cflags; then + unset CFLAGS CPPFLAGS LDFLAGS + fi + + # work around musl: include first the compiler include dir, then the system one + # bug #933080, #938012 + local CPPINCLUDEDIR + if tc-is-gcc; then + CPPINCLUDEDIR=$(LANG=C ${CC} -print-search-dirs 2> /dev/null | grep ^install: | cut -f2 -d' ')/include + elif tc-is-clang; then + CPPINCLUDEDIR=$(LANG=C ${CC} -print-resource-dir 2> /dev/null)/include + fi + append-cflags "-nostdinc -isystem ${CPPINCLUDEDIR} -isystem ${ESYSROOT}/usr/include" + + if use amd64 || use x86; then + use abi_x86_32 && CHOST=i686 ABI=x86 efimake + use abi_x86_64 && CHOST=x86_64 ABI=amd64 efimake + else + efimake + fi +} + +src_install() { + if use amd64 || use x86; then + use abi_x86_32 && CHOST=i686 ABI=x86 efimake INSTALLROOT="${D}" install + use abi_x86_64 && CHOST=x86_64 ABI=amd64 efimake INSTALLROOT="${D}" install + else + efimake INSTALLROOT="${D}" install + fi + einstalldocs +} |