# Kernel Build Warnings



## CraigHB (Feb 4, 2018)

First time building a kernel and I'm getting a lot of warnings.  Not sure if I have a problem or not.  Here's the output;


```
make[1]: "/usr/src/Makefile.inc1" line 158: SYSTEM_COMPILER: Determined that CC=cc matches the source tree.  Not bootstrapping a cross-compiler.

--------------------------------------------------------------
>>> Kernel build for f2_config started on Sun Feb  4 14:45:40 UTC 2018
--------------------------------------------------------------
===> f2_config

--------------------------------------------------------------
>>> stage 1: configuring the kernel
--------------------------------------------------------------
Kernel build directory is /usr/obj/usr/src/sys/f2_config
Don't forget to do ``make cleandepend && make depend''

--------------------------------------------------------------
>>> stage 2.1: cleaning up the object tree
--------------------------------------------------------------

--------------------------------------------------------------
>>> stage 2.2: rebuilding the object tree
--------------------------------------------------------------

--------------------------------------------------------------
>>> stage 2.3: build tools
--------------------------------------------------------------

--------------------------------------------------------------
>>> stage 3.1: building everything
--------------------------------------------------------------
In file included from /usr/src/sys/cam/cam.c:45:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_compat.c:46:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_iosched.c:48:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_periph.c:50:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_queue.c:39:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_sim.c:40:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/cam_xpt.c:54:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/ata/ata_all.c:50:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/ata/ata_xpt.c:49:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/ata/ata_pmp.c:54:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_xpt.c:51:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_all.c:57:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_cd.c:69:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/ata/ata_da.c:60:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_da.c:60:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_pass.c:54:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_enc.c:49:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_enc_ses.c:52:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/scsi_enc_safte.c:44:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/cam/scsi/smp_all.c:55:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/dev/ahci/ahci.c:47:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/dev/ahci/ahciem.c:50:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/dev/ata/ata-all.c:54:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/dev/ata/ata-lowlevel.c:52:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/dev/usb/storage/umass.c:132:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
In file included from /usr/src/sys/kern/subr_bus_dma.c:52:
In file included from /usr/src/sys/cam/cam_ccb.h:44:
In file included from /usr/src/sys/cam/nvme/nvme_all.h:32:
/usr/src/sys/dev/nvme/nvme.h:922:16: warning: taking address of packed member 'cdw10' of class or structure 'nvme_command' may result in an unaligned pointer value [-Waddress-of-packed-member]
        *(uint64_t *)&cmd->cdw10 = lba;
                      ^~~~~~~~~~
1 warning generated.
/usr/src/sys/netinet/raw_ip.c:318:41: warning: taking address of packed member 'ip_dst' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                        if (prison_check_ip4(inp->inp_cred, &ip->ip_dst) != 0)
                                                             ^~~~~~~~~~
/usr/src/sys/netinet/raw_ip.c:354:41: warning: taking address of packed member 'ip_dst' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                            prison_check_ip4(inp->inp_cred, &ip->ip_dst) != 0)
                                                             ^~~~~~~~~~
/usr/src/sys/netinet/raw_ip.c:478:31: warning: taking address of packed member 'ip_dst' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                                error = in_pcbladdr(inp, &ip->ip_dst, &ip->ip_src,
                                                          ^~~~~~~~~~
/usr/src/sys/netinet/raw_ip.c:478:44: warning: taking address of packed member 'ip_src' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                                error = in_pcbladdr(inp, &ip->ip_dst, &ip->ip_src,
                                                                       ^~~~~~~~~~
/usr/src/sys/netinet/raw_ip.c:482:10: warning: taking address of packed member 'ip_src' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                                    &ip->ip_src);
                                     ^~~~~~~~~~
/usr/src/sys/netinet/raw_ip.c:498:44: warning: taking address of packed member 'ip_src' of class or structure 'ip' may result in an unaligned pointer value [-Waddress-of-packed-member]
                error = prison_check_ip4(inp->inp_cred, &ip->ip_src);
                                                         ^~~~~~~~~~
6 warnings generated.
/usr/src/sys/libkern/x86/crc32_sse42.c:56:1: warning: unused function '_mm_crc32_u32' [-Wunused-function]
_mm_crc32_u32(uint32_t x, uint32_t y)
^
1 warning generated.
linking kernel
     text     data       bss       dec        hex   filename
  5113289   437933   3298088   8849310   0x87079e   kernel
/usr/src/sys/compat/linux/linux_signal.c:67:23: warning: taking address of packed member 'lsa_mask' of class or structure 'l_sigaction_t' may result in an unaligned pointer value [-Waddress-of-packed-member]
        linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask);
                             ^~~~~~~~~~~~~
/usr/src/sys/compat/linux/linux_signal.c:90:38: warning: taking address of packed member 'lsa_mask' of class or structure 'l_sigaction_t' may result in an unaligned pointer value [-Waddress-of-packed-member]
        bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask);
                                            ^~~~~~~~~~~~~
/usr/src/sys/compat/linux/linux_signal.c:651:34: warning: taking address of packed member 'lsi_code' of class or structure 'l_siginfo' may result in an unaligned pointer value [-Waddress-of-packed-member]
        sicode_to_lsicode(si->si_code, &lsi->lsi_code);
                                        ^~~~~~~~~~~~~
3 warnings generated.
/usr/src/sys/amd64/linux32/linux32_sysvec.c:352:29: warning: taking address of packed member 'uc_sigmask' of class or structure 'l_ucontext' may result in an unaligned pointer value [-Waddress-of-packed-member]
        bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
                                   ^~~~~~~~~~~~~~~~~~~~~~
/usr/src/sys/amd64/linux32/linux32_sysvec.c:685:23: warning: taking address of packed member 'uc_sigmask' of class or structure 'l_ucontext' may result in an unaligned pointer value [-Waddress-of-packed-member]
        linux_to_bsd_sigset(&uc.uc_sigmask, &bmask);
                             ^~~~~~~~~~~~~
2 warnings generated.
--------------------------------------------------------------
>>> Kernel build for f2_config completed on Sun Feb  4 14:48:54 UTC 2018
--------------------------------------------------------------
```


----------



## SirDice (Feb 5, 2018)

What's in /etc/make.conf?


----------



## CraigHB (Feb 5, 2018)

There's not much in there, just two lines, `CPUTYPE?=core2` and `MODULES_OVERIDE=linux linux_common linux64`.

I tried building the kernel again after doing a buildworld and it made no difference, exact same warnings.  I've built Linux kernels a lot over the years and learned not to concern myself with a few compiler warnings here and there, but this seems like a lot.

The buildworld process also spits out a ton of similar warnings.  I'm using the release version of 11.1 amd64 with the source tarball from the flash stick.  Shouldn't be any problem with things being compatible.


----------



## CraigHB (Feb 5, 2018)

So pushing ahead the kernel seems to work without issue.  I guess those are just superfluous warnings, a lot of them though.  Got the kernel down to 6.4M from 26M so that's good.  FreeBSD on a stick boots a lot faster with the more reasonably sized kernel.  Still the Linux kernels I was building in the same fashion were well under 3M so I have to wonder about that.  Is the FreeBSD kernel using any compression?  Not a big deal if it doesn't.  These days speed is more of a commodity than space so I'd actually prefer if it doesn't use compression.


----------



## SirDice (Feb 5, 2018)

CraigHB said:


> So pushing ahead the kernel seems to work without issue. I guess those are just superfluous warnings, a lot of them though.


To be honest, I rarely look at warnings. All I'm interested in are the messages at the end, kernel's done and no errors 


CraigHB said:


> Got the kernel down to 6.4M from 26M so that's good.


Keep in mind that everything you don't explicitly put in the kernel is built as a module and will be automatically loaded when needed. So the kernel file may be small, the running kernel may not be. 


CraigHB said:


> Is the FreeBSD kernel using any compression?


Not that I'm aware of. The actual kernel file (/boot/kernel/kernel) isn't compressed.


----------



## CraigHB (Feb 5, 2018)

I always add the -s switch to `make` so only the stderr comes through.  That way it's just the warnings and errors that print to the console.  Otherwise it's a hurricane of text blowing by.

I didn't get the impression the kernel file was compressed, but I didn't know for sure.

I'm not particularly knowledgeable with the mechanics of modules and how the kernel is loaded, just the basic stuff.  I do know on this particular machine the generic kernel does not need to load any modules when it boots.  In this case it's not something to hold against the generic kernel.

I assume (maybe incorrectly) the whole of the kernel file is loaded into memory.  If that's the case the machine I'm using has SDDs and the time it takes to load 6M versus 26M is negligible.  A difference of 20MB is a small fraction of overall RAM so not anything to really consider in terms of memory usage either.  However the machine boots from a flash drive in USB 1.0 mode which is pretty slow.  It does seem to make a difference there.

I don't really notice any performance difference with the generic kernel versus the custom one, but with Linux I've seen it make a difference.  If for no other reason I like it when kernels have all the drivers built-in and don't have to screw around with loading modules.  Also out of principle I don't like the kernel to carry around a bunch of unused drivers.


----------

