gentoo-ebuilds/dev-lang/micropython/micropython-1.23.0.ebuild
Z. Liu fec7440bc4
dev-lang/micropython: fix build issue using mold
remove link option "--cref" because mold doesn't support

not all files were patched, but the compilation & tests succeeded.

Closes: https://bugs.gentoo.org/937354
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42654
Closes: https://github.com/gentoo/gentoo/pull/42654
Signed-off-by: Sam James <sam@gentoo.org>
2025-06-22 10:46:37 +01:00

82 lines
1.7 KiB
Bash

# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit toolchain-funcs
DESCRIPTION="Python implementation for microcontrollers"
HOMEPAGE="https://micropython.org https://github.com/micropython/micropython"
SRC_URI="https://micropython.org/resources/source/${P}.tar.xz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~x86"
IUSE="test"
RESTRICT="!test? ( test )"
DEPEND="
dev-libs/libffi:=
virtual/pkgconfig
"
PATCHES=(
"${FILESDIR}/${P}-gcc13-build-fix.patch"
)
src_prepare() {
default
tc-ld-is-mold && {
# mold doesn't support --cref, bug #937354
find . -name Makefile -exec sed -r \
-e 's:map,--cref\s:map :g' \
-e 's:\s(-Wl,)?--cref(\s|$): :g' \
-i {} + || die
}
cd ports/unix || die
# 1) don't die on compiler warning
# 2) remove /usr/local prefix references in favour of /usr
# 3) enforce our CFLAGS
# 4) enforce our LDFLAGS
sed -e 's#-Werror##g;' \
-e 's#\/usr\/local#\/usr#g;' \
-e "s#^CFLAGS = \(.*\)#CFLAGS = \1 ${CFLAGS}#g" \
-e "s#^LDFLAGS = \(.*\)#LDFLAGS = \1 ${LDFLAGS}#g" \
-i Makefile || die "can't patch Makefile"
}
src_compile() {
# Build the cross-compiler first. Build fails without this.
einfo ""
einfo "Building the mpy-crosscompiler."
einfo ""
cd "${S}/mpy-cross" || die
emake CC="$(tc-getCC)"
# Finally, build the unix port.
einfo ""
einfo "Building the micropython unix port."
einfo ""
cd "${S}/ports/unix" || die
emake CC="$(tc-getCC)"
}
src_test() {
cd ports/unix || die
emake CC="$(tc-getCC)" test
}
src_install() {
pushd ports/unix > /dev/null || die
emake CC="$(tc-getCC)" DESTDIR="${D}" install
popd > /dev/null || die
# remove .git files
find tools -type f -name '.git*' -exec rm {} \; || die
dodoc -r tools
einstalldocs
}