Re: Build src tree in Develop/Debug mode
- In reply to: Farhan Khan: "Build src tree in Develop/Debug mode"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Dec 2023 02:17:14 UTC
> On Dec 7, 2023, at 1:09 AM, Farhan Khan <farhan@farhan.codes> wrote: > > 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. There's an option COPTFLAGS. You can try ``` $ setenv COPTFLAGS -O0 $ make buildkernel KERNCONF=GENERIC ``` > > 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 > > Best regards, Zhenlei