diff --git a/cddl/contrib/opensolaris/tools/ctf/common/ctf_headers.h b/cddl/contrib/opensolaris/tools/ctf/common/ctf_headers.h index b00b8fd9a650..ca66b9bf5486 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/ctf_headers.h +++ b/cddl/contrib/opensolaris/tools/ctf/common/ctf_headers.h @@ -1,72 +1,72 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _CTF_HEADERS_H #define _CTF_HEADERS_H #pragma ident "%Z%%M% %I% %E% SMI" /* * Because the ON tools are executed on the system where they are built, * the tools need to include the headers installed on the build system, * rather than those in the ON source tree. However, some of the headers * required by the tools are part of the ON source tree, but not delivered * as part of Solaris. These include the following: * * $(SRC)/lib/libctf/common/libctf.h * $(SRC)/uts/common/sys/ctf_api.h * $(SRC)/uts/common/sys/ctf.h * * These headers get installed in the proto area in the build environment * under $(ROOT)/usr/include and $(ROOT)/usr/include/sys. Though these * headers are not part of the release, in releases including and prior to * Solaris 9, they did get installed on the build system via bfu. Therefore, * we can not simply force the order of inclusion with -I/usr/include first * in Makefile.ctf because we might actually get downlevel versions of the * ctf headers. Depending on the order of the -I includes, we can also have * a problem with mismatched headers when building the ctf tools with some * headers getting pulled in from /usr/include and others from * $(SRC)/uts/common/sys. * * To address the problem, we have done two things: * 1) Created this header with a specific order of inclusion for the * ctf headers. Because the header includes * which in turn includes we need to include these in * reverse order to guarantee that we get the correct versions of * the headers. * 2) In $(SRC)/tools/ctf/Makefile.ctf, we order the -I includes such * that we first search the directories where the ctf headers * live, followed by /usr/include, followed by $(SRC)/uts/common. * This last -I include is needed in order to prevent a build failure * when is included via a nested #include rather than * an explicit path #include. */ -#include +#include #include #include #endif /* _CTF_HEADERS_H */ diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile index 26ff06b46c40..05b183215f4c 100644 --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -1,145 +1,144 @@ # $FreeBSD$ .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/common .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libgen/common PACKAGE= dtrace LIB= dtrace SRCS= dt_aggregate.c \ dt_as.c \ dt_buf.c \ dt_cc.c \ dt_cg.c \ dt_consume.c \ dt_decl.c \ dt_dis.c \ dt_dof.c \ dt_error.c \ dt_errtags.c \ dt_grammar.y \ dt_handle.c \ dt_ident.c \ dt_isadep.c \ dt_inttab.c \ dt_lex.l \ dt_link.c \ dt_list.c \ dt_map.c \ dt_module.c \ dt_names.c \ dt_open.c \ dt_options.c \ dt_parser.c \ dt_pcb.c \ dt_pid.c \ dt_pq.c \ dt_pragma.c \ dt_print.c \ dt_printf.c \ dt_proc.c \ dt_program.c \ dt_provider.c \ dt_regset.c \ dt_string.c \ dt_strtab.c \ dt_subr.c \ dt_sugar.c \ dt_work.c \ dt_xlator.c \ gmatch.c DSRCS= errno.d \ io.d \ ip.d \ psinfo.d \ sctp.d \ siftr.d \ signal.d \ tcp.d \ socket.d \ udp.d \ udplite.d \ unistd.d FILES= ${DSRCS} FILESDIR= /usr/lib/dtrace FILESMODE= ${NOBINMODE} INCSGROUPS= INCS SYSINCS SYSINCSDIR= ${INCLUDEDIR}/sys INCS+= ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h -SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h WARNS?= 1 CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -I${.OBJDIR} -I${.CURDIR} \ -I${SRCTOP}/sys/cddl/dev/dtrace/${MACHINE_ARCH} \ -I${SRCTOP}/sys/cddl/compat/opensolaris \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common #CFLAGS+= -DYYDEBUG .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/aarch64 .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/aarch64 .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/aarch64 .elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" CFLAGS+= -I${SRCTOP}/sys/cddl/dev/dtrace/x86 CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel -DDIS_MEM .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/i386 .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/${MACHINE_ARCH} .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/x86 .elif ${MACHINE_CPUARCH} == "arm" CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/arm .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/arm .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/arm .elif ${MACHINE_CPUARCH} == "mips" CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/mips .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/mips .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/mips .elif ${MACHINE_CPUARCH} == "powerpc" CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/powerpc .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/powerpc .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/powerpc .elif ${MACHINE_CPUARCH} == "riscv" CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/riscv .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/riscv .PATH: ${SRCTOP}/sys/cddl/dev/dtrace/riscv .else # temporary hack CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel .endif .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" SRCS+= dis_tables.c DSRCS+= regs_x86.d .endif YFLAGS+=-d LIBADD= ctf elf proc pthread rtld_db CLEANFILES= dt_errtags.c dt_names.c .include dt_errtags.c: ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/dt_errtags.h sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mkerrtags.sh < ${.ALLSRC} > ${.TARGET} dt_names.c: ${OPENSOLARIS_SYS_DISTDIR}/uts/common/sys/dtrace.h sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mknames.sh < ${.ALLSRC} > ${.TARGET} diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h b/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h deleted file mode 100644 index 528814118e1c..000000000000 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h +++ /dev/null @@ -1,360 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _CTF_H -#define _CTF_H - -#ifdef illumos -#pragma ident "%Z%%M% %I% %E% SMI" -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * CTF - Compact ANSI-C Type Format - * - * This file format can be used to compactly represent the information needed - * by a debugger to interpret the ANSI-C types used by a given program. - * Traditionally, this kind of information is generated by the compiler when - * invoked with the -g flag and is stored in "stabs" strings or in the more - * modern DWARF format. CTF provides a representation of only the information - * that is relevant to debugging a complex, optimized C program such as the - * operating system kernel in a form that is significantly more compact than - * the equivalent stabs or DWARF representation. The format is data-model - * independent, so consumers do not need different code depending on whether - * they are 32-bit or 64-bit programs. CTF assumes that a standard ELF symbol - * table is available for use in the debugger, and uses the structure and data - * of the symbol table to avoid storing redundant information. The CTF data - * may be compressed on disk or in memory, indicated by a bit in the header. - * CTF may be interpreted in a raw disk file, or it may be stored in an ELF - * section, typically named .SUNW_ctf. Data structures are aligned so that - * a raw CTF file or CTF ELF section may be manipulated using mmap(2). - * - * The CTF file or section itself has the following structure: - * - * +--------+--------+---------+----------+-------+--------+ - * | file | type | data | function | data | string | - * | header | labels | objects | info | types | table | - * +--------+--------+---------+----------+-------+--------+ - * - * The file header stores a magic number and version information, encoding - * flags, and the byte offset of each of the sections relative to the end of the - * header itself. If the CTF data has been uniquified against another set of - * CTF data, a reference to that data also appears in the the header. This - * reference is the name of the label corresponding to the types uniquified - * against. - * - * Following the header is a list of labels, used to group the types included in - * the data types section. Each label is accompanied by a type ID i. A given - * label refers to the group of types whose IDs are in the range [0, i]. - * - * Data object and function records are stored in the same order as they appear - * in the corresponding symbol table, except that symbols marked SHN_UNDEF are - * not stored and symbols that have no type data are padded out with zeroes. - * For each data object, the type ID (a small integer) is recorded. For each - * function, the type ID of the return type and argument types is recorded. - * - * The data types section is a list of variable size records that represent each - * type, in order by their ID. The types themselves form a directed graph, - * where each node may contain one or more outgoing edges to other type nodes, - * denoted by their ID. - * - * Strings are recorded as a string table ID (0 or 1) and a byte offset into the - * string table. String table 0 is the internal CTF string table. String table - * 1 is the external string table, which is the string table associated with the - * ELF symbol table for this object. CTF does not record any strings that are - * already in the symbol table, and the CTF string table does not contain any - * duplicated strings. - * - * If the CTF data has been merged with another parent CTF object, some outgoing - * edges may refer to type nodes that exist in another CTF object. The debugger - * and libctf library are responsible for connecting the appropriate objects - * together so that the full set of types can be explored and manipulated. - */ - -#define CTF_MAX_TYPE 0xffff /* max type identifier value */ -#define CTF_MAX_NAME 0x7fffffff /* max offset into a string table */ -#define CTF_MAX_VLEN 0x3ff /* max struct, union, enum members or args */ -#define CTF_MAX_INTOFF 0xff /* max offset of intrinsic value in bits */ -#define CTF_MAX_INTBITS 0xffff /* max size of an intrinsic in bits */ - -/* See ctf_type_t */ -#define CTF_MAX_SIZE 0xfffe /* max size of a type in bytes */ -#define CTF_LSIZE_SENT 0xffff /* sentinel for ctt_size */ -#define CTF_MAX_LSIZE UINT64_MAX - -typedef struct ctf_preamble { - ushort_t ctp_magic; /* magic number (CTF_MAGIC) */ - uchar_t ctp_version; /* data format version number (CTF_VERSION) */ - uchar_t ctp_flags; /* flags (see below) */ -} ctf_preamble_t; - -typedef struct ctf_header { - ctf_preamble_t cth_preamble; - uint_t cth_parlabel; /* ref to name of parent lbl uniq'd against */ - uint_t cth_parname; /* ref to basename of parent */ - uint_t cth_lbloff; /* offset of label section */ - uint_t cth_objtoff; /* offset of object section */ - uint_t cth_funcoff; /* offset of function section */ - uint_t cth_typeoff; /* offset of type section */ - uint_t cth_stroff; /* offset of string section */ - uint_t cth_strlen; /* length of string section in bytes */ -} ctf_header_t; - -#define cth_magic cth_preamble.ctp_magic -#define cth_version cth_preamble.ctp_version -#define cth_flags cth_preamble.ctp_flags - -#ifdef CTF_OLD_VERSIONS - -typedef struct ctf_header_v1 { - ctf_preamble_t cth_preamble; - uint_t cth_objtoff; - uint_t cth_funcoff; - uint_t cth_typeoff; - uint_t cth_stroff; - uint_t cth_strlen; -} ctf_header_v1_t; - -#endif /* CTF_OLD_VERSIONS */ - -#define CTF_MAGIC 0xcff1 /* magic number identifying header */ - -/* data format version number */ -#define CTF_VERSION_1 1 -#define CTF_VERSION_2 2 -#define CTF_VERSION CTF_VERSION_2 /* current version */ - -#define CTF_F_COMPRESS 0x1 /* data buffer is compressed */ - -typedef struct ctf_lblent { - uint_t ctl_label; /* ref to name of label */ - uint_t ctl_typeidx; /* last type associated with this label */ -} ctf_lblent_t; - -typedef struct ctf_stype { - uint_t ctt_name; /* reference to name in string table */ - ushort_t ctt_info; /* encoded kind, variant length (see below) */ - union { - ushort_t _size; /* size of entire type in bytes */ - ushort_t _type; /* reference to another type */ - } _u; -} ctf_stype_t; - -/* - * type sizes, measured in bytes, come in two flavors. 99% of them fit within - * (USHRT_MAX - 1), and thus can be stored in the ctt_size member of a - * ctf_stype_t. The maximum value for these sizes is CTF_MAX_SIZE. The sizes - * larger than CTF_MAX_SIZE must be stored in the ctt_lsize member of a - * ctf_type_t. Use of this member is indicated by the presence of - * CTF_LSIZE_SENT in ctt_size. - */ -typedef struct ctf_type { - uint_t ctt_name; /* reference to name in string table */ - ushort_t ctt_info; /* encoded kind, variant length (see below) */ - union { - ushort_t _size; /* always CTF_LSIZE_SENT */ - ushort_t _type; /* do not use */ - } _u; - uint_t ctt_lsizehi; /* high 32 bits of type size in bytes */ - uint_t ctt_lsizelo; /* low 32 bits of type size in bytes */ -} ctf_type_t; - -#define ctt_size _u._size /* for fundamental types that have a size */ -#define ctt_type _u._type /* for types that reference another type */ - -/* - * The following macros compose and decompose values for ctt_info and - * ctt_name, as well as other structures that contain name references. - * - * ------------------------ - * ctt_info: | kind | isroot | vlen | - * ------------------------ - * 15 11 10 9 0 - * - * kind = CTF_INFO_KIND(c.ctt_info); <-- CTF_K_* value (see below) - * vlen = CTF_INFO_VLEN(c.ctt_info); <-- length of variable data list - * - * stid = CTF_NAME_STID(c.ctt_name); <-- string table id number (0 or 1) - * offset = CTF_NAME_OFFSET(c.ctt_name); <-- string table byte offset - * - * c.ctt_info = CTF_TYPE_INFO(kind, vlen); - * c.ctt_name = CTF_TYPE_NAME(stid, offset); - */ - -#define CTF_INFO_KIND(info) (((info) & 0xf800) >> 11) -#define CTF_INFO_ISROOT(info) (((info) & 0x0400) >> 10) -#define CTF_INFO_VLEN(info) (((info) & CTF_MAX_VLEN)) - -#define CTF_NAME_STID(name) ((name) >> 31) -#define CTF_NAME_OFFSET(name) ((name) & 0x7fffffff) - -#define CTF_TYPE_INFO(kind, isroot, vlen) \ - (((kind) << 11) | (((isroot) ? 1 : 0) << 10) | ((vlen) & CTF_MAX_VLEN)) - -#define CTF_TYPE_NAME(stid, offset) \ - (((stid) << 31) | ((offset) & 0x7fffffff)) - -#define CTF_TYPE_ISPARENT(id) ((id) < 0x8000) -#define CTF_TYPE_ISCHILD(id) ((id) > 0x7fff) - -#define CTF_TYPE_TO_INDEX(id) ((id) & 0x7fff) -#define CTF_INDEX_TO_TYPE(id, child) ((child) ? ((id) | 0x8000) : (id)) -#define CTF_PARENT_SHIFT 15 - -#define CTF_STRTAB_0 0 /* symbolic define for string table id 0 */ -#define CTF_STRTAB_1 1 /* symbolic define for string table id 1 */ - -#define CTF_TYPE_LSIZE(cttp) \ - (((uint64_t)(cttp)->ctt_lsizehi) << 32 | (cttp)->ctt_lsizelo) -#define CTF_SIZE_TO_LSIZE_HI(size) ((uint32_t)((uint64_t)(size) >> 32)) -#define CTF_SIZE_TO_LSIZE_LO(size) ((uint32_t)(size)) - -#ifdef CTF_OLD_VERSIONS - -#define CTF_INFO_KIND_V1(info) (((info) & 0xf000) >> 12) -#define CTF_INFO_ISROOT_V1(info) (((info) & 0x0800) >> 11) -#define CTF_INFO_VLEN_V1(info) (((info) & 0x07ff)) - -#define CTF_TYPE_INFO_V1(kind, isroot, vlen) \ - (((kind) << 12) | (((isroot) ? 1 : 0) << 11) | ((vlen) & 0x07ff)) - -#endif /* CTF_OLD_VERSIONS */ - -/* - * Values for CTF_TYPE_KIND(). If the kind has an associated data list, - * CTF_INFO_VLEN() will extract the number of elements in the list, and - * the type of each element is shown in the comments below. - */ -#define CTF_K_UNKNOWN 0 /* unknown type (used for padding) */ -#define CTF_K_INTEGER 1 /* variant data is CTF_INT_DATA() (see below) */ -#define CTF_K_FLOAT 2 /* variant data is CTF_FP_DATA() (see below) */ -#define CTF_K_POINTER 3 /* ctt_type is referenced type */ -#define CTF_K_ARRAY 4 /* variant data is single ctf_array_t */ -#define CTF_K_FUNCTION 5 /* ctt_type is return type, variant data is */ - /* list of argument types (ushort_t's) */ -#define CTF_K_STRUCT 6 /* variant data is list of ctf_member_t's */ -#define CTF_K_UNION 7 /* variant data is list of ctf_member_t's */ -#define CTF_K_ENUM 8 /* variant data is list of ctf_enum_t's */ -#define CTF_K_FORWARD 9 /* no additional data; ctt_name is tag */ -#define CTF_K_TYPEDEF 10 /* ctt_type is referenced type */ -#define CTF_K_VOLATILE 11 /* ctt_type is base type */ -#define CTF_K_CONST 12 /* ctt_type is base type */ -#define CTF_K_RESTRICT 13 /* ctt_type is base type */ - -#define CTF_K_MAX 31 /* Maximum possible CTF_K_* value */ - -/* - * Values for ctt_type when kind is CTF_K_INTEGER. The flags, offset in bits, - * and size in bits are encoded as a single word using the following macros. - */ -#define CTF_INT_ENCODING(data) (((data) & 0xff000000) >> 24) -#define CTF_INT_OFFSET(data) (((data) & 0x00ff0000) >> 16) -#define CTF_INT_BITS(data) (((data) & 0x0000ffff)) - -#define CTF_INT_DATA(encoding, offset, bits) \ - (((encoding) << 24) | ((offset) << 16) | (bits)) - -#define CTF_INT_SIGNED 0x01 /* integer is signed (otherwise unsigned) */ -#define CTF_INT_CHAR 0x02 /* character display format */ -#define CTF_INT_BOOL 0x04 /* boolean display format */ -#define CTF_INT_VARARGS 0x08 /* varargs display format */ - -/* - * Values for ctt_type when kind is CTF_K_FLOAT. The encoding, offset in bits, - * and size in bits are encoded as a single word using the following macros. - */ -#define CTF_FP_ENCODING(data) (((data) & 0xff000000) >> 24) -#define CTF_FP_OFFSET(data) (((data) & 0x00ff0000) >> 16) -#define CTF_FP_BITS(data) (((data) & 0x0000ffff)) - -#define CTF_FP_DATA(encoding, offset, bits) \ - (((encoding) << 24) | ((offset) << 16) | (bits)) - -#define CTF_FP_SINGLE 1 /* IEEE 32-bit float encoding */ -#define CTF_FP_DOUBLE 2 /* IEEE 64-bit float encoding */ -#define CTF_FP_CPLX 3 /* Complex encoding */ -#define CTF_FP_DCPLX 4 /* Double complex encoding */ -#define CTF_FP_LDCPLX 5 /* Long double complex encoding */ -#define CTF_FP_LDOUBLE 6 /* Long double encoding */ -#define CTF_FP_INTRVL 7 /* Interval (2x32-bit) encoding */ -#define CTF_FP_DINTRVL 8 /* Double interval (2x64-bit) encoding */ -#define CTF_FP_LDINTRVL 9 /* Long double interval (2x128-bit) encoding */ -#define CTF_FP_IMAGRY 10 /* Imaginary (32-bit) encoding */ -#define CTF_FP_DIMAGRY 11 /* Long imaginary (64-bit) encoding */ -#define CTF_FP_LDIMAGRY 12 /* Long double imaginary (128-bit) encoding */ - -#define CTF_FP_MAX 12 /* Maximum possible CTF_FP_* value */ - -typedef struct ctf_array { - ushort_t cta_contents; /* reference to type of array contents */ - ushort_t cta_index; /* reference to type of array index */ - uint_t cta_nelems; /* number of elements */ -} ctf_array_t; - -/* - * Most structure members have bit offsets that can be expressed using a - * short. Some don't. ctf_member_t is used for structs which cannot - * contain any of these large offsets, whereas ctf_lmember_t is used in the - * latter case. If ctt_size for a given struct is >= 8192 bytes, all members - * will be stored as type ctf_lmember_t. - */ - -#define CTF_LSTRUCT_THRESH 8192 - -typedef struct ctf_member { - uint_t ctm_name; /* reference to name in string table */ - ushort_t ctm_type; /* reference to type of member */ - ushort_t ctm_offset; /* offset of this member in bits */ -} ctf_member_t; - -typedef struct ctf_lmember { - uint_t ctlm_name; /* reference to name in string table */ - ushort_t ctlm_type; /* reference to type of member */ - ushort_t ctlm_pad; /* padding */ - uint_t ctlm_offsethi; /* high 32 bits of member offset in bits */ - uint_t ctlm_offsetlo; /* low 32 bits of member offset in bits */ -} ctf_lmember_t; - -#define CTF_LMEM_OFFSET(ctlmp) \ - (((uint64_t)(ctlmp)->ctlm_offsethi) << 32 | (ctlmp)->ctlm_offsetlo) -#define CTF_OFFSET_TO_LMEMHI(offset) ((uint32_t)((uint64_t)(offset) >> 32)) -#define CTF_OFFSET_TO_LMEMLO(offset) ((uint32_t)(offset)) - -typedef struct ctf_enum { - uint_t cte_name; /* reference to name in string table */ - int cte_value; /* value associated with this name */ -} ctf_enum_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _CTF_H */ diff --git a/sys/sys/ctf.h b/sys/sys/ctf.h new file mode 100644 index 000000000000..e6a806143d51 --- /dev/null +++ b/sys/sys/ctf.h @@ -0,0 +1,214 @@ +/* $OpenBSD: ctf.h,v 1.5 2017/08/13 14:56:05 nayden Exp $ */ + +/*- + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2016 Martin Pieuchot + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_CTF_H_ +#define _SYS_CTF_H_ + +#include + +/* + * CTF ``Compact ANSI-C Type Format'' ABI header file. + * + * See the ctf(5) manual page for a detailed description of the format. + */ + +typedef struct ctf_preamble { + __uint16_t ctp_magic; + __uint8_t ctp_version; + __uint8_t ctp_flags; +} ctf_preamble_t; + +typedef struct ctf_header { + struct ctf_preamble cth_preamble; +#define cth_magic cth_preamble.ctp_magic +#define cth_version cth_preamble.ctp_version +#define cth_flags cth_preamble.ctp_flags + __uint32_t cth_parlabel; + __uint32_t cth_parname; + __uint32_t cth_lbloff; + __uint32_t cth_objtoff; + __uint32_t cth_funcoff; + __uint32_t cth_typeoff; + __uint32_t cth_stroff; + __uint32_t cth_strlen; +} ctf_header_t; + +#define CTF_F_COMPRESS (1 << 0) /* zlib compression */ + +typedef struct ctf_lblent { + __uint32_t ctl_label; + __uint32_t ctl_typeidx; +} ctf_lblent_t; + +typedef struct ctf_stype { + __uint32_t ctt_name; + __uint16_t ctt_info; + union { + __uint16_t _size; + __uint16_t _type; + } _u; +} ctf_stype_t; + +typedef struct ctf_type { + __uint32_t ctt_name; + __uint16_t ctt_info; + union { + __uint16_t _size; + __uint16_t _type; + } _u; + __uint32_t ctt_lsizehi; + __uint32_t ctt_lsizelo; +} ctf_type_t; + +#define ctt_size _u._size +#define ctt_type _u._type + +typedef struct ctf_array { + __uint16_t cta_contents; + __uint16_t cta_index; + __uint32_t cta_nelems; +} ctf_array_t; + +typedef struct ctf_member { + __uint32_t ctm_name; + __uint16_t ctm_type; + __uint16_t ctm_offset; +} ctf_member_t; + +typedef struct ctf_lmember { + __uint32_t ctlm_name; + __uint16_t ctlm_type; + __uint16_t ctlm_pad; + __uint32_t ctlm_offsethi; + __uint32_t ctlm_offsetlo; +} ctf_lmember_t; + +#define CTF_LSTRUCT_THRESH 8192 + +typedef struct ctf_enum { + __uint32_t cte_name; + __int32_t cte_value; +} ctf_enum_t; + +#define CTF_MAGIC 0xcff1 +#define CTF_VERSION CTF_VERSION_2 +#define CTF_VERSION_2 2 +#define CTF_VERSION_1 1 + +#define CTF_MAX_NAME 0x7fffffff +#define CTF_MAX_VLEN 0x03ff +#define CTF_MAX_SIZE 0xfffe +#define CTF_LSIZE_SENT (CTF_MAX_SIZE + 1) /* sentinel for cts vs ctt */ + +#define CTF_PARENT_SHIFT 15 +#define CTF_MAX_TYPE 0xffff +#define CTF_TYPE_ISPARENT(id) ((id) < 0x8000) +#define CTF_TYPE_ISCHILD(id) ((id) > 0x7fff) +#define CTF_TYPE_TO_INDEX(t) ((t) & 0x7fff) +#define CTF_INDEX_TO_TYPE(t, c) (((t) & 0x7fff) | ((c) != 0 ? 0x8000 : 0)) + +#define CTF_TYPE_INFO(k, r, l) \ + ((k) << 11) | ((r) != 0 ? (1 << 10) : 0) | ((l) & ((1 << 10) - 1)) + +#define CTF_STRTAB_0 0 +#define CTF_STRTAB_1 1 + +#define CTF_TYPE_NAME(t, o) (((t) << 31) | ((o) & ((1u << 31) - 1))) + +/* + * Info macro. + */ +#define CTF_INFO_VLEN(i) (((i) & CTF_MAX_VLEN)) +#define CTF_INFO_ISROOT(i) (((i) & 0x0400) >> 10) +#define CTF_INFO_KIND(i) (((i) & 0xf800) >> 11) +#define CTF_K_UNKNOWN 0 +#define CTF_K_INTEGER 1 +#define CTF_K_FLOAT 2 +#define CTF_K_POINTER 3 +#define CTF_K_ARRAY 4 +#define CTF_K_FUNCTION 5 +#define CTF_K_STRUCT 6 +#define CTF_K_UNION 7 +#define CTF_K_ENUM 8 +#define CTF_K_FORWARD 9 +#define CTF_K_TYPEDEF 10 +#define CTF_K_VOLATILE 11 +#define CTF_K_CONST 12 +#define CTF_K_RESTRICT 13 +#define CTF_K_MAX 31 + +/* + * Integer/Float Encoding macro. + */ +#define _CTF_ENCODING(e) (((e) & 0xff000000) >> 24) +#define _CTF_OFFSET(e) (((e) & 0x00ff0000) >> 16) +#define _CTF_BITS(e) (((e) & 0x0000ffff)) +#define _CTF_DATA(encoding, offset, bits) \ + (((encoding) << 24) | ((offset) << 16) | (bits)) + +#define CTF_INT_ENCODING(e) _CTF_ENCODING(e) +#define CTF_INT_SIGNED (1 << 0) +#define CTF_INT_CHAR (1 << 1) +#define CTF_INT_BOOL (1 << 2) +#define CTF_INT_VARARGS (1 << 3) +#define CTF_INT_OFFSET(e) _CTF_OFFSET(e) +#define CTF_INT_BITS(e) _CTF_BITS(e) +#define CTF_INT_DATA(e, o, b) _CTF_DATA(e, o, b) + +#define CTF_FP_ENCODING(e) _CTF_ENCODING(e) +#define CTF_FP_SINGLE 1 +#define CTF_FP_DOUBLE 2 +#define CTF_FP_CPLX 3 +#define CTF_FP_DCPLX 4 +#define CTF_FP_LDCPLX 5 +#define CTF_FP_LDOUBLE 6 +#define CTF_FP_INTRVL 7 +#define CTF_FP_DINTRVL 8 +#define CTF_FP_LDINTRVL 9 +#define CTF_FP_IMAGRY 10 +#define CTF_FP_DIMAGRY 11 +#define CTF_FP_LDIMAGRY 12 +#define CTF_FP_OFFSET(e) _CTF_OFFSET(e) +#define CTF_FP_BITS(e) _CTF_BITS(e) +#define CTF_FP_DATA(e, o, b) _CTF_DATA(e, o, b) + +/* + * Name reference macro. + */ +#define CTF_NAME_STID(n) ((n) >> 31) +#define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME) + +/* + * Type macro. + */ +#define CTF_SIZE_TO_LSIZE_HI(s) ((uint32_t)((uint64_t)(s) >> 32)) +#define CTF_SIZE_TO_LSIZE_LO(s) ((uint32_t)(s)) +#define CTF_TYPE_LSIZE(t) \ + (((uint64_t)(t)->ctt_lsizehi) << 32 | (t)->ctt_lsizelo) + +/* + * Member macro. + */ +#define CTF_LMEM_OFFSET(m) \ + (((__uint64_t)(m)->ctlm_offsethi) << 32 | (m)->ctlm_offsetlo) +#define CTF_OFFSET_TO_LMEMHI(off) ((__uint32_t)((__uint64_t)(off) >> 32)) +#define CTF_OFFSET_TO_LMEMLO(off) ((__uint32_t)(off)) + +#endif /* _SYS_CTF_H_ */ diff --git a/tools/build/Makefile b/tools/build/Makefile index b1dca0c9314c..00f5e3e45337 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -1,373 +1,374 @@ # $FreeBSD$ .PATH: ${.CURDIR}/../../include LIB= egacy SRC= INCSGROUPS= INCS SYSINCS CASPERINC UFSINCS FFSINCS MSDOSFSINCS DISKINCS INCSGROUPS+= MACHINESYSINCS RPCINCS INCS= SYSINCSDIR= ${INCLUDEDIR}/sys CASPERINCDIR= ${INCLUDEDIR}/casper # Also add ufs/ffs/msdosfs/disk headers to allow building makefs as a bootstrap tool UFSINCSDIR= ${INCLUDEDIR}/ufs/ufs FFSINCSDIR= ${INCLUDEDIR}/ufs/ffs MSDOSFSINCSDIR= ${INCLUDEDIR}/fs/msdosfs DISKINCSDIR= ${INCLUDEDIR}/sys/disk MACHINESYSINCSDIR= ${INCLUDEDIR}/machine RPCINCSDIR= ${INCLUDEDIR}/rpc BOOTSTRAPPING?= 0 .if ${.MAKE.OS} == "Darwin" _XCODE_ROOT!=xcode-select -p # since macOS 10.14 C headers are no longer installed in /usr but only # provided via the SDK .if ${_XCODE_ROOT} == "/Library/Developer/CommandLineTools" # Only command line tools installed -> host headers are in the SDKs directory _MACOS_SDK_DIR=${_XCODE_ROOT}/SDKs/MacOSX.sdk/ .else # Full XCode installed -> host headers are below Platforms/MacOSX.platform _MACOS_SDK_DIR=${_XCODE_ROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk .endif HOST_INCLUDE_ROOT=${_MACOS_SDK_DIR}/usr/include .if !exists(${HOST_INCLUDE_ROOT}/stdio.h) .error You must install the macOS SDK (try xcode-select --install) .endif .else HOST_INCLUDE_ROOT=/usr/include .endif # Allow building libc-internal files (also on non-FreeBSD hosts) CFLAGS+= -I${.CURDIR}/libc-bootstrap # Symbol versioning is not required for -legacy (and macOS bootstrap) MK_SYMVER= no _WITH_PWCACHEDB!= grep -c pwcache_groupdb ${HOST_INCLUDE_ROOT}/grp.h || true .if ${_WITH_PWCACHEDB} == 0 .PATH: ${.CURDIR}/../../contrib/libc-pwcache CFLAGS.pwcache.c+= -I${.CURDIR}/../../contrib/libc-pwcache SRCS+= pwcache.c .endif _WITH_STRSVIS!= grep -c strsvis ${HOST_INCLUDE_ROOT}/vis.h 2>/dev/null || true .if ${_WITH_STRSVIS} == 0 .PATH: ${.CURDIR}/../../contrib/libc-vis INCS+= vis.h SRCS+= vis.c unvis.c CFLAGS.vis.c+= -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 -DHAVE_SVIS=0 CFLAGS.unvis.c+= -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 -DHAVE_SVIS=0 .endif _WITH_REALLOCARRAY!= grep -c reallocarray ${HOST_INCLUDE_ROOT}/stdlib.h || true .if ${_WITH_REALLOCARRAY} == 0 .PATH: ${.CURDIR}/../../lib/libc/stdlib INCS+= stdlib.h SRCS+= reallocarray.c .endif _WITH_UTIMENS!= grep -c utimensat ${HOST_INCLUDE_ROOT}/sys/stat.h || true .if ${_WITH_UTIMENS} == 0 SYSINCS+= stat.h SRCS+= futimens.c utimensat.c .endif _WITH_EXPLICIT_BZERO!= grep -c explicit_bzero ${HOST_INCLUDE_ROOT}/strings.h || true .if ${_WITH_EXPLICIT_BZERO} == 0 # .PATH: ${SRCTOP}/sys/libkern # Adding sys/libkern to .PATH breaks building the cross-build compat library # since that attempts to build strlcpy.c from libc and adding libkern here will # cause it to pick the file from libkern instead (which won't compile). # Avoid modifying .PATH by creating a copy in the build directory instead. explicit_bzero.c: ${SRCTOP}/sys/libkern/explicit_bzero.c cp ${.ALLSRC} ${.TARGET} CLEANFILES+= explicit_bzero.c INCS+= strings.h SRCS+= explicit_bzero.c .endif _WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true .if ${_WITH_FSPACECTL} == 0 INCS+= fcntl.h SRCS+= fspacectl.c .endif .if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) _WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true _WITH_CAPH_RIGHTS_LIMIT!= grep -c caph_rights_limit ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true .endif .if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0 || ${_WITH_CAPH_RIGHTS_LIMIT} == 0 .PATH: ${SRCTOP}/lib/libcapsicum INCS+= capsicum_helpers.h .PATH: ${SRCTOP}/lib/libcasper/libcasper INCS+= libcasper.h .endif # rpcgen should build against the source tree rpc/types.h and not the host. # This is especially important on non-FreeBSD systems where the types may # not match. RPCINCS+= ${SRCTOP}/sys/rpc/types.h INCS+= ${SRCTOP}/include/mpool.h INCS+= ${SRCTOP}/include/ndbm.h INCS+= ${SRCTOP}/include/err.h INCS+= ${SRCTOP}/include/stringlist.h # Needed to build arc4random.c INCSGROUPS+= CHACHA20INCS CHACHA20INCSDIR= ${INCLUDEDIR}/crypto/chacha20 CHACHA20INCS+= ${SRCTOP}/sys/crypto/chacha20/_chacha.h \ ${SRCTOP}/sys/crypto/chacha20/chacha.h _host_arch=${MACHINE} .if ${_host_arch} == "x86_64" # bmake on Linux/mac often prints that instead of amd64 _host_arch=amd64 .elif ${_host_arch} == "aarch64" # Linux calls arm64, aarch64, across the board _host_arch=arm64 .elif ${_host_arch:Mppc*} _host_arch=powerpc .endif .if ${_host_arch} == "unknown" # HACK: If MACHINE is unknown, assume we are building on x86 _host_arch=amd64 .endif MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/elf.h .if ${_host_arch} == "amd64" || ${_host_arch} == "i386" INCSGROUPS+= X86INCS X86INCSDIR= ${INCLUDEDIR}/x86 X86INCS+= ${SRCTOP}/sys/x86/include/elf.h .endif # needed for btxld: MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/exec.h MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/reloc.h INCS+= ${SRCTOP}/include/a.out.h INCS+= ${SRCTOP}/include/nlist.h SYSINCS+= ${SRCTOP}/sys/sys/imgact_aout.h SYSINCS+= ${SRCTOP}/sys/sys/nlist_aout.h .if ${.MAKE.OS} != "FreeBSD" .PATH: ${.CURDIR}/cross-build # dbopen() behaves differently on Linux and FreeBSD so we ensure that we # bootstrap the FreeBSD db code. The cross-build headers #define dbopen() to # __freebsd_dbopen() so that we don't ever use the host version INCS+= ${SRCTOP}/include/db.h LIBC_SRCTOP= ${SRCTOP}/lib/libc/ .include "${LIBC_SRCTOP}/db/Makefile.inc" # Do the same as we did for dbopen() for getopt() on since it's not compatible # on Linux (and to avoid surprises also compile the FreeBSD code on macOS) .PATH: ${LIBC_SRCTOP}/stdlib SRCS+= getopt.c getopt_long.c INCS+= ${SRCTOP}/include/getopt.h # getcap.c is needed for cap_mkdb: .PATH: ${LIBC_SRCTOP}/gen SRCS+= getcap.c # Glibc does not provide all err*/warn* functions, and for macOS we need the # alias with the extra underscore. SRCS+= err.c # Add various libbc functions that are not available in glibc: SRCS+= stringlist.c setmode.c SRCS+= strtonum.c merge.c heapsort.c reallocf.c .PATH: ${LIBC_SRCTOP}/locale SRCS+= rpmatch.c .if ${.MAKE.OS} == "Linux" # On Linux, glibc does not provide strlcpy,strlcat or strmode. .PATH: ${LIBC_SRCTOP}/string SRCS+= strlcpy.c strlcat.c strmode.c # Compile the fgetln/fgetwln/closefrom fallback code from libbsd: SRCS+= fgetln_fallback.c fgetwln_fallback.c closefrom.c CFLAGS.closefrom.c+= -DSTDC_HEADERS -DHAVE_SYS_DIR_H -DHAVE_DIRENT_H \ -DHAVE_DIRFD -DHAVE_SYSCONF # Provide getprogname/setprograme SRCS+= progname.c # Stub implementations of fflagstostr/strtofflags SRCS+= fflags.c .endif # Provide the same arc4random implementation on Linux/macOS CFLAGS.arc4random.c+= -I${SRCTOP}/sys/crypto/chacha20 -D__isthreaded=1 SRCS+= arc4random.c arc4random_uniform.c # expand_number() is not provided by either Linux or MacOS libutil .PATH: ${SRCTOP}/lib/libutil SRCS+= expand_number.c # Linux libutil also doesn't have fparseln SRCS+= fparseln.c # A dummy sysctl for tzsetup: SRCS+= fake_sysctl.c # capsicum support SYSINCS+= ${SRCTOP}/sys/sys/capsicum.h SYSINCS+= ${SRCTOP}/sys/sys/caprights.h SRCS+= capsicum_stubs.c # XXX: we can't add ${SRCTOP}/sys/kern to .PATH since that will causes # conflicts with other files. Instead copy subr_capability to the build dir. subr_capability.c: ${SRCTOP}/sys/kern/subr_capability.c cp ${.ALLSRC} ${.TARGET} SRCS+= subr_capability.c CLEANFILES+= subr_capability.c .endif CASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h CASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_net/cap_net.h .if empty(SRCS) SRCS= dummy.c .endif .if defined(CROSS_BUILD_TESTING) SUBDIR= cross-build .endif # To allow bootstrapping makefs on FreeBSD 11 or non-FreeBSD systems: UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dinode.h UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dir.h FFSINCS+= ${SRCTOP}/sys/ufs/ffs/fs.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bootsect.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bpb.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/denode.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/direntry.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/fat.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h # Needed to build config (since it uses libnv) SYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \ ${SRCTOP}/sys/sys/dnv.h # Needed when bootstrapping ldd (since it uses DF_1_PIE) SYSINCS+= ${SRCTOP}/sys/sys/elf32.h SYSINCS+= ${SRCTOP}/sys/sys/elf64.h SYSINCS+= ${SRCTOP}/sys/sys/elf_common.h SYSINCS+= ${SRCTOP}/sys/sys/elf_generic.h SYSINCS+= ${SRCTOP}/sys/sys/queue.h SYSINCS+= ${SRCTOP}/sys/sys/md5.h SYSINCS+= ${SRCTOP}/sys/sys/sbuf.h SYSINCS+= ${SRCTOP}/sys/sys/tree.h # vtfontcvt is using sys/font.h SYSINCS+= ${SRCTOP}/sys/sys/font.h # For mkscrfil.c: SYSINCS+= ${SRCTOP}/sys/sys/consio.h # for gencat: INCS+= ${SRCTOP}/include/nl_types.h # for vtfontcvt: SYSINCS+= ${SRCTOP}/sys/sys/fnv_hash.h # opensolaris compatibility INCS+= ${SRCTOP}/include/elf.h SYSINCS+= ${SRCTOP}/sys/sys/elf.h +SYSINCS+= ${SRCTOP}/sys/sys/ctf.h # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't # accidentally run tools that are incompatible but happen to be in $PATH. # This is especially important when building on Linux/MacOS where many of the # programs used during the build accept different flags or generate different # output. On those platforms we only symlink the tools known to be compatible # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others # from the FreeBSD sources during the bootstrap-tools stage. # basic commands: It is fine to use the host version for all of these even on # Linux/MacOS since we only use flags that are supported by all of them. _host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date dd \ dirname echo env false find fmt gzip gunzip head hostname id ln ls \ mkdir mv nice patch rm sh sleep stat tee time touch tr true uname uniq \ unxz wc which xz # We also need a symlink to the absolute path to the make binary used for # the toplevel makefile. This is not necessarily the same as `which make` # since e.g. on Linux and MacOS that will be GNU make. _make_abs!= which "${MAKE}" _host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake .if ${.MAKE.OS} == "FreeBSD" # When building on FreeBSD we always copy the host tools instead of linking # into WORLDTMP to avoid issues with incompatible libraries (see r364030). # Note: we could create links if we don't intend to update the current machine. _COPY_HOST_TOOL=cp -pf .else # However, this is not necessary on Linux/macOS. Additionally, copying the host # tools to another directory with cp -p results in freezes on macOS Big Sur for # some unknown reason. It can also break building inside docker containers if # there are ACLs on shared volumes. _COPY_HOST_TOOL=ln -sfn _make_abs!= which "${MAKE}" _host_abs_tools_to_symlink+= ${_make_abs}:make ${_make_abs}:bmake .if ${.MAKE.OS} == "Darwin" # /usr/bin/cpp may invoke xcrun: _host_tools_to_symlink+=xcrun .endif # ${.MAKE.OS} == "Darwin" # On Ubuntu /bin/sh is dash which is totally useless. Let's just link bash # as the build sh since that will work fine. _host_abs_tools_to_symlink+= /bin/bash:sh _host_tools_to_symlink:=${_host_tools_to_symlink:Nsh} .endif host-symlinks: @echo "Linking host tools into ${DESTDIR}/bin" .for _tool in ${_host_tools_to_symlink} @export PATH=$${PATH}:/usr/local/bin; \ source_path=`which ${_tool} || echo /dev/null/no/such`; \ if [ ! -e "$${source_path}" ] ; then \ echo "Cannot find host tool '${_tool}' in PATH ($$PATH)." >&2; false; \ fi; \ rm -f "${DESTDIR}/bin/${_tool}"; \ ${_COPY_HOST_TOOL} "$${source_path}" "${DESTDIR}/bin/${_tool}" .endfor .for _tool in ${_host_abs_tools_to_symlink} @source_path="${_tool:S/:/ /:[1]}"; \ target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \ if [ ! -e "$${source_path}" ] ; then \ echo "Host tool '$${source_path}' is missing"; false; \ fi; \ rm -f "$${target_path}"; \ ${_COPY_HOST_TOOL} "$${source_path}" "$${target_path}" .endfor .if exists(/usr/libexec/flua) rm -f ${DESTDIR}/usr/libexec/flua ${_COPY_HOST_TOOL} /usr/libexec/flua ${DESTDIR}/usr/libexec/flua .endif # Create all the directories that are needed during the legacy, bootstrap-tools # and cross-tools stages. We do this here using mkdir since mtree may not exist # yet (this happens if we are crossbuilding from Linux/Mac). INSTALLDIR_LIST= \ bin \ lib/casper \ lib/geom \ usr/include/casper \ usr/include/private/ucl \ usr/include/private/zstd \ usr/lib \ usr/libdata/pkgconfig \ usr/libexec installdirs: mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,} # Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a # bootstrap tool was added to WORLTMP with a symlink or by building it in the # bootstrap-tools phase. We could also overrride BINDIR when building bootstrap # tools but adding the symlinks is easier and means all tools are also # in the directory that they are installed to normally. .for _dir in sbin usr/sbin usr/bin # delete existing directories from before r340157 @if [ -e ${DESTDIR}/${_dir} ] && [ ! -L ${DESTDIR}/${_dir} ]; then \ echo "removing old non-symlink ${DESTDIR}/${_dir}"; \ rm -rf "${DESTDIR}/${_dir}"; \ fi .endfor ln -sfn bin ${DESTDIR}/sbin ln -sfn ../bin ${DESTDIR}/usr/bin ln -sfn ../bin ${DESTDIR}/usr/sbin .for _group in ${INCSGROUPS:NINCS} mkdir -p "${DESTDIR}/${${_group}DIR}" .endfor .include