Fix make depend in sys/modules
Details
cd sys/modules; make depend
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Hi,
Can I piggyback this commit and ask you to fix those modules too? (it should be the same fix):
mlx4ib
ibcore
if_tun
if_bridge
oce
cryptodev
padlock_rng
rdrand_rng
sppp
safe
tmpfs
hifn
syscons/dragon
ubsec
ufs
virtio/random
virtio/network
usb/smsc
netgraph/iface
I hope with your initial list and my list we've covered all broken modules.
Sure, I did not found them are broken when doing make depend last time. May I know how do you find these?
The bigger problem is that sys/random.h includes opt_random.h.
Header files aren't supposed to include opt_foo.h.
Do you mean that we should remove opt_random.h from sys/random.h first then fix these modules?
Is there anything else need to take care of?
We should remove opt_random.h from sys/random.h and move the affected options to opt_global.h.
The modules won't need fixing if we do this.
It turns out just removing opt_random.h from sys/random.h works fine.
I've done buildworld & buildkernel tests.
Hmm, this might break when using options RANDOM_YARROW or options RANDOM_LOADABLE, is it OK to just set them to opt_global.h in sys/conf/options ?
Except it doesn't. The RANDOM_ parameters are now never defined. This does 'work' in the 'it compiles' sense,
but it doesn't allow any of them to take effect.
This is also needed:
diff -r 4f344ba5ec47 sys/conf/options --- a/sys/conf/options +++ b/sys/conf/options @@ -947,11 +947,11 @@ RCTL opt_global.h # Random number generator(s) # Which CSPRNG hash we get. # If Yarrow is not chosen, Fortuna is selected. -RANDOM_YARROW opt_random.h +RANDOM_YARROW opt_global.h # With this, no entropy processor is loaded, but the entropy # harvesting infrastructure is present. This means an entropy # processor may be loaded as a module. -RANDOM_LOADABLE opt_random.h +RANDOM_LOADABLE opt_global.h # This turns on high-rate and potentially expensive harvesting in # the uma slab allocator. RANDOM_ENABLE_UMA opt_global.h
This looks like it will work. Make sure by defining both RANDOM_LOADABLE and RANDOM_YARROW in a kernel config and seeing if you hit the above #error.
If so, commit away. If you don't have a commit bit, let me know and I'll do the deed.
make -DALL_MODULES buildkernel with options RANDOM_LOADABLE in KERNCONF
got following error:
--- kernel.debug --- linking kernel.debug ivy.o: In function `rdrand_modevent': /usr/src/sys/dev/random/ivy.c:115: undefined reference to `random_source_deregister' /usr/src/sys/dev/random/ivy.c:108: undefined reference to `random_source_register' nehemiah.o: In function `nehemiah_modevent': /usr/src/sys/dev/random/nehemiah.c:136: undefined reference to `random_source_deregister' /usr/src/sys/dev/random/nehemiah.c:127: undefined reference to `random_source_register' *** [kernel.debug] Error code 1
I am working on fixing this.
Thanks, I'm having trouble with how to deal with these functions only exist when _KENREL defined.
Please update this patch (although I don't know if non-original author can) and I can help to test, or please just commit it.
This change is more invasive than it potentially needs to be: https://reviews.freebsd.org/D3594
No, this change is correct. Your change is wrong. It breaks building modules. Sorry, try again.
It looks like it works to me. make tinderbox is in progress on ref11-amd64:
[ngie@fbsd11 /usr/src/git/sys/modules/random_fortuna]$ make obj
/usr/obj/usr/src/git/sys/modules/random_fortuna created for /usr/src/git/sys/modules/random_fortuna
[ngie@fbsd11 /usr/src/git/sys/modules/random_fortuna]$ make depend
machine -> /usr/src/git/sys/amd64/include
x86 -> /usr/src/git/sys/x86/include
:> opt_param.h
awk -f /usr/src/git/sys/modules/random_fortuna/../../tools/makeobjops.awk /usr/src/git/sys/kern/bus_if.m -h
awk -f /usr/src/git/sys/modules/random_fortuna/../../tools/makeobjops.awk /usr/src/git/sys/kern/device_if.m -h
:> opt_ddb.h
rm -f .depend
mkdep -f .depend -a -nostdinc -DRANDOM_LOADABLE -D_KERNEL -DKLD_MODULE -I. -I/usr/src/git/sys/modules/random_fortuna/../.. -Dprintf=freebsd_kprintf -std=iso9899:1999 /usr/src/git/sys/modules/random_fortuna/../../dev/random/randomdev.c /usr/src/git/sys/modules/random_fortuna/../../dev/random/hash.c /usr/src/git/sys/modules/random_fortuna/../../dev/random/fortuna.c
[ngie@fbsd11 /usr/src/git/sys/modules/random_fortuna]$ make all
cc -O2 -pipe -fno-strict-aliasing -O2 -DRANDOM_LOADABLE -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I/usr/src/git/sys/modules/random_fortuna/../.. -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Dprintf=freebsd_kprintf -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -mno-aes -mno-avx -std=iso9899:1999 -c /usr/src/git/sys/modules/random_fortuna/../../dev/random/randomdev.c -o randomdev.o
cc -O2 -pipe -fno-strict-aliasing -O2 -DRANDOM_LOADABLE -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I/usr/src/git/sys/modules/random_fortuna/../.. -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Dprintf=freebsd_kprintf -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -mno-aes -mno-avx -std=iso9899:1999 -c /usr/src/git/sys/modules/random_fortuna/../../dev/random/hash.c -o hash.o
cc -O2 -pipe -fno-strict-aliasing -O2 -DRANDOM_LOADABLE -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I/usr/src/git/sys/modules/random_fortuna/../.. -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Dprintf=freebsd_kprintf -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -mno-aes -mno-avx -std=iso9899:1999 -c /usr/src/git/sys/modules/random_fortuna/../../dev/random/fortuna.c -o fortuna.o
ld -d -warn-common -r -d -o random_fortuna.ko randomdev.o hash.o fortuna.o
:> export_syms
awk -f /usr/src/git/sys/modules/random_fortuna/../../conf/kmod_syms.awk random_fortuna.ko export_syms | xargs -J% objcopy % random_fortuna.ko
objcopy --strip-debug random_fortuna.ko
[ngie@fbsd11 /usr/src/git/sys/modules/random_fortuna]$ uname -a
FreeBSD fbsd11 11.0-CURRENT FreeBSD 11.0-CURRENT #2 r287529+e3e7b86(isilon-atf): Mon Sep 7 00:12:58 PDT 2015 ngie@fbsd11:/usr/obj/usr/src/git/sys/GENERIC-NODEBUG amd64
It works, in that it compiles. That's never been an acceptable definition of 'works'
Look down a few lines. If you define RANDOM_ENABLE_UMA it won't be picked up by the drivers.
There have been, at other times, other RANDOM_ENABLE_* options, and there will be in the
future. Your change makes sure they are never defined.
That's broken. that's the whole reason I moved them to opt_global.h in the other review.
The above patch passed make tinderbox on ref11-amd64. I'm going to commit the above patch soon.
Found this issue on 10.1-RELEASE box building HEAD r290336. The proposed patch didn't fix anything and the problem turned out to be an old kernel-toolchain.
After running building kernel-toolchain the error below disappeared.
Capturing here for posterity as its the the first relevant search result for this error.
--- kernel.full --- linking kernel.full random_infra.o:(.data+0xb0): undefined reference to `random_alg_context' kern_mib.o: In function `sysctl_kern_arnd': /usr/src/sys/kern/kern_mib.c:164: undefined reference to `read_random' arc4random.o: In function `arc4_randomstir': /usr/src/sys/libkern/arc4random.c:61: undefined reference to `read_random' tcp_subr.o: In function `tcp_new_isn': /usr/src/sys/netinet/tcp_subr.c:1756: undefined reference to `read_random' key.o: In function `key_randomfill': /usr/src/sys/netipsec/key.c:4416: undefined reference to `read_random' /usr/src/sys/netipsec/key.c:4416: undefined reference to `read_random' xform_esp.o:/usr/src/sys/netipsec/xform_esp.c:802: more undefined references to `read_random' follow ivy.o: In function `rdrand_modevent': /usr/src/sys/dev/random/ivy.c:115: undefined reference to `random_source_deregister' /usr/src/sys/dev/random/ivy.c:108: undefined reference to `random_source_register' nehemiah.o: In function `nehemiah_modevent': /usr/src/sys/dev/random/nehemiah.c:136: undefined reference to `random_source_deregister' /usr/src/sys/dev/random/nehemiah.c:127: undefined reference to `random_source_register' *** [kernel.full] Error code 1
What are your random(4)-related kernel options? Are you building random(4) and friends as modules, or statically into the kernel?
...
What are your random(4)-related kernel options? Are you building random(4) and friends as modules, or statically into the kernel?
The reason why I ask is because:
- Building modules doesn't affect linking kernel.debug, etc.
- My looking at sys/conf suggests that (with your error message above) there might be some hidden, unarticulated dependencies in the files, and some additional pollution that was added to libkern, kern, net*, etc that are causing the before mentioned build errors.
Nothing specific:
grep -ri RANDOM sys/amd64/conf/GENERIC sys/amd64/conf/MULTIPLAY* sys/amd64/conf/GENERIC:device random # Entropy device