Re: [hatari-devel] Enabling _FORTIFY_SOURCE for Debug builds?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Am Sat, 13 Apr 2024 07:51:44 +0200
schrieb Thorsten Otto <admin@xxxxxxxxxxx>:

> On Freitag, 12. April 2024 20:17:47 CEST Thomas Huth wrote:
> > So why does this not apply to your build?  
> 
> Maybe depends on cmake version? (i'm using 3.27.2)
> 
> The command line that is executed is 
> 
> /usr/bin/cc -DCONFDIR=\"/etc\" -I/home/sebilla/atari/hatari/src/includes -I/
> home/sebilla/atari/hatari/src/debug -I/home/sebilla/atari/hatari/src/falcon -
> I/home/sebilla/atari/hatari/Debug -I/home/sebilla/atari/hatari/src/cpu -I/
> home/sebilla/atari/hatari/src/cpu/. -I/home/sebilla/atari/hatari/src/cpu/../.. 
> -I/home/sebilla/atari/hatari/src/cpu/../includes -I/home/sebilla/atari/hatari/
> src/cpu/softfloat -I/home/sebilla/atari/hatari/Debug/src/cpu -isystem /usr/
> include/SDL2 -O  -std=gnu99 -Wcast-qual -Wbad-function-cast -Wpointer-arith -
> Wmissing-prototypes -Wstrict-prototypes -Wall -Wwrite-strings -Wsign-compare -
> Wformat-security -D_FORTIFY_SOURCE=2 -Wimplicit-fallthrough=2 -Wshadow=local -
> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -O0 -Wno-sign-compare -Wno-
> unused-variable -Wno-shadow=local -Wno-unused-but-set-variable -MD -MT src/
> cpu/CMakeFiles/UaeCpu.dir/cpuemu_11.c.o -MF CMakeFiles/UaeCpu.dir/
> cpuemu_11.c.o.d -o CMakeFiles/UaeCpu.dir/cpuemu_11.c.o -c /home/sebilla/atari/
> hatari/Debug/src/cpu/cpuemu_11.c
> 
> You can see that the "-O" is later overidden by "-O0"

Weird, I'm using 3.27.7 (on Fedora), and for me, it does not add the -O0
after the -g ... but OK, if there are versions that add -O0 automatically,
it's likely better to remove the -D_FORTIFY_SOURCE again. Done now.
 
> Also, debug builds should IMHO not use any optimization. If you try to debug 
> such programs in gdb, the code jumps around like made and it is almost 
> impossible to step through functions.

Hatari without optimization is no fun at all, that's why it's there. And
-O1 should still be fine with debugging, as far as I can tell. I already
considered -Og in the past, too, but I think that might cause problems with
certain compilers, so it's just "-O" for now which should work OK
everywhere.

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/