k4be 2 тижнів тому
батько
коміт
df1fef79c6
1 змінених файлів з 24 додано та 0 видалено
  1. 24 0
      cross-avr/avr-libc/avr-libc-2.3.2.ebuild

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

@@ -83,4 +83,28 @@ src_install() {
 	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
 }