2 Commitit 91b84c98f1 ... df1fef79c6

Tekijä SHA1 Viesti Päivämäärä
  k4be df1fef79c6 Fix __call_main 1 kuukausi sitten
  k4be e783c8561c cross-avr/avr-libc: local bump to 2.3.2 for avrxmega3 device support 1 kuukausi sitten

+ 1 - 0
cross-avr/avr-libc/Manifest

@@ -0,0 +1 @@
+DIST avr-libc-2.3.2.tar.bz2 11303422 BLAKE2B 766546962425bef2b4960c8e46d8d7d0ef34a5880bf3cf071468fa714e501ae66b59a925b5146633df41f46911ff8cdb44f44099fe747569a50f0e3c10243e5c SHA512 cd38bc9a25bfbebfbbcf9691246e6a84d7b43769d42f3a3586cf7a4038cd2ff95b9fb235500c9adcbd6613468f54e9b36400f2c6275b5390a873ad806a806283

+ 110 - 0
cross-avr/avr-libc/avr-libc-2.3.2.ebuild

@@ -0,0 +1,110 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+CHOST="avr"
+CTARGET="avr"
+
+inherit flag-o-matic
+
+DESCRIPTION="C library for Atmel AVR microcontrollers"
+HOMEPAGE="https://github.com/avrdudes/avr-libc https://www.nongnu.org/avr-libc/"
+
+# Upstream moved from Savannah to GitHub with 2.2.0.  The GitHub "release"
+# tarball ships a pre-generated ./configure and the avr/{lib,devices} trees
+# (mlib-gen.py output), so no bootstrap / autotools / python is needed to
+# build it.  Manual pages are no longer a separate download; they are built
+# from the tree only when doxygen is present, which we do not pull in.
+MY_TAG="avr-libc-$(ver_rs 1- '_')-release"
+SRC_URI="https://github.com/avrdudes/avr-libc/releases/download/${MY_TAG}/${P}.tar.bz2"
+
+LICENSE="BSD"
+SLOT="0"
+# 'amd64' is a blessed placeholder for crossdev. It could
+# be any other arch. See bug #620316#c5
+# Don't add more arches to KEYWORDS.
+KEYWORDS="amd64"
+IUSE="headers-only"
+
+DEPEND=">=sys-devel/crossdev-0.9.1"
+[[ ${CATEGORY/cross-} != ${CATEGORY} ]] \
+	&& RDEPEND="!dev-embedded/avr-libc" \
+	|| RDEPEND=""
+
+DOCS="AUTHORS NEWS NEWS.md README.md"
+
+pkg_setup() {
+	# check for avr-gcc, bug #134738
+	ebegin "Checking for avr-gcc"
+	if type -p avr-gcc > /dev/null ; then
+		eend 0
+	else
+		eend 1
+
+		eerror
+		eerror "Failed to locate 'avr-gcc' in \$PATH. You can install an AVR toolchain using:"
+		eerror "  $ crossdev -t avr"
+		eerror
+		die "AVR toolchain not found"
+	fi
+}
+
+src_prepare() {
+	default
+
+	# work around broken gcc versions PR45261: drop MCUs the installed
+	# avr-gcc does not know about so ./configure does not choke on them.
+	local mcu
+	for mcu in $(sed -r -n '/CHECK_AVR_DEVICE/{s:.*[(](.*)[)]:\1:;p}' configure.ac) ; do
+		if avr-gcc -E - -mmcu=${mcu} <<<"" |& grep -q 'unknown MCU' ; then
+			sed -i "/HAS_${mcu}=yes/s:yes:no:" configure || die
+		fi
+	done
+
+	strip-flags
+	strip-unsupported-flags
+}
+
+src_configure() {
+	# --enable-device-lib builds the per-device lib<mcu>.a / crt<mcu>.o.
+	# It is on by default with avr-gcc >= 5.1 but be explicit.  Docs are
+	# off by default in 2.2+; keep them off (no doxygen dependency).
+	econf \
+		--host=avr \
+		--enable-device-lib \
+		--disable-doc
+}
+
+src_install() {
+	default
+
+	# Make sure different cross-compilers don't collide #414075
+	if [[ -d ${ED}/usr/share/doc/${PF} ]] ; then
+		mv "${ED}"/usr/share/doc/{${PF},${CTARGET}-${PF}} || die
+	fi
+
+	# https://github.com/avrdudes/avr-libc/issues/1060 documents that,
+	# since avr-libc 2.3.0, crt<mcu>.o only *declares* `main` as a
+	# referenced symbol so the linker is supposed to pull in
+	# __call_main (which actually calls main()+exit()) from
+	# lib<mcu>.a's call_main.o.  In practice a plain `.global main` in
+	# crt<mcu>.o is satisfied directly by the user's own main() and
+	# never triggers extraction of call_main.o, so .init9 stays empty
+	# and the reset vector falls straight through into __bad_interrupt
+	# (jmp 0) -- main() is never called and the device does nothing.
+	# Work around this by forcing `-u __call_main` on every link via a
+	# small specs file dropped next to avr-gcc's own specs; this is a
+	# no-op for pre-2.3.0-style self-contained crt objects.
+	local gccdir
+	gccdir=$(avr-gcc -print-search-dirs | sed -n 's/^install: //p') || die
+	[[ -d ${gccdir} ]] || die "could not determine avr-gcc install dir"
+
+	local specs="${T}/specs"
+	avr-gcc -dumpspecs > "${specs}" || die
+	sed -i '/^\*lib:$/{n;s/$/ -u __call_main/}' "${specs}" || die
+	grep -q -- '-u __call_main' "${specs}" || die "failed to patch *lib spec"
+
+	insinto "${gccdir#${EPREFIX}}"
+	newins "${specs}" specs
+}

+ 18 - 0
cross-avr/avr-libc/metadata.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>k4be@pirc.pl</email>
+		<name>k4be</name>
+	</maintainer>
+	<longdescription>
+		Local bump of cross-avr/avr-libc to 2.3.x.  The version in ::gentoo
+		(2.1.0) predates avr-libc 2.2.0, which is the first release to ship
+		the tinyAVR 0/1/2-series and megaAVR-0 (avrxmega3) device headers,
+		startup code and device libraries.  Without this the crossdev avr
+		toolchain cannot build for parts like the ATtiny3217.
+	</longdescription>
+	<upstream>
+		<remote-id type="github">avrdudes/avr-libc</remote-id>
+	</upstream>
+</pkgmetadata>

+ 1 - 0
profiles/categories

@@ -1,4 +1,5 @@
 app-text
+cross-avr
 dev-util
 sys-kernel
 sys-power