Build src tree in Develop/Debug mode

From: Farhan Khan <farhan_at_farhan.codes>
Date: Wed, 06 Dec 2023 17:09:59 UTC
Hi all,

Is there a build-in-debug-mode flag I can run when building the kernel (or world)?

I was tinkering through the build system and saw that the optimization is hardcoded to -O2 and objcopy strips debugging symbols. This means even with "CFLAGS+=-g -O0 -fno-inline-functions" in my /etc/make.conf I am still losing symbols and sometimes getting unwanted optimizations. The result is that `kgdb` often does not know what line a crash took place in.

Is there an option to disable all optimizations, optimizations and symbol stripping? If not, IMO, this would be a good candidate for an option to add.

I briefly wrote about this a few years back: https://blog.farhan.codes/2018/08/16/including-optimized-out-kernel-symbols-in-dtrace-on-freebsd/

Thanks!
--
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE