ip7z / 7zip

7-Zip
858 stars 80 forks source link

Add an option to enable DEBUG build #21

Closed ouankou closed 6 months ago

ouankou commented 8 months ago

I'm packaging 7-zip to a Linux distro. I'm not sure if I missed anything, but it seems that we can't create a DEBUG build unless hacking the makefile. I also see a few similar requests in Sourceforge.

https://github.com/ip7z/7zip/blob/5b39dc76f1bc82f941d5c800ab9f34407a06b53a/CPP/7zip/7zip_gcc.mak#L35-L37

May I open a PR to add an env flag here? like:

CFLAGS_BASE = ... 
ifdef DEBUG_BUILD
CFLAGS_BASE += -g
endif

By default, this change won't make any difference.

ip7z commented 8 months ago

I suppose we must remove -s also in that case:

ifdef DEBUG_BUILD
CFLAGS_DEBUG = -g
else
CFLAGS_DEBUG = -DNDEBUG
ifneq ($(CC), $(CROSS_COMPILE)clang)
LFLAGS_STRIP = -s
endif
endif

CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
 $(CFLAGS_DEBUG) -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
 -fPIC
ouankou commented 8 months ago

Sure, I'll confirm the changes locally and then open a PR.

ouankou commented 8 months ago

Local building and packaging work fine.

cd CPP/7zip/Bundles/Alone2
DEBUG_BUILD=1 make -j -f ../../cmpl_gcc.mak

file b/g/7zz
b/g/7zz: ELF 64-bit LSB pie executable, ..., with debug_info, not stripped
ouankou commented 6 months ago

It's been fixed in the release 24.05.