diff --git a/stand/defs.mk b/stand/defs.mk index f6c43ef7bd01..504493ebe648 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -1,265 +1,265 @@ .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} FORTIFY_SOURCE= 0 # We need to define all the MK_ options before including src.opts.mk # because it includes bsd.own.mk which needs the right MK_ values, # espeically MK_CTF. MK_CTF= no MK_SSP= no MK_PIE= no MK_ZEROREGS= no MAN= .if !defined(PIC) NO_PIC= INTERNALLIB= .endif # Should be NO_CPU_FLAGS, but bsd.cpu.mk is included too early in bsd.init.mk # via the early include of bsd.opts.mk. Moving Makefile.inc include earlier in # that file causes weirdness, so this is the next best thing. We need to do this # because the loader needs very specific flags to work right, and things like # CPUTYPE?=native prevent that, and introduce an endless game of whack-a-mole # to disable more and more features. Boot loader performance is never improved # enough to make that hassle worth chasing. _CPUCFLAGS= .if ${LDFLAGS:M-nostdlib} # Sanitizers won't work unless we link against libc (e.g. in userboot/test). MK_ASAN:= no MK_UBSAN:= no .endif .include .include WARNS?= 1 BOOTSRC= ${SRCTOP}/stand EDK2INC= ${SYSDIR}/contrib/edk2/Include EFISRC= ${BOOTSRC}/efi EFIINC= ${EFISRC}/include # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is # built 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here # and activate it when DO32 is explicitly defined to be 1. .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 EFIINCMD= ${EFIINC}/i386 .else EFIINCMD= ${EFIINC}/${MACHINE} .endif FDTSRC= ${BOOTSRC}/fdt FICLSRC= ${BOOTSRC}/ficl LDRSRC= ${BOOTSRC}/common LIBLUASRC= ${BOOTSRC}/liblua LIBOFWSRC= ${BOOTSRC}/libofw LUASRC= ${SRCTOP}/contrib/lua/src SASRC= ${BOOTSRC}/libsa +SAZFSSRC= ${SASRC}/zfs SYSDIR= ${SRCTOP}/sys UBOOTSRC= ${BOOTSRC}/uboot -ZFSSRC= ${SASRC}/zfs ZFSOSSRC= ${ZFSTOP}/module/os/freebsd/ ZFSOSINC= ${ZFSTOP}/include/os/freebsd LIBCSRC= ${SRCTOP}/lib/libc BOOTOBJ= ${OBJTOP}/stand # BINDIR is where we install BINDIR?= /boot # LUAPATH is where we search for and install lua scripts. LUAPATH?= /boot/lua FLUASRC?= ${SRCTOP}/libexec/flua FLUALIB?= ${SRCTOP}/libexec/flua LIBSA= ${BOOTOBJ}/libsa/libsa.a .if ${MACHINE} == "i386" LIBSA32= ${LIBSA} .else LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a .endif # Standard options: CFLAGS+= -nostdinc # Allow CFLAGS_EARLY.file/target so that code that needs specific stack # of include paths can set them up before our include paths. Normally # the only thing that should be there are -I directives, and as few of # those as possible. CFLAGS+= ${CFLAGS_EARLY} ${CFLAGS_EARLY.${.IMPSRC:T}} ${CFLAGS_EARLY.${.TARGET:T}} .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 CFLAGS+= -I${BOOTOBJ}/libsa32 .else CFLAGS+= -I${BOOTOBJ}/libsa .endif CFLAGS+= -I${SASRC} -D_STANDALONE CFLAGS+= -I${SYSDIR} # Spike the floating point interfaces CFLAGS+= -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" # Slim down the image. This saves about 15% in size with clang 6 on x86 # Our most constrained /boot/loader env is BIOS booting on x86, where # our text + data + BTX have to fit into 640k below the ISA hole. # Experience has shown that problems arise between ~520k to ~530k. CFLAGS.clang+= -Oz CFLAGS.gcc+= -Os CFLAGS+= -ffunction-sections -fdata-sections .endif # GELI Support, with backward compat hooks (mostly) .if defined(LOADER_NO_GELI_SUPPORT) MK_LOADER_GELI=no .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" .endif .if defined(LOADER_GELI_SUPPORT) MK_LOADER_GELI=yes .warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" .endif .if ${MK_LOADER_GELI} == "yes" CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -I${SASRC}/geli .endif # MK_LOADER_GELI # These should be confined to loader.mk, but can't because uboot/lib # also uses it. It's part of loader, but isn't a loader so we can't # just include loader.mk .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .endif # Machine specific flags for all builds here # Ensure PowerPC64 and PowerPC64LE boot loaders are compiled as 32 bit. # PowerPC64LE boot loaders are 32-bit little-endian. .if ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -m32 -mcpu=powerpc -mbig-endian .elif ${MACHINE_ARCH} == "powerpc64le" CFLAGS+= -m32 -mcpu=powerpc -mlittle-endian .endif .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 CFLAGS+= -m32 # LD_FLAGS is passed directly to ${LD}, not via ${CC}: LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 .endif # Add in the no float / no SIMD stuff and announce we're freestanding # aarch64 and riscv don't have -msoft-float, but all others do. CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only -ffixed-x18 -fPIC .elif ${MACHINE_CPUARCH} == "riscv" CFLAGS+= -march=rv64imac -mabi=lp64 -fPIC CFLAGS.clang+= -mcmodel=medium CFLAGS.gcc+= -mcmodel=medany .else CFLAGS+= -msoft-float .endif # -msoft-float seems to be insufficient for powerpcspe .if ${MACHINE_ARCH} == "powerpcspe" CFLAGS+= -mno-spe .endif .if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) CFLAGS+= -march=i386 CFLAGS.gcc+= -mpreferred-stack-boundary=2 .endif .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC -mno-red-zone .endif .if ${MACHINE_CPUARCH} == "arm" # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. CFLAGS.clang+= -mno-movt CFLAGS.clang+= -mfpu=none CFLAGS+= -fPIC .endif # Some RISC-V linkers have support for relaxations, while some (lld) do not # yet. If this is the case we inhibit the compiler from emitting relaxations. .if ${LINKER_FEATURES:Mriscv-relaxations} == "" CFLAGS+= -mno-relax .endif # The boot loader build uses dd status=none, where possible, for reproducible # build output (since performance varies from run to run). Trouble is that # option was recently (10.3) added to FreeBSD and is non-standard. Only use it # when this test succeeds rather than require dd to be a bootstrap tool. DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true DD=dd ${DD_NOSTATUS} # # Have a sensible default # .if ${MK_LOADER_LUA} == "yes" LOADER_DEFAULT_INTERP?=lua .elif ${MK_FORTH} == "yes" LOADER_DEFAULT_INTERP?=4th .else LOADER_DEFAULT_INTERP?=simp .endif LOADER_INTERP?=${LOADER_DEFAULT_INTERP} # Make sure we use the machine link we're about to create CFLAGS+=-I. .include "${BOOTSRC}/veriexec.mk" all: ${PROG} CLEANFILES+= teken_state.h teken.c: teken_state.h teken_state.h: ${SYSDIR}/teken/sequences awk -f ${SYSDIR}/teken/gensequences \ ${SYSDIR}/teken/sequences > teken_state.h .if !defined(NO_OBJ) _ILINKS=include/machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=include/${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _ILINKS+=include/x86 .endif CFLAGS+= -Iinclude CLEANDIRS+= include beforedepend: ${_ILINKS} beforebuild: ${_ILINKS} # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. .for _link in ${_ILINKS} .if !exists(${.OBJDIR}/${_link}) ${OBJS}: ${_link} .endif # _link exists .endfor .NOPATH: ${_ILINKS} ${_ILINKS}: .NOMETA @case ${.TARGET:T} in \ machine) \ if [ ${DO32:U0} -eq 0 ]; then \ path=${SYSDIR}/${MACHINE}/include ; \ else \ path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ fi ;; \ *) \ path=${SYSDIR}/${.TARGET:T}/include ;; \ esac ; \ case ${.TARGET} in \ */*) mkdir -p ${.TARGET:H};; \ esac ; \ path=`(cd $$path && /bin/pwd)` ; \ ${ECHO} ${.TARGET} "->" $$path ; \ ln -fns $$path ${.TARGET} .endif # !NO_OBJ .-include "local.defs.mk" .endif # __BOOT_DEFS_MK__ diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile index c9f04546b56b..17fa849beb0b 100644 --- a/stand/efi/boot1/Makefile +++ b/stand/efi/boot1/Makefile @@ -1,104 +1,104 @@ .include BOOT1?= boot1 PROG= ${BOOT1}.sym INTERNALPROG= WARNS?= 6 CFLAGS+= -DEFI_BOOT1 # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.proto.c += -Wno-format CWARNFLAGS.boot1.c += -Wno-format CWARNFLAGS.ufs_module.c += -Wno-format CWARNFLAGS.zfs_module.c += -Wno-format # Disable bogus alignment issues CWARNFLAGS.ufs_module.c += -Wno-cast-align # Disable warnings that are currently incompatible with the zfs boot code CWARNFLAGS.zfs_module.c += -Wno-array-bounds CWARNFLAGS.zfs_module.c += -Wno-cast-align CWARNFLAGS.zfs_module.c += -Wno-cast-qual CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes CWARNFLAGS.zfs_module.c += -Wno-sign-compare CWARNFLAGS.zfs_module.c += -Wno-unused-parameter CWARNFLAGS.zfs_module.c += -Wno-unused-function # architecture-specific loader code SRCS+= boot1.c proto.c self_reloc.c start.S ufs_module.c .if ${MK_LOADER_ZFS} != "no" SRCS+= zfs_module.c -CFLAGS.zfs_module.c+= -I${ZFSSRC} +CFLAGS.zfs_module.c+= -I${SAZFSSRC} CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 CFLAGS.zfs_module.c+= -include ${ZFSOSINC}/spl/sys/ccompile.h CFLAGS+= -DEFI_ZFS_BOOT .endif CFLAGS+= -I${EFIINC} -I${EDK2INC} CFLAGS+= -I${EFIINCMD} CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -DEFI_UFS_BOOT .ifdef(EFI_DEBUG) CFLAGS+= -DEFI_DEBUG .endif .include "${BOOTSRC}/veriexec.mk" # Always add MI sources and REGULAR efi loader bits .PATH: ${EFISRC}/loader/arch/${MACHINE} .PATH: ${EFISRC}/loader .PATH: ${LDRSRC} CFLAGS+= -I${LDRSRC} FILES= ${BOOT1}.efi FILESMODE_${BOOT1}.efi= ${BINMODE} LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/${MACHINE}.ldscript LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie .if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400 LDFLAGS+= -Wl,--no-dynamic-linker .endif .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .endif .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -fPIC LDFLAGS+= -Wl,-znocombreloc .endif LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a # # Add libsa for the runtime functions used by the compiler as well as required # string and memory functions for all platforms. # DPADD+= ${LIBEFI} ${LIBSA} LDADD+= ${LIBEFI} ${LIBSA} DPADD+= ${LDSCRIPT} CLEANFILES+= ${BOOT1}.efi ${BOOT1}.efi: ${PROG} @if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ ${EFI_OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} .include diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile index aaf9ef666fde..4f4586fbf253 100644 --- a/stand/efi/libefi/Makefile +++ b/stand/efi/libefi/Makefile @@ -1,72 +1,72 @@ .include LIB= efi WARNS?= 2 SRCS= delay.c \ devicename.c \ devpath.c \ efi_console.c \ efi_driver_utils.c \ efichar.c \ eficom.c \ efienv.c \ efihttp.c \ efinet.c \ efipart.c \ efizfs.c \ env.c \ errno.c \ handles.c \ libefi.c \ wchar.c .PATH: ${SYSDIR}/teken SRCS+= teken.c .if ${MACHINE_CPUARCH} == "amd64" SRCS+= time.c .elif ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv" SRCS+= time_event.c .elif ${MACHINE_CPUARCH} == "aarch64" SRCS+= time_arm64.c .endif # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.efinet.c+= -Wno-format CWARNFLAGS.efipart.c+= -Wno-format CWARNFLAGS.env.c+= -Wno-format .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .endif .if ${MACHINE_ARCH} == "amd64" CFLAGS+= -fPIC -mno-red-zone .endif CFLAGS+= -I${EFIINC} -I${EDK2INC} CFLAGS+= -I${EFIINCMD} CFLAGS.efi_console.c+= -I${SRCTOP}/sys/teken -I${SRCTOP}/contrib/pnglite CFLAGS.efi_console.c+= -I${.CURDIR}/../loader CFLAGS.teken.c+= -I${SRCTOP}/sys/teken .if ${MK_LOADER_ZFS} != "no" -CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SAZFSSRC} CFLAGS+= -I${SYSDIR}/cddl/boot/zfs CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common CFLAGS+= -DEFI_ZFS_BOOT .endif # Pick up the bootstrap header for some interface items CFLAGS+= -I${LDRSRC} # Handle FreeBSD specific %b and %D printf format specifiers CFLAGS+= ${FORMAT_EXTENSIONS} CFLAGS+= -DTERM_EMU .include "${BOOTSRC}/veriexec.mk" .include diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index 8000e2f6df7d..addb7652249d 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -1,154 +1,154 @@ LOADER_NET_SUPPORT?= yes LOADER_MSDOS_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= no LOADER_EXT2FS_SUPPORT?= no .include .if ${MACHINE} == "amd64" && ${DO32:U0} == 1 __arch= i386 LOADER?= loader_ia32 .else __arch= ${MACHINE} LOADER?= loader_${LOADER_INTERP} .endif PROG= ${LOADER}.sym INTERNALPROG= WARNS?= 3 # architecture-specific loader code SRCS= autoload.c \ bootinfo.c \ conf.c \ copy.c \ efi_main.c \ framebuffer.c \ main.c \ self_reloc.c \ vers.c \ gfx_fb.c \ 8x16.c SRCS+= acpi_detect.c .PATH: ${EFISRC}/acpica CFLAGS+= -I${EFISRC}/acpica/include CFLAGS+= -I${.CURDIR}/../loader .if ${MK_LOADER_ZFS} != "no" -CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SAZFSSRC} CFLAGS+= -I${SYSDIR}/contrib/openzfs/include CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs CFLAGS+= -DEFI_ZFS_BOOT HAVE_ZFS= yes .endif CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite CFLAGS.main.c += -I$(SRCTOP)/sys/teken CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.main.c+= -Wno-format .PATH: ${.CURDIR}/../loader .PATH: ${.CURDIR}/../loader/arch/${__arch} .include "${.CURDIR}/../loader/arch/${__arch}/Makefile.inc" CFLAGS+= -Wall CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}/arch/${__arch} CFLAGS+= -I${EFISRC}/include CFLAGS+= -I${EFISRC}/include/${__arch} CFLAGS+= -I${EDK2INC} CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -DEFI .if defined(HAVE_FDT) && ${MK_FDT} != "no" .include "${BOOTSRC}/fdt.mk" LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.a HELP_FILES+= ${FDTSRC}/help.fdt .endif # Include bcache code. HAVE_BCACHE= yes .if defined(EFI_STAGING_SIZE) CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} .endif .if ${MK_LOADER_EFI_SECUREBOOT} != "no" CFLAGS+= -DEFI_SECUREBOOT .endif NEWVERSWHAT?= "EFI loader" ${MACHINE} VERSION_FILE?= ${.CURDIR}/../loader/version HELP_FILENAME= loader.help.efi # Always add MI sources .include "${BOOTSRC}/loader.mk" CLEANFILES+= 8x16.c 8x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} FILES+= ${LOADER}.efi FILESMODE_${LOADER}.efi= ${BINMODE} .if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} && ${__arch} != "i386" LINKS+= ${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi .endif LDSCRIPT= ${.CURDIR}/../loader/arch/${__arch}/${__arch}.ldscript LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie .if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400 LDFLAGS+= -Wl,--no-dynamic-linker .endif .include .if ${LINKER_TYPE} == "lld" && ${LINKER_FREEBSD_VERSION} < 1500001 # When lld is using multiple threads, which it does by default, it can # result in non-reproducible output with the custom linker script. Work # around this by disabling threading. LDFLAGS+= -Wl,--threads=1 .endif CLEANFILES+= ${LOADER}.efi ${LOADER}.efi: ${PROG} @if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ ${EFI_OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ -j set_X${LOADER_INTERP}_compile_set \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a LIBEFI32= ${BOOTOBJ}/efi/libefi32/libefi.a .if ${__arch} == "i386" DPADD= ${LDR_INTERP32} ${LIBEFI32} ${LIBSA32} ${LDSCRIPT} LDADD= ${LDR_INTERP32} ${LIBEFI32} ${LIBSA32} .else DPADD= ${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT} LDADD= ${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA} .endif .include diff --git a/stand/i386/gptzfsboot/Makefile b/stand/i386/gptzfsboot/Makefile index ebdd4958c5f2..2b3b5422031b 100644 --- a/stand/i386/gptzfsboot/Makefile +++ b/stand/i386/gptzfsboot/Makefile @@ -1,82 +1,82 @@ .include .PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \ ${BOOTSRC}/i386/common \ ${BOOTSRC}/common FILES= gptzfsboot MAN= gptzfsboot.8 BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x0 CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \ -O1 \ -DBOOT2 \ -DLOADER_GPT_SUPPORT \ -DLOADER_MBR_SUPPORT \ -DLOADER_ZFS_SUPPORT \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386/libi386 \ - -I${ZFSSRC} \ + -I${SAZFSSRC} \ -I${SYSDIR}/crypto/skein \ -I${SYSDIR}/cddl/boot/zfs \ -I${SYSDIR}/contrib/openzfs/include \ -I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl \ -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs \ -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \ -I${BOOTSRC}/i386/btx/lib \ -I${BOOTSRC}/i386/boot2 \ -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib \ -Wall -Waggregate-return -Wbad-function-cast \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Wno-pointer-sign CFLAGS.clang+= -Wno-tentative-definition-incomplete-type NO_WCAST_ALIGN= CFLAGS.gcc+= --param max-inline-insns-single=100 \ --param min-pagesize=1024 LD_FLAGS+=${LD_FLAGS_BIN} CLEANFILES+= gptzfsboot gptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \ -o ${.TARGET} gptzfsboot.bin CLEANFILES+= gptldr.bin gptldr.out gptldr.o gptldr.bin: gptldr.out ${OBJCOPY} -S -O binary gptldr.out ${.TARGET} gptldr.out: gptldr.o ${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} gptldr.o OBJS= zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o misc.o CLEANFILES+= gptzfsboot.bin gptzfsboot.out ${OBJS} # i386 standalone support library LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a gptzfsboot.bin: gptzfsboot.out ${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET} gptzfsboot.out: ${BTXCRT} ${OBJS} ${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBI386} ${LIBSA32} -zfsboot.o: ${ZFSSRC}/zfsimpl.c +zfsboot.o: ${SAZFSSRC}/zfsimpl.c .include diff --git a/stand/kboot/kboot/Makefile b/stand/kboot/kboot/Makefile index 19bae09df5ea..68bb67096851 100644 --- a/stand/kboot/kboot/Makefile +++ b/stand/kboot/kboot/Makefile @@ -1,73 +1,73 @@ LOADER_DISK_SUPPORT?= yes LOADER_CD9660_SUPPORT?= yes LOADER_MSDOS_SUPPORT?= no LOADER_EXT2FS_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes LOADER_ZFS_SUPPORT?= yes LOADER_NET_SUPPORT?= no LOADER_NFS_SUPPORT?= no LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= no LOADER_BZIP2_SUPPORT?= no .include PROG= loader.kboot NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH} INSTALLFLAGS= -b # Architecture-specific loader code SRCS= \ bootinfo.c \ conf.c \ hostcons.c \ hostdisk.c \ hostfs.c \ init.c \ main.c \ vers.c .if ${MK_FDT} != "no" SRCS+= kbootfdt.c .endif .if ${MK_LOADER_ZFS} != "no" -CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SAZFSSRC} CFLAGS+= -I${SYSDIR}/contrib/openzfs/include CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs HAVE_ZFS=yes .endif HELP_FILENAME= loader.help.kboot .include "${BOOTSRC}/fdt.mk" # We share bootinfo.c with efi .PATH: ${BOOTSRC}/efi/loader # Note: Since we're producing a userland binary, we key off of MACHINE_ARCH # instead of the more normal MACHINE since the changes between different flavors # of MACHINE_ARCH are large enough in Linux that it's easier that way. .PATH: ${.CURDIR}/arch/${MACHINE_ARCH} .include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc" # Bring in our ldscript LDFLAGS= -nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}.ldscript # Always add MI sources .include "${BOOTSRC}/loader.mk" CFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH} CFLAGS+= -Wall DPADD= ${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT} LDADD= ${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT} # Add our own lua bindings until they are universal .if ${LOADER_INTERP} == "lua" SRCS+= \ lua_bindings.c CFLAGS.lua_bindings.c+= -I${FLUALIB}/libhash .endif .include diff --git a/stand/libsa/zfs/Makefile.inc b/stand/libsa/zfs/Makefile.inc index 5ecf68d3bc09..c747078a115b 100644 --- a/stand/libsa/zfs/Makefile.inc +++ b/stand/libsa/zfs/Makefile.inc @@ -1,84 +1,84 @@ -.PATH: ${ZFSSRC} +.PATH: ${SAZFSSRC} .PATH: ${SYSDIR}/crypto/skein .PATH: ${ZFSOSSRC}/spl .PATH: ${ZFSTOP}/module/zstd .PATH: ${ZFSTOP}/module/zstd/lib/common .PATH: ${ZFSTOP}/module/zstd/lib/compress .PATH: ${ZFSTOP}/module/zstd/lib/decompress .PATH: ${ZFSTOP}/module/icp/asm-aarch64/blake3 .PATH: ${ZFSTOP}/module/icp/algs/blake3 ZFS_SRC= zfs.c nvlist.c skein.c skein_block.c list.c ZFS_SRC+= zfs_zstd.c ZFS_SRC+= blake3.c blake3_generic.c blake3_impl.c ZSTD_SRC+= entropy_common.c error_private.c ZSTD_SRC+= fse_decompress.c hist.c ZSTD_SRC+= huf_decompress.c pool.c xxhash.c ZSTD_SRC+= zstd_common.c ZSTD_SRC+= zstd_ddict.c zstd_decompress.c zstd_decompress_block.c ZSTD_SRC+= zstd_double_fast.c zstd_fast.c zstd_lazy.c zstd_ldm.c SRCS+= ${ZFS_SRC} ${ZSTD_SRC} ${ZFS_SRC_AS} # # Any file that needs the FreeBSD overrides that are in # include/os/freebssd/spl/XXX needs to have these added to # CFLAGS_EARLY.file.c. In general, we try to build out of the OpenZFS tree # unaltered. There's a problem, though, that since we're building for a # standalone environment that's neither userland nor kernel, we sometimes need # special code and that's handled by the 'nested' includes where we either setup # something just-so before we include the include/XXX file, or if we need to # tweak something defined in that file. # -ZFS_EARLY= -I${ZFSSRC}/spl \ +ZFS_EARLY= -I${SAZFSSRC}/spl \ -I${ZFSOSINC} \ -I${ZFSOSINC}/spl \ -I${ZFSOSINC}/zfs # # For all files, though, we prepend the sys/ccompile.h file to the build which # has a bunch of defines that are present in OpenSolaris / Illumos, but missing # from FreeBSD. # .for i in ${ZFS_SRC} ${ZSTD_SRC} CFLAGS.$i+= -include ${ZFSOSINC}/spl/sys/ccompile.h -Wformat -Wall -I${ZFSTOP}/include \ -DNEED_SOLARIS_BOOLEAN .endfor CFLAGS_EARLY.blake3.c+= ${ZFS_EARLY} -DOMIT_SIMD CFLAGS_EARLY.blake3_generic.c+= ${ZFS_EARLY} -DOMIT_SIMD CFLAGS_EARLY.blake3_impl.c+= ${ZFS_EARLY} -DOMIT_SIMD CFLAGS_EARLY.list.c+= ${ZFS_EARLY} CFLAGS_EARLY.zfs_zstd.c+= ${ZFS_EARLY} CFLAGS_EARLY.nvlist.c+= ${ZFS_EARLY} CFLAGS_EARLY.zfs.c += ${ZFS_EARLY} # # zfs.c is special: we need to define HAS_ZSTD_ZFS to get zfssubr.c to initialize zstd # properly. We need to have the cddl boot compat directory in the include path for zfssubr.c # to be found, and we need a couple of other include paths for skein and lz4. Finally we # temporarily need LDRSRC to pick up part.h until libsa has a way to look into partitions # or enumerate them... # CFLAGS.zfs.c+= -DHAS_ZSTD_ZFS \ -I${SYSDIR}/cddl/boot/zfs \ -I${LDRSRC} \ -I${SYSDIR}/crypto/skein \ -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 # # ZSTD coding style has some issues, so suppress clang's warnings. Also, zstd's # use of BMI instrucitons is broken in this environment, so avoid them. # .for i in ${ZSTD_SRC} CFLAGS.$i+= -U__BMI__ ${NO_WBITWISE_INSTEAD_OF_LOGICAL} .endfor CFLAGS.zfs_zstd.c+= -DIN_BASE -DIN_LIBSA CFLAGS.blake3_impl.c+= -I${ZFSTOP}/module/icp/algs/blake3 -I${ZFSTOP}/module/icp/include -DIN_LIBSA # Do not unroll skein loops, reduce code size CFLAGS.skein_block.c+= -DSKEIN_LOOP=111 CWARNFLAGS.zfs.c+= ${NO_WDANGLING_POINTER} diff --git a/stand/loader.mk b/stand/loader.mk index e26ba1401912..496252e7a534 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -1,203 +1,203 @@ .PATH: ${LDRSRC} ${BOOTSRC}/libsa CFLAGS+=-I${LDRSRC} SRCS+= boot.c commands.c console.c devopen.c interp.c SRCS+= interp_backslash.c interp_parse.c ls.c misc.c SRCS+= modinfo.c SRCS+= module.c nvstore.c pnglite.c tslog.c CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .PATH: ${SRCTOP}/contrib/pnglite CFLAGS.pnglite.c+= -I${SRCTOP}/contrib/pnglite CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib .if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c .elif ${MACHINE_CPUARCH} == "aarch64" SRCS+= load_elf64.c reloc_elf64.c .elif ${MACHINE_CPUARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c .elif ${MACHINE_CPUARCH} == "powerpc" SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c .elif ${MACHINE_CPUARCH} == "riscv" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c .endif # # LOADER_*_SUPPORT variables are used to subset the boot loader in the various # configurations each platform supports. These are typically used to omit broken # options, or to size optimize for space constrained instances. These are set in # loader Makefiles (which include loader.mk) to control which subset of features # are enabled. These cannot generally be set in src.conf since that would affect # all loaders, but also not all loaders are setup for overrides like that and # not all combinations of the following have been tested or even work. Sometimes # non-default values won't work due to buggy support for that component being # optional. # # LOADER_BZIP2_SUPPORT Add support for bzip2 compressed files # LOADER_CD9660_SUPPORT Add support for iso9660 filesystems # LOADER_DISK_SUPPORT Adds support for disks and mounting filesystems on it # LOADER_EXT2FS_SUPPORT Add support for ext2 Linux filesystems # LOADER_GPT_SUPPORT Add support for GPT partitions # LOADER_GZIP_SUPPORT Add support for gzip compressed files # LOADER_INSTALL_SUPPORT Add support for booting off of installl ISOs # LOADER_MBR_SUPPORT Add support for MBR partitions # LOADER_MSDOS_SUPPORT Add support for FAT filesystems # LOADER_NET_SUPPORT Adds networking support (useless w/o net drivers sometimes) # LOADER_NFS_SUPPORT Add NFS support # LOADER_TFTP_SUPPORT Add TFTP support # LOADER_UFS_SUPPORT Add support for UFS filesystems # LOADER_ZFS_SUPPORT Add support for ZFS filesystems # .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib SRCS+= disk.c part.c vdisk.c .endif .if ${LOADER_NET_SUPPORT:Uno} == "yes" SRCS+= dev_net.c .endif .if defined(HAVE_BCACHE) SRCS+= bcache.c .endif .if defined(MD_IMAGE_SIZE) CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE} SRCS+= md.c .else CLEANFILES+= md.o .endif # Machine-independent ISA PnP .if defined(HAVE_ISABUS) SRCS+= isapnp.c .endif .if defined(HAVE_PNP) SRCS+= pnp.c .endif .if ${LOADER_INTERP} == "lua" SRCS+= interp_lua.c .include "${BOOTSRC}/lua.mk" LDR_INTERP= ${LIBLUA} LDR_INTERP32= ${LIBLUA32} CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/lfs .elif ${LOADER_INTERP} == "4th" SRCS+= interp_forth.c .include "${BOOTSRC}/ficl.mk" LDR_INTERP= ${LIBFICL} LDR_INTERP32= ${LIBFICL32} .elif ${LOADER_INTERP} == "simp" SRCS+= interp_simple.c .else .error Unknown interpreter ${LOADER_INTERP} .endif .if defined(BOOT_PROMPT_123) CFLAGS+= -DBOOT_PROMPT_123 .endif .if defined(LOADER_INSTALL_SUPPORT) SRCS+= install.c .endif # Filesystem support .if ${LOADER_CD9660_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif .if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_EXT2FS_SUPPORT .endif .if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_MSDOS_SUPPORT .endif .if ${LOADER_UFS_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_UFS_SUPPORT .endif # Compression .if ${LOADER_GZIP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif .if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_BZIP2_SUPPORT .endif # Network related things .if ${LOADER_NET_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NET_SUPPORT .endif .if ${LOADER_NFS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NFS_SUPPORT .endif .if ${LOADER_TFTP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_TFTP_SUPPORT .endif # Partition support .if ${LOADER_GPT_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_GPT_SUPPORT .endif .if ${LOADER_MBR_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_MBR_SUPPORT .endif .if ${HAVE_ZFS:Uno} == "yes" CFLAGS+= -DLOADER_ZFS_SUPPORT -CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SAZFSSRC} CFLAGS+= -I${SYSDIR}/cddl/boot/zfs CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common SRCS+= zfs_cmd.c .endif LIBFICL= ${BOOTOBJ}/ficl/libficl.a .if ${MACHINE} == "i386" LIBFICL32= ${LIBFICL} .else LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a .endif LIBLUA= ${BOOTOBJ}/liblua/liblua.a .if ${MACHINE} == "i386" LIBLUA32= ${LIBLUA} .else LIBLUA32= ${BOOTOBJ}/liblua32/liblua.a .endif CLEANFILES+= vers.c VERSION_FILE?= ${.CURDIR}/version .if ${MK_REPRODUCIBLE_BUILD} != no REPRO_FLAG= -r .endif vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE} sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ ${NEWVERSWHAT} .if ${MK_LOADER_VERBOSE} != "no" CFLAGS+= -DELF_VERBOSE .endif # Each loader variant defines their own help filename. Optional or # build-specific commands are included by augmenting HELP_FILES. .if !defined(HELP_FILENAME) .error Define HELP_FILENAME before including loader.mk .endif HELP_FILES+= ${LDRSRC}/help.common CFLAGS+= -DHELP_FILENAME=\"${HELP_FILENAME}\" .if ${INSTALL_LOADER_HELP_FILE:Uyes} == "yes" CLEANFILES+= ${HELP_FILENAME} FILES+= ${HELP_FILENAME} .endif ${HELP_FILENAME}: ${HELP_FILES} cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}