After upgrading to FreeBSD 14.2, I encountered a perplexing issue with kernel modules built from ports. They would load and show up in kldstat, but no message nor sysctl node would be created. In fact, it was as if the event_handler would not be called at all, yet it compiled and loaded successfully. On the other hand, modules shipped with the kernel and already compiled were working as intended. To investigate, I built a small test module:
#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> static int test_event_handler(module_t mod, int event, void *arg) { printf("Test module loaded, event: %d\n", event); return (0); } static moduledata_t test_mod = { "testmodule", test_event_handler, NULL }; DECLARE_MODULE(testmodule, test_mod, SI_SUB_LAST, SI_ORDER_ANY); MODULE_VERSION(testmodule, 1);
On FreeBSD 14.2 amd64, it would load and show the message in the log, whereas on FreeBSD 14.2 arm64, it would load but with no output. Yet, disassembling the module, the event_handler code was just there.
After some investigation, I found out that while the source were compiled with /usr/bin/cc
(llvm clang), they were linked with /usr/local/bin/ld
(GNU binutils ld). Uninstalling binutils and compiling again with both /usr/bin/cc
and /usr/bin/ld
, the module would load and show in the log. Why it only appeared with FreeBSD 14.2, however, is still a mystery.