OpenBLAS icon indicating copy to clipboard operation
OpenBLAS copied to clipboard

Makefiles need to turn off optimizations for DEBUG=1

Open ChipKerchner opened this issue 1 year ago • 4 comments

It makes it challenging to debug issues when optimizations are turned on and using gdb. All optimizations should be set to -O0 for DEBUG=1.

ChipKerchner avatar Sep 08 '24 22:09 ChipKerchner

I guess that depends on target on compiler, at least "-O2 -g" is a valid combination of options and it has been that way "forever". You can set COMMON_OPT=-O0 if needed.

martin-frbg avatar Sep 09 '24 07:09 martin-frbg

Yes, it is a valid combo but within gdb you can not inspect a lot of variables when any optimization is turned on.

Every time I want to use gdb, I have to manually modify the optimization flags in Makefile.system and Makefile.power.

It would be nice to not have to do this. I'll probably submit a PR later with the changes to Makefile.power

ChipKerchner avatar Sep 09 '24 13:09 ChipKerchner

Something like this

ifeq ($(DEBUG), 1)
OPT_FLAGF = -O0
OPT_FLAG1 = -O0
OPT_FLAG2 = -O0
else
OPT_FLAGF = -Ofast
OPT_FLAG1 = -O1
OPT_FLAG2 = -O2
endif

ChipKerchner avatar Sep 09 '24 13:09 ChipKerchner

OK. Makefile.power is different from the other Makefile.<arch> in this regard, which is probably not a good idea anyway.

martin-frbg avatar Sep 09 '24 13:09 martin-frbg

should be fixed by #4979

martin-frbg avatar Nov 17 '24 23:11 martin-frbg