Re: How to compile modules with debug symbols

From: Farhan Khan <farhan_at_farhan.codes>
Date: Mon, 21 Apr 2025 23:56:27 UTC
>>> On Dec 18, 2024, at 4:40 AM, Stasia Powless <stasiapowlessjkk42@gmail.com> wrote:
>>> 
>>> 
>>> Hi, everyone. I just learned how to develop modules in FreeBSD.
>>> A simple one with this Makefile
>>> ```
>>> KMOD=   hello
>>> SRCS=   hello.c
>>> 
>>> .include <bsd.kmod.mk>
>>> ```
>>> Type `make` and it works. But no debug symbols by default.
>>> 
>>> There are variables in `sys/conf/kmod.mk` which control the compiling process. But I did not find anyone that can help to add debug symbols.
>>> 
>>> Thanks.

I would also stop the `objcopy` strip command. There's a flag somewhere in the Makefiles to remove it.
I personally add -O0 and -fno-inline-functions. You can add that into /etc/make.conf, 
The first removes any optimizations, such as compressing lines. The second flag flattens inline functions, so they behave like regular functions.

I would like to see a flag in /etc/make.conf that does all this for you in one shot.

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