For amd64, compile both zfs and zfs32 libraries.

We have a separate copy of zfs for userboot. However, we don't need it
if we compile both 32 and 64 bit ZFS libraries. Remove redunant copies
of zfs related .o files now that both versions are
available. Introduce ZFSSRC and use it everywhere.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2017-10-30 23:14:59 +00:00
parent 89ec162979
commit 8689c387ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325175
19 changed files with 66 additions and 117 deletions

View File

@ -1,16 +1,16 @@
# $FreeBSD$
SUBDIR+= efi
SUBDIR+= libsa32
SUBDIR+= zfs
SUBDIR+= zfs zfs32
.if ${MK_FORTH} != "no"
SUBDIR+= ficl32
.endif
SUBDIR+= efi
SUBDIR+= userboot
.if ${LOADER_GELI_SUPPORT:Uyes} == "yes"
SUBDIR+= geli
.endif
.if ${MK_FORTH} != "no"
SUBDIR+= ficl32
.endif
SUBDIR+= i386

View File

@ -3,5 +3,8 @@
.if ${MK_FDT} != "no"
SUBDIR+= fdt
.endif
.if ${MK_ZFS} != "no"
SUBDIR+= zfs
.endif
SUBDIR+= efi uboot

View File

@ -3,5 +3,8 @@
.if ${MK_FDT} != "no"
SUBDIR+= fdt
.endif
.if ${MK_ZFS} != "no"
SUBDIR+= zfs
.endif
SUBDIR+= efi

View File

@ -1,9 +1,9 @@
# $FreeBSD$
SUBDIR+= efi
SUBDIR+= libsa32
SUBDIR+= zfs
.if ${LOADER_GELI_SUPPORT:Uyes} == "yes"
SUBDIR+= geli
.endif
SUBDIR+= zfs
SUBDIR+= efi

View File

@ -15,6 +15,7 @@ LDRSRC= ${BOOTSRC}/common
SASRC= ${BOOTSRC}/libsa
SYSDIR= ${SRCTOP}/sys
UBOOTSRC= ${BOOTSRC}/uboot
ZFSSRC= ${BOOTSRC}/zfs
BOOTOBJ= ${OBJTOP}/sys/boot

View File

@ -26,21 +26,15 @@ 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
CWARNFLAGS.skein.c += -Wno-cast-align
.if ${COMPILER_TYPE} == "clang"
CWARNFLAGS.skein.c += -Wno-missing-variable-declarations
.else if ${COMPILER_TYPE} == "gcc"
CWARNFLAGS.skein.c += -Wno-missing-declarations
.endif
# architecture-specific loader code
SRCS= boot1.c self_reloc.c start.S ufs_module.c
.if ${MK_ZFS} != "no"
SRCS+= zfs_module.c
SRCS+= skein.c skein_block.c
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
.PATH: ${SYSDIR}/crypto/skein
CFLAGS+= -I${ZFSSRC}
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
CFLAGS+= -DEFI_ZFS_BOOT
LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a
.endif
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
@ -57,13 +51,6 @@ CFLAGS+= -DEFI_UFS_BOOT
CFLAGS+= -DEFI_DEBUG
.endif
.if ${MK_ZFS} != "no"
CFLAGS+= -I${BOOTSRC}/zfs/
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs/
CFLAGS+= -I${SYSDIR}/crypto/skein
CFLAGS+= -DEFI_ZFS_BOOT
.endif
# Always add MI sources and REGULAR efi loader bits
.PATH: ${EFISRC}/loader/arch/${MACHINE}
.PATH: ${EFISRC}/loader
@ -91,8 +78,8 @@ LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
# __aeabi_* (arm) or __divdi3 (i386).
# as well as required string and memory functions for all platforms.
#
DPADD+= ${LIBEFI} ${LIBSA}
LDADD+= ${LIBEFI} ${LIBSA}
DPADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA}
LDADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA}
DPADD+= ${LDSCRIPT}

View File

@ -38,9 +38,7 @@ CFLAGS+= -I${SYSDIR}
CFLAGS+= -I${EFIINC}
CFLAGS+= -I${EFIINCMD}
.if ${MK_ZFS} != "no"
CFLAGS+= -I${BOOTSRC}/zfs
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
CFLAGS+= -I${SYSDIR}/crypto/skein
CFLAGS+= -I${ZFSSRC}
CFLAGS+= -DEFI_ZFS_BOOT
.endif

View File

@ -29,17 +29,9 @@ SRCS= autoload.c \
vers.c
.if ${MK_ZFS} != "no"
SRCS+= zfs.c
.PATH: ${BOOTSRC}/zfs
SRCS+= skein.c skein_block.c
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
.PATH: ${SYSDIR}/crypto/skein
# Disable warnings that are currently incompatible with the zfs boot code
CWARNFLAGS.zfs.c+= -Wno-sign-compare
CWARNFLAGS.zfs.c+= -Wno-array-bounds
CWARNFLAGS.zfs.c+= -Wno-missing-prototypes
LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a
CFLAGS+= -I${ZFSSRC}
CFLAGS+= -DEFI_ZFS_BOOT
.endif
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
@ -65,12 +57,6 @@ CFLAGS+= -I${EFISRC}/include/${MACHINE}
CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include
CFLAGS+= -I${SYSDIR}
CFLAGS+= -I${BOOTSRC}/i386/libi386
.if ${MK_ZFS} != "no"
CFLAGS+= -I${BOOTSRC}/zfs
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
CFLAGS+= -I${SYSDIR}/crypto/skein
CFLAGS+= -DEFI_ZFS_BOOT
.endif
CFLAGS+= -DNO_PCI -DEFI
.if !defined(BOOT_HIDE_SERIAL_NUMBERS)
@ -142,9 +128,9 @@ loader.efi: ${PROG}
LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} \
DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA} \
${LDSCRIPT}
LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA}
.include <bsd.prog.mk>

View File

@ -4,7 +4,7 @@
.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \
${BOOTSRC}/i386/zfsboot ${BOOTSRC}/i386/common \
${SYSDIR}/crypto/skein ${SASRC}
${SASRC}
FILES= gptzfsboot
MAN= gptzfsboot.8
@ -27,9 +27,8 @@ CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
-I${LDRSRC} \
-I${BOOTSRC}/i386/common \
-I${BOOTSRC}/zfs \
-I${ZFSSRC} \
-I${SYSDIR}/cddl/boot/zfs \
-I${SYSDIR}/crypto/skein \
-I${BOOTSRC}/i386/btx/lib -I. \
-I${BOOTSRC}/i386/boot2 \
-I${SYSDIR} \
@ -45,8 +44,11 @@ NO_WCAST_ALIGN=
CFLAGS+= -Wno-tentative-definition-incomplete-type
.endif
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
.if ${MACHINE} == "amd64"
LIBZFSBOOT=${BOOTOBJ}/zfs32/libzfsboot.a
.else
LIBZFSBOOT=${BOOTOBJ}/zfs/libzfsboot.a
.endif
.if ${LOADER_GELI_SUPPORT:Uyes} == "yes"
CFLAGS+= -DLOADER_GELI_SUPPORT
@ -75,16 +77,16 @@ gptldr.out: gptldr.o
${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
CLEANFILES+= gptzfsboot.bin gptzfsboot.out zfsboot.o sio.o cons.o \
drv.o gpt.o util.o skein.o skein_block.o ${OPENCRYPTO_XTS}
drv.o gpt.o util.o ${OPENCRYPTO_XTS}
gptzfsboot.bin: gptzfsboot.out
${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET}
gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o \
skein.o skein_block.o ${OPENCRYPTO_XTS}
${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBSA32}
${OPENCRYPTO_XTS}
${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBZFSBOOT} ${LIBSA32}
zfsboot.o: ${BOOTSRC}/zfs/zfsimpl.c
zfsboot.o: ${ZFSSRC}/zfsimpl.c
.if ${MACHINE_CPUARCH} == "amd64"
beforedepend zfsboot.o: machine

View File

@ -11,8 +11,8 @@ SRCS= biosacpi.c bioscd.c biosdisk.c biosmem.c biospnp.c \
elf64_freebsd.c multiboot.c multiboot_tramp.S relocater_tramp.S \
i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
.PATH: ${BOOTSRC}/zfs
SRCS+= devicename_stubs.c
.PATH: ${ZFSSRC}
SRCS+= devicename_stubs.c
BOOT_COMCONSOLE_PORT?= 0x3f8
CFLAGS+= -DCOMPORT=${BOOT_COMCONSOLE_PORT}

View File

@ -31,8 +31,12 @@ LIBFIREWIRE= ${BOOTSRC}/i386/libfirewire/libfirewire.a
# Set by zfsloader Makefile
.if defined(LOADER_ZFS_SUPPORT)
CFLAGS+= -DLOADER_ZFS_SUPPORT
.if ${MACHINE} == "amd64"
LIBZFSBOOT= ${BOOTOBJ}/zfs32/libzfsboot.a
.else
LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a
.endif
.endif
# Include bcache code.
HAVE_BCACHE= yes

View File

@ -4,8 +4,7 @@ LOADER_GELI_SUPPORT=no
.include <bsd.init.mk>
.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common \
${SYSDIR}/crypto/skein ${SASRC}
.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC}
FILES= zfsboot
MAN= zfsboot.8
@ -29,9 +28,8 @@ CFLAGS+=-DBOOTPROG=\"zfsboot\" \
-I${LDRSRC} \
-I${BOOTSRC}/i386/common \
-I${BOOTSRC}/i386 \
-I${BOOTSRC}/zfs \
-I${ZFSSRC} \
-I${SYSDIR}/cddl/boot/zfs \
-I${SYSDIR}/crypto/skein \
-I${BTXLIB} -I. \
-I${BOOTSRC}/i386/boot2 \
-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
@ -40,8 +38,11 @@ CFLAGS+=-DBOOTPROG=\"zfsboot\" \
-Winline
CFLAGS.gcc+= --param max-inline-insns-single=100
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
.if ${MACHINE} == "amd64"
LIBZFSBOOT=${BOOTOBJ}/zfs32/libzfsboot.a
.else
LIBZFSBOOT=${BOOTOBJ}/zfs/libzfsboot.a
.endif
LD_FLAGS+=${LD_FLAGS_BIN}
@ -59,8 +60,7 @@ zfsldr.out: zfsldr.o
${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o \
skein.o skein_block.o
zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o
# We currently allow 128k bytes for zfsboot - in practice it could be
# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
@ -82,8 +82,8 @@ zfsboot.ldr:
zfsboot.bin: zfsboot.out
${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o skein.o skein_block.o
${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32}
zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o
${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBZFSBOOT} ${LIBSA32}
SRCS= zfsboot.c

View File

@ -8,7 +8,7 @@ INTERNALLIB=
SRCS= devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \
ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \
ofw_time.c openfirm.c
.PATH: ${BOOTSRC}/zfs
.PATH: ${ZFSSRC}
SRCS+= devicename_stubs.c
# Pick up the bootstrap header for some interface items

View File

@ -30,7 +30,7 @@ CFLAGS+= -DLOADER_DEBUG
.endif
.if ${LOADER_ZFS_SUPPORT} == "yes"
CFLAGS+= -DLOADER_ZFS_SUPPORT
CFLAGS+= -I${BOOTSRC}/zfs
CFLAGS+= -I${ZFSSRC}
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a
.endif

View File

@ -2,7 +2,7 @@
.include <bsd.own.mk>
SUBDIR= test zfs userboot
SUBDIR= test userboot
.include <bsd.subdir.mk>

View File

@ -47,7 +47,7 @@ NEWVERSWHAT= "User boot" ${MACHINE_CPUARCH}
.if ${MK_ZFS} != "no"
CFLAGS+= -DUSERBOOT_ZFS_SUPPORT
LIBZFSBOOT= ${BOOTOBJ}/userboot/zfs/libzfsboot.a
LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a
.endif
# Always add MI sources

View File

@ -1,22 +0,0 @@
# $FreeBSD$
.include <bsd.init.mk>
.PATH: ${BOOTSRC}/zfs ${SYSDIR}/crypto/skein
LIB= zfsboot
INTERNALLIB=
SRCS+= zfs.c skein.c skein_block.c
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I.
CFLAGS+= -I${SASRC}
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
CFLAGS+= -I${SYSDIR}/crypto/skein
CFLAGS+= -ffreestanding -fPIC
CFLAGS+= -Wformat -Wall
.include <bsd.lib.mk>

View File

@ -1,13 +0,0 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
include/xlocale \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -5,9 +5,8 @@
LIB= zfsboot
INTERNALLIB=
SRCS+= zfs.c
SRCS+= skein.c skein_block.c
.PATH: ${ZFSSRC}
SRCS+= zfs.c skein.c skein_block.c
# Do not unroll skein loops, reduce code size
CFLAGS+= -DSKEIN_LOOP=111
.PATH: ${SYSDIR}/crypto/skein
@ -17,16 +16,17 @@ CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I.
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
CFLAGS+= -I${SYSDIR}/crypto/skein
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
.if ${MACHINE_CPUARCH} == "i386" || \
(${MACHINE_CPUARCH} == "amd64" && defined(ZFS32))
CFLAGS+= -march=i386
.endif
.if ${MACHINE_CPUARCH} == "amd64"
.if ${MACHINE_CPUARCH} == "amd64" && defined(ZFS32)
CFLAGS+= -m32
.endif
CFLAGS+= -Wformat -Wall
.if ${MACHINE_CPUARCH} == "amd64"
.if ${MACHINE_CPUARCH} == "amd64" && defined(ZFS32)
CLEANFILES+= machine
machine: .NOMETA
ln -sf ${SYSDIR}/i386/include machine
@ -35,7 +35,7 @@ machine: .NOMETA
.include <bsd.stand.mk>
.include <bsd.lib.mk>
.if ${MACHINE_CPUARCH} == "amd64"
.if ${MACHINE_CPUARCH} == "amd64" && defined(ZFS32)
.if !exists(machine)
beforedepend ${OBJS}: machine
.endif