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 via freebsd-toolchain <[email protected]>
Newsgroups gmane.os.freebsd.devel.toolchain,gmane.os.freebsd.devel.ppc
Message-ID <[email protected]>
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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.