META MODE: Fix 'make bootstrap-tools'.

The main problem was bitrot after elftoolchain being swapped in for the
GNU toolchain.

This also reworks how the list of 'host allowed' libraries is determined
to only allow INTERNALLIBs, which is needed for libelftc to come in.

For usr.bin/readelf use the same hack, as libelf and libdward, to bring in
the needed sys/ headers for host builds.  This has not yet been a problem due
to readelf not being built as a host tool in buildworld.  This is possible
in the meta build though when building the toolchain.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
bdrewery 2015-11-25 19:44:51 +00:00
parent 52255645fb
commit cbc5242afd
12 changed files with 74 additions and 43 deletions

View File

@ -76,7 +76,7 @@ SRCS= \
INCS= dwarf.h libdwarf.h
#
# This same hack is in lib/libelf/Makefile and usr.bin/readelf/Makefile
# We need to link against the correct version of these files. One
# solution is to include ../../sys in the include path. This causes
# problems when a header file in sys depends on a file in another

View File

@ -65,7 +65,7 @@ SRCS= elf.c \
INCS= libelf.h gelf.h
#
# This same hack is in lib/libdwarf/Makefile and usr.bin/readelf/Makefile
# We need to link against the correct version of these files. One
# solution is to include ../../sys in the include path. This causes
# problems when a header file in sys depends on a file in another

View File

@ -7,7 +7,6 @@ DIRDEPS = \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/clang/include.host \
lib/libc \
lib/libcompiler_rt \
lib/libthr \

View File

@ -2,9 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/usr.bin/binutils/ld \
gnu/usr.bin/binutils/nm \
usr.bin/xinstall \
.include <dirdeps.mk>

View File

@ -28,15 +28,20 @@ DIRDEPS_FILTER+= N*.host
.for m in host common
M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
.endfor
#.info M_dep_qual_fixes=${M_dep_qual_fixes}
# we want to supress these dependencies for host tools
# but some libs are sadly needed.
_need_host_libs= \
lib/libc++ \
lib/libcxxrt \
lib/libdwarf \
lib/libmd \
# Cheat for including src.libnames.mk
__<bsd.init.mk>__:
# Pull in _INTERNALLIBS
.include <src.libnames.mk>
# Host libraries should mostly be excluded from the build so the
# host version in /usr/lib is used. Internal libraries need to be
# allowed to be built though since they are never installed.
_need_host_libs=
.for lib in ${_INTERNALLIBS}
_need_host_libs+= ${LIB${lib:tu}DIR:S,^${ROOTOBJDIR}/,,}
.endfor
N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
DIRDEPS_FILTER.host = \

View File

@ -14,6 +14,7 @@ GENDIRDEPS_FILTER+= \
Ntargets/pseudo/stage* \
Ntools/*
# Exclude toolchain which is handled special.
.if ${RELDIR:Mtargets*} == ""
.if ${RELDIR:Nusr.bin/clang/*:Ngnu/usr.bin/cc/*:Nlib/clang*} != ""
GENDIRDEPS_FILTER.host+= \
@ -22,7 +23,17 @@ GENDIRDEPS_FILTER.host+= \
.endif
GENDIRDEPS_FILTER+= \
Nlib/clang/include.host \
Nusr.bin/addr2line.host \
Nusr.bin/ar.host \
Nusr.bin/clang/clang.host \
Nusr.bin/elfcopy.host \
Nusr.bin/elfdump.host \
Nusr.bin/nm.host \
Nusr.bin/readelf.host \
Nusr.bin/size.host \
Nusr.bin/strings.host \
Nusr.bin/strip.host \
Ngnu/usr.bin/cc* \
Ngnu/usr.bin/binutils*.host \

View File

@ -7,6 +7,9 @@
.error src.libnames.mk cannot be included directly.
.endif
.if !target(__<src.libnames.mk>__)
__<src.libnames.mk>__:
.include <src.opts.mk>
.if ${.OBJDIR:S,${.CURDIR},,} != ${.OBJDIR}
@ -368,3 +371,4 @@ LIBBSNMPTOOLS?= ${LIBBSNMPTOOLSDIR}/libbsnmptools.a
LIBAMUDIR= ${ROOTOBJDIR}/usr.sbin/amd/libamu
LIBAMU?= ${LIBAMUDIR}/libamu/libamu.a
.endif # !target(__<src.libnames.mk>__)

View File

@ -62,7 +62,7 @@ cross-tools build-tools bootstrap-tools: .MAKE .META
touch $@
# MAKELEVEL=0 so that dirdeps.mk does its thing
# LEGACY_TOOLS lets us use the bootstaped stuff above
# LEGACY_TOOLS lets us use the bootstrapped stuff above
# TARGET* is so that MK_CLANG gets set correctly.
BSTCENV= \
MAKELEVEL=0 \

View File

@ -5,44 +5,26 @@
.if !defined(MK_CLANG)
.include "${SRCTOP}/share/mk/src.opts.mk"
.endif
DIRDEPS=
.if ${MK_TOOLCHAIN} == "yes"
DIRDEPS+= \
DIRDEPS= \
gnu/usr.bin/binutils/as \
gnu/usr.bin/binutils/ld \
usr.bin/addr2line \
usr.bin/cxxflit \
usr.bin/ar \
usr.bin/cxxfilt \
usr.bin/elfcopy \
usr.bin/elfdump \
usr.bin/nm \
usr.bin/readelf \
usr.bin/size \
usr.bin/strip \
usr.bin/strings \
.else
DIRDEPS+= \
gnu/usr.bin/binutils/addr2line \
gnu/usr.bin/binutils/nm \
gnu/usr.bin/binutils/readelf \
gnu/usr.bin/binutils/size \
gnu/usr.bin/binutils/strip \
gnu/usr.bin/binutils/strings \
.endif
DIRDEPS+= \
usr.bin/strip \
usr.bin/xinstall \
gnu/usr.bin/binutils/ar \
gnu/usr.bin/binutils/as \
gnu/usr.bin/binutils/ld \
gnu/usr.bin/binutils/objcopy \
gnu/usr.bin/binutils/objdump \
gnu/usr.bin/binutils/ranlib \
.if ${MK_CLANG} == "yes"
.if ${MK_CLANG_BOOTSTRAP} == "yes"
DIRDEPS+= targets/pseudo/clang
.endif
.if ${MK_GCC} == "yes"
.if ${MK_GCC_BOOTSTRAP} == "yes"
DIRDEPS+= targets/pseudo/gcc
.endif

View File

@ -0,0 +1,20 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libelf \
lib/libelftc \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -6,9 +6,23 @@ READELFDIR= ${ELFTCDIR}/readelf
.PATH: ${READELFDIR}
PROG= readelf
SRCS= readelf.c
LIBADD= dwarf elftc elf
CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common
# This same hack is in lib/libelf/Makefile and lib/libdward/Makefile
# We need to link against the correct version of these files. One
# solution is to include ../../sys in the include path. This causes
# problems when a header file in sys depends on a file in another
# part of the tree, e.g. a machine dependent header.
#
SRCS+= sys/elf32.h sys/elf64.h sys/elf_common.h
CLEANDIRS= sys
CFLAGS+= -I.
sys/elf32.h sys/elf64.h sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA
mkdir -p ${.OBJDIR}/sys
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>

View File

@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/usr.bin/binutils/ld \
lib/libmd \