Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 817899 - dev-lang/fpc-3.2.2 arm64 keyword request
Summary: dev-lang/fpc-3.2.2 arm64 keyword request
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Keywording (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Amy Liffey
URL:
Whiteboard:
Keywords: CC-ARCHES
: 802717 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-12 20:47 UTC by Norayr Chilingarian
Modified: 2021-10-17 01:04 UTC (History)
2 users (show)

See Also:
Package list:
dev-lang/fpc-3.2.2 arm64
Runtime testing required: ---
nattka: sanity-check-


Attachments
fpc-3.2.2 ebuild that builds on aarch64 (fpc-3.2.2.ebuild,4.56 KB, text/plain)
2021-10-16 18:36 UTC, Norayr Chilingarian
no flags Details
patch for current fpc-3.2.2 ebuild to build fpc-3.2.2 on aarch64 (fpc-3.2.2.patch,333 bytes, patch)
2021-10-16 18:38 UTC, Norayr Chilingarian
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Norayr Chilingarian 2021-10-12 20:47:10 UTC
though fpc-3.2.2 officially supports the architecture and even provides binary builds: https://www.freepascal.org/down/aarch64/linux.html

error message i get:

____________________________
Saving to: ‘/mnt/mmc/gentoo/distfiles/fpc-3.2.2.source.tar.gz.__download__’

/mnt/mmc/gentoo/dis 100%[===================>]  49.82M   296KB/s    in 3m 16s

2021-10-13 00:42:32 (260 KB/s) - ‘/mnt/mmc/gentoo/distfiles/fpc-3.2.2.source.tar.gz.__download__’ saved [52240052/52240052]

 * fpc-3.2.2.source.tar.gz BLAKE2B SHA512 size ;-) ...                   [ ok ]
 * fpc-3.2.2.source.tar.gz BLAKE2B SHA512 size ;-) ...                   [ ok ]
>>> Unpacking source...
 * ERROR: dev-lang/fpc-3.2.2::gentoo failed (unpack phase):
 *   This ebuild doesn't support arm64

___________________________
Comment 1 Tee KOBAYASHI 2021-10-13 05:11:44 UTC
See also https://bugs.gentoo.org/801649
Comment 2 NATTkA bot gentoo-dev 2021-10-15 09:56:23 UTC
Unable to check for sanity:

> package masked: dev-lang/fpc-3.2.2, by keywords: -arm64
Comment 3 Cănărău Constantin 2021-10-15 14:44:40 UTC
fpc-3.2.2, and probably 3.2.0, are incompatible with glibc-2.34 on arm64.
See: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
Comment 4 Norayr Chilingarian 2021-10-16 18:01:29 UTC
meanwhile i have applied a couple of dirty hacks to fpc-3.2.2.ebuild and built fpc on aarch64 successfully:

_______________________________________
[2021-10-16 21:57:54] $ cat test.pas
begin

writeln ('hello from aarch64 gentoo system');

end.
[2021-10-16 21:57:57] $ fpc test.pas
Free Pascal Compiler version 3.2.2 [2021/10/16] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling test.pas
Assembling program
Linking test
5 lines compiled, 0.2 sec
[2021-10-16 21:58:15] $ ./test
hello from aarch64 gentoo system
[2021-10-16 21:58:19] $ qlist -Iv | grep glibc
sys-libs/glibc-2.33-r7

_______________________________________

my system is fully updated, but i have glibc-2.33.

hacks are quick and dirty, because i replaced amd64 with arm64 in several places.

but fpc compiled and seem to work absolutely fine.

this is what i did:

__________________________________
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit prefix toolchain-funcs

HOMEPAGE="https://www.freepascal.org/"
DESCRIPTION="Free Pascal Compiler"
SRC_URI="mirror://sourceforge/freepascal/fpcbuild-${PV}.tar.gz
	mirror://sourceforge/freepascal/fpc-${PV}.source.tar.gz
	amd64? ( mirror://sourceforge/freepascal/${P}.x86_64-linux.tar )
	arm64? ( mirror://sourceforge/freepascal/${P}.aarch64-linux.tar )
	x86? ( mirror://sourceforge/freepascal/${P}.i386-linux.tar )
	doc? ( mirror://sourceforge/freepascal/Documentation/${PV}/doc-html.tar.gz -> ${P}-doc-html.tar.gz )"
S="${WORKDIR}/fpcbuild-${PV}/fpcsrc"

LICENSE="GPL-2 LGPL-2.1-with-linking-exception"
SLOT="0"
KEYWORDS="-* ~amd64 ~x86 ~arm64"
IUSE="doc source"
RESTRICT="strip" #269221

# fpc is special: it can't use CFLAGS and LDFLAGS directly
# since those are geared for running through gcc's frontend
QA_FLAGS_IGNORED="
	usr/bin/.*
	usr/lib.*/.*"

pkg_pretend() {
	if [[ ${MERGE_TYPE} != binary ]]; then
		# Bug 475210
		if $(tc-getLD) --version | grep -q "GNU gold"; then
			eerror "fpc has several issues with the gold linker and does not easily"
			eerror "permit selection. Please do not use USE=default-gold on binutils."
			die "GNU gold detected from $(tc-getLD)"
		fi
	fi
}

src_unpack() {
	case ${ARCH} in
		arm64)
			FPC_ARCH="aarch64"
			PV_BIN="${PV}"
			;;
		x86)
			FPC_ARCH="i386"
			PV_BIN="${PV}"
			;;
		*)
			die "This ebuild doesn't support ${ARCH}" ;;
	esac

	unpack ${A}

	unpack "${PN}-${PV_BIN}.${FPC_ARCH}-linux/binary.${FPC_ARCH}-linux.tar"
	unpack ./base.${FPC_ARCH}-linux.tar.gz
}

src_prepare() {
	default

	find "${WORKDIR}" -name Makefile -exec sed -i 's/ -Xs / /' {} + || die

	# let the pkg manager compress man files
	sed -i '/find man.* gzip /d' "${WORKDIR}"/fpcbuild-${PV}/install/man/Makefile || die

	# make the compiled binary check for fpc.cfg under the prefixed /etc/ path
	hprefixify "${WORKDIR}"/fpcbuild-${PV}/fpcsrc/compiler/options.pas
}

set_pp() {
	case ${ARCH} in
		arm64)
			FPC_ARCH="a64"
			FPC_PARCH="aarch64"
			;;
		x86)
			FPC_ARCH="386"
			FPC_PARCH="i386"
			;;
		*)
			die "This ebuild doesn't support ${ARCH}" ;;
	esac

	case ${1} in
		bootstrap)
			pp="${WORKDIR}/lib/fpc/${PV_BIN}/ppc${FPC_ARCH}"
			;;
		new)
			pp="${S}/compiler/ppc${FPC_ARCH}"
			;;
		*)
			die "set_pp: unknown argument: ${1}" ;;
	esac
}

src_compile() {
	local pp

	# Using the bootstrap compiler.
	set_pp bootstrap

	emake PP="${pp}" compiler_cycle AS="$(tc-getAS)"

	# Save new compiler from cleaning...
	cp compiler/ppc${FPC_ARCH} ppc${FPC_ARCH}.new || die

	# ...rebuild with current version...
	emake PP="${S}/ppc${FPC_ARCH}.new" AS="$(tc-getAS)" compiler_cycle

	# ..and clean up afterwards
	rm ppc${FPC_ARCH}.new || die

	# Using the new compiler.
	set_pp new

	emake PP="${pp}" AS="$(tc-getAS)" rtl_clean

	# ide is moved to packages directory and build unconditionally
	emake PP="${pp}" AS="$(tc-getAS)" rtl packages_all utils
}

src_install() {
	local pp
	set_pp new

	#fpcbuild-3.0.0/utils/fpcm/fpcmake
	#${WORKDIR}/${PN}build-${PV}/utils/fpcm/fpcmake"
	#fpcbuild-3.0.0/fpcsrc/utils/fpcm/bin/x86_64-linux/fpcmake
	set -- PP="${pp}" FPCMAKE="${S}/utils/fpcm/bin/${FPC_PARCH}-linux/fpcmake" \
		INSTALL_PREFIX="${ED}"/usr \
		INSTALL_DOCDIR="${ED}"/usr/share/doc/${PF} \
		INSTALL_MANDIR="${ED}"/usr/share/man \
		INSTALL_SOURCEDIR="${ED}"/usr/lib/fpc/${PV}/source

	emake "$@" compiler_install rtl_install packages_install utils_install

	dosym ../lib/fpc/${PV}/ppc${FPC_ARCH} /usr/bin/ppc${FPC_ARCH}

	emake -C "${S}"/../install/doc "$@" installdoc
	emake -C "${S}"/../install/man "$@" installman

	use doc && dodoc -r "${S}"/../../doc/.

	if use source ; then
		shift
		emake PP="${ED}"/usr/bin/ppc${FPC_ARCH} "$@" sourceinstall
		find "${ED}"/usr/lib/fpc/${PV}/source -name '*.o' -delete || die
	fi

	"${ED}"/usr/lib/fpc/${PV}/samplecfg "${ED}"/usr/lib/fpc/${PV} "${ED}"/etc || die

	# set correct (prefixed) path for e.g. unit files
	sed -i "s:${ED}:${EPREFIX}:g" "${ED}"/etc/fpc.cfg || die

	sed -e "s:${ED}::g" \
		-i "${ED}"/etc/fppkg.cfg \
		-i "${ED}"/etc/fppkg/default \
		-i "${ED}"/usr/lib/fpc/${PV}/ide/text/fp.cfg \
		|| die

	rm -r "${ED}"/usr/lib/fpc/lexyacc || die

	case ${ARCH} in
		arm64)
			mkdir -p "${ED}"/usr/$(get_libdir) || die
			mv "${ED}"/usr/lib/*.so "${ED}/usr/$(get_libdir)/" || die
			;;
	esac
}

pkg_postinst() {
	if [[ -z ${REPLACING_VERSIONS} ]] && ! use doc; then
		elog "To read the documentation in the fpc IDE, enable the doc USE flag"
	fi
}
________________________
Comment 5 Norayr Chilingarian 2021-10-16 18:36:43 UTC
Created attachment 745185 [details]
fpc-3.2.2 ebuild that builds on aarch64
Comment 6 Norayr Chilingarian 2021-10-16 18:37:15 UTC
now i am commiting not dirty, normal ebuild that builds on x86_64, x86, aarch64.
Comment 7 Norayr Chilingarian 2021-10-16 18:38:40 UTC
Created attachment 745209 [details, diff]
patch for current fpc-3.2.2 ebuild to build fpc-3.2.2 on aarch64
Comment 8 Norayr Chilingarian 2021-10-16 18:40:11 UTC
the only line i doubt is i am not sure amd64|arm64 condition is necessary in the following segment:

_______________

    case ${ARCH} in
        amd64|arm64)
            mkdir -p "${ED}"/usr/$(get_libdir) || die
            mv "${ED}"/usr/lib/*.so "${ED}/usr/$(get_libdir)/" || die
            ;;
    esac
_________________
Comment 9 Norayr Chilingarian 2021-10-16 18:46:54 UTC
(In reply to Cănărău Constantin from comment #3)
> fpc-3.2.2, and probably 3.2.0, are incompatible with glibc-2.34 on arm64.
> See: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295

firstly, on my fully updated system i have only glibc-2.33.7,
secondly, it's interesting, because fpc runtime doesn't depend on glibc at all - they use kernel calls directly.

afaik the only exception when the glibc is used is threading unit.
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-10-17 01:04:08 UTC
(In reply to Norayr Chilingarian from comment #9)
> (In reply to Cănărău Constantin from comment #3)
> > fpc-3.2.2, and probably 3.2.0, are incompatible with glibc-2.34 on arm64.
> > See: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
> 
> firstly, on my fully updated system i have only glibc-2.33.7,
> secondly, it's interesting, because fpc runtime doesn't depend on glibc at
> all - they use kernel calls directly.
> 
> afaik the only exception when the glibc is used is threading unit.

It's still noteworthy if it doesn't work on arm64, but ideally someone could file a different bug for that and we'll block the glibc-2.34 tracker (not yet keyworded).
Comment 11 Larry the Git Cow gentoo-dev 2021-10-17 01:04:23 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=974a887b1c22104da459eefeef15d73799df65af

commit 974a887b1c22104da459eefeef15d73799df65af
Author:     Norayr Chilingarian <norayr@arnet.am>
AuthorDate: 2021-10-17 01:03:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-10-17 01:03:38 +0000

    dev-lang/fpc: add (~)arm64 support to 3.2.2
    
    Closes: https://bugs.gentoo.org/817899
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-lang/fpc/Manifest         |  1 +
 dev-lang/fpc/fpc-3.2.2.ebuild | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-10-17 01:04:34 UTC
*** Bug 802717 has been marked as a duplicate of this bug. ***