Search code examples
makefilefreebsdports

Why is my FreeBSD port failing on make stage?


I'm trying to build a port for the Silicom Bypass Controller. I suspect that my Makefile is not complete but I'm not sure. Is there something I should add for ld based on the error?

UPDATE:

Adding SSP_UNSAFE= yes in the Makefile moves me past the original error. Not sure if this is the best way.. Adding support to default SSP_CFLAGS using -fstack-protector seemed to cause this issue. Is this something that would need to be fixed in the source code?

Makefile:

PORTNAME=       silicom_bpctl
PORTVERSION=    3.10.5
PORTREVISION=   1
CATEGORIES=     sysutils
MASTER_SITES=   http://pkg.insecure-it.com/distfiles/

MAINTAINER=     me@myemail.com
COMMENT=        Silicom Bypass Controller utility (Zero Power Fail-Open for IPS)

LICENSE=        GPLv2
LICENSE_FILE=   ${WRKSRC}/license

SUB_FILES=      pkg-message

SSP_UNSAFE=     yes

.include <bsd.port.mk>

pkg-plist file:

boot/kernel/bpmod.ko
bin/bpctl_util

Original Error:

:/usr/local/poudriere/ports/default/sysutils/silicom_bpctl % sudo make stage

===>  License GPLv2 accepted by the user
===>   silicom_bpctl-3.10.5_1 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by silicom_bpctl-3.10.5_1 for building
===>  Extracting for silicom_bpctl-3.10.5_1
=> SHA256 Checksum OK for silicom_bpctl-3.10.5.tar.gz.
===>  Patching for silicom_bpctl-3.10.5_1
===>  Configuring for silicom_bpctl-3.10.5_1
===>  Building for silicom_bpctl-3.10.5_1
--- _sub.all ---
===> driver (all)
--- objwarn ---
--- /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver/@ ---
--- /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver/machine ---
--- opt_bdg.h ---
--- objwarn ---
Warning: Object directory not changed from original /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver
--- opt_bdg.h ---
:> opt_bdg.h
--- /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver/@ ---
@ -> /usr/src/sys
--- /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver/machine ---
machine -> /usr/src/sys/amd64/include
--- pci_if.h ---
--- bus_if.h ---
--- device_if.h ---
--- pci_if.h ---
awk -f @/tools/makeobjops.awk @/dev/pci/pci_if.m -h
--- bus_if.h ---
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
--- device_if.h ---
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
--- bp_mod.o ---
cc -O2 -pipe -fstack-protector -fno-strict-aliasing  -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ -I@/contrib/altq -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -mno-aes -mno-avx -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -std=iso9899:1999 -Qunused-arguments  -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option  -Wno-error-tautological-compare -Wno-error-empty-body  -Wno-error-parentheses-equality -Wno-error-unused-function    -c bp_mod.c -o bp_mod.o
--- bpmod.ko ---
ld  -fstack-protector -d -warn-common -r -d -o bpmod.ko bp_mod.o
ld: -f may not be used without -shared
*** [bpmod.ko] Error code 1

make[2]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver
1 error

make[2]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5/driver
*** [_sub.all] Error code 2

make[1]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5
1 error

make[1]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom_bpctl/work/silicom_bpctl-3.10.5
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/local/poudriere/ports/default/sysutils/silicom_bpctl

Manually installing this utility is very simple just make and sudo make install.

make:

~/silicom/bp_ctl-3.10.5 % make 

===> driver (all)
Warning: Object directory not changed from original /usr/home/arozar/silicom/bp_ctl-3.10.5/driver
@ -> /usr/src/sys
machine -> /usr/src/sys/amd64/include
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
awk -f @/tools/makeobjops.awk @/dev/pci/pci_if.m -h
:> opt_bdg.h
cc -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ -I@/contrib/altq -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -mno-aes -mno-avx -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -std=iso9899:1999 -Qunused-arguments  -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option  -Wno-error-tautological-compare -Wno-error-empty-body  -Wno-error-parentheses-equality -Wno-error-unused-function   -c bp_mod.c
ld  -d -warn-common -r -d -o bpmod.ko bp_mod.o
:> export_syms
awk -f /sys/conf/kmod_syms.awk bpmod.ko  export_syms | xargs -J% objcopy % bpmod.ko
objcopy --strip-debug bpmod.ko
===> util (all)
cc -O2 -pipe  bpctl_util.c  -o bpctl_util
bpctl_util.c:1096:20: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
            printf(bp_cap_array[i].desc);
                   ^~~~~~~~~~~~~~~~~~~~
bpctl_util.c:2617:30: warning: format specifies type 'char *' but the argument has type 'int *' [-Wformat]
    printf("Name\t\t\t%s\n", bpctl_cmd.data);
                      ~~     ^~~~~~~~~~~~~~
bpctl_util.c:2635:46: warning: format specifies type 'char *' but the argument has type 'int *' [-Wformat]
                printf("\n\tName\t\t\t%s\n", bpctl_cmd.data);
                                      ~~     ^~~~~~~~~~~~~~
3 warnings generated.

sudo make install:

~/silicom/bp_ctl-3.10.5 % sudo make install

===> driver (install)
install -o root -g wheel -m 555   bpmod.ko /boot/kernel
kldxref /boot/kernel
===> util (install)
install bpctl_util /bin

New Error:

Fails on install now must be the pkg-plist file:

:/usr/local/poudriere/ports/default/sysutils/silicom-bpctl % sudo make stage
===>  License GPLv2 accepted by the user
===>   silicom-bpctl-3.10.5_1 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by silicom-bpctl-3.10.5_1 for building
===>  Extracting for silicom-bpctl-3.10.5_1
=> SHA256 Checksum OK for silicom-bpctl-3.10.5.tar.gz.
===>  Patching for silicom-bpctl-3.10.5_1
===>  Configuring for silicom-bpctl-3.10.5_1
===>  Building for silicom-bpctl-3.10.5_1
--- _sub.all ---
===> driver (all)
--- objwarn ---
--- /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver/@ ---
--- /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver/machine ---
--- opt_bdg.h ---
--- objwarn ---
Warning: Object directory not changed from original /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver
--- opt_bdg.h ---
:> opt_bdg.h
--- /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver/@ ---
@ -> /usr/src/sys
--- /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver/machine ---
machine -> /usr/src/sys/amd64/include
--- pci_if.h ---
--- bus_if.h ---
--- device_if.h ---
--- pci_if.h ---
awk -f @/tools/makeobjops.awk @/dev/pci/pci_if.m -h
--- bus_if.h ---
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
--- device_if.h ---
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
--- bp_mod.o ---
cc -O2 -pipe -fno-strict-aliasing  -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ -I@/contrib/altq -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -mno-aes -mno-avx -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -std=iso9899:1999 -Qunused-arguments  -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option  -Wno-error-tautological-compare -Wno-error-empty-body  -Wno-error-parentheses-equality -Wno-error-unused-function    -c bp_mod.c -o bp_mod.o
--- bpmod.ko ---
ld  -d -warn-common -r -d -o bpmod.ko bp_mod.o
:> export_syms
awk -f /sys/conf/kmod_syms.awk bpmod.ko  export_syms | xargs -J% objcopy % bpmod.ko
objcopy --strip-debug bpmod.ko
===> util (all)
--- bpctl_util ---
cc -O2 -pipe  bpctl_util.c  -o bpctl_util
bpctl_util.c:1096:20: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
            printf(bp_cap_array[i].desc);
                   ^~~~~~~~~~~~~~~~~~~~
bpctl_util.c:2617:30: warning: format specifies type 'char *' but the argument has type 'int *' [-Wformat]
    printf("Name\t\t\t%s\n", bpctl_cmd.data);
                      ~~     ^~~~~~~~~~~~~~
bpctl_util.c:2635:46: warning: format specifies type 'char *' but the argument has type 'int *' [-Wformat]
                printf("\n\tName\t\t\t%s\n", bpctl_cmd.data);
                                      ~~     ^~~~~~~~~~~~~~
3 warnings generated.
===>  Staging for silicom-bpctl-3.10.5_1
===>   Generating temporary packing list
===> driver (install)
install -o root -g wheel -m 555   bpmod.ko /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/stage/boot/kernel
install: /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/stage/boot/kernel: No such file or directory
*** Error code 71

Stop.
make[2]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5/driver
*** Error code 1

Stop.
make[1]: stopped in /usr/local/poudriere/ports/default/sysutils/silicom-bpctl/work/silicom-bpctl-3.10.5
*** Error code 1

Stop.
make: stopped in /usr/local/poudriere/ports/default/sysutils/silicom-bpctl

Solution

  • Don't hardcode your non-/usr/local paths in your pkg-plist file.

    /%%KMODDIR%%/yourdriver.ko should be the way that you specify your driver in the plist file - otherwise, your port does not support staging.

    If you're not aware of what staging does, it performs an internal install of the port to a temporary directory, catalogs all files that happen to get installed, and compares that with the package list.

    Staging was created to account for every file that a port installs, otherwise it's possible for the pkg-plist to not list files that a port's make install will actually install; and now uninstall is broken because it'll leave files behind.

    You may need to create your intermediate directories, especially to support staging. Taking a peak at the Makefile for nvidia-driver is helpful in this regard:

    pre-install:
        @${MKDIR} ${STAGEDIR}${PREFIX}/${MODULESDIR}/drivers \
            ${STAGEDIR}${PREFIX}/${MODULESDIR}/extensions