For reliable builds, gnu/usr.bin/binutils/Makefile needs similar to gnu/usr.bin/binutils/Makefile.inc0 TARGET_CPUARCH use, not ${TARGET} use

Mark Millard marklmi at yahoo.com
Wed Jan 1 05:58:43 UTC 2020


My cross-build attempts were failing to build
ld.bfd for use for building LIB32 for powerpc64
until I made the following change:


# svnlite diff gnu/usr.bin/binutils/Makefile
Index: gnu/usr.bin/binutils/Makefile
===================================================================
--- gnu/usr.bin/binutils/Makefile	(revision 356187)
+++ gnu/usr.bin/binutils/Makefile	(working copy)
@@ -15,7 +15,16 @@
 # GNU binutils 2.17.50 ld.
 # Except if we are on powerpc, that needs the ld from binutils to link
 # 32-bit binaries.
-.if ${MK_LLD_IS_LD} == "no" || ${TARGET} == "powerpc"
+#
+# Localized variation of some gnu/usr.bin/binutils/Makefile.inc0
+# content:
+.if defined(TARGET_ARCH)
+HACK_TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
+.else
+HACK_TARGET_CPUARCH=${MACHINE_CPUARCH}
+.endif
+#
+.if ${MK_LLD_IS_LD} == "no" || ${HACK_TARGET_CPUARCH} == "powerpc"
 SUBDIR.${MK_BINUTILS}+=ld
 .endif
 

Otherwise, gnu/usr.bin/binutils/ld/Makefile was not used
to build ld.bfd and the build ending up stopping, reporting
the lack of anything at the path it specified to clang for
executing the 32-bit linker.

(No place else under gnu/ was using ${TARGET} . Many
places were using ${MACHINE_CPUARCH} . But straight use
of ${MACHINE_CPUARCH} here did not work for the context.
Thus, I went for the more general code from Makefile.inc0
instead, reusing what others had already figured out.)

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ppc mailing list