mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Enable "debug" optimizations in make develop
Enhances some warnings as well as the sanitizers (Clang especially complained about it) The `-f*` flags are to get better stack traces out of the sanitizers, as recommended by Clang's docs: https://clang.llvm.org/docs/AddressSanitizer.html#usage GCC's docs claim that these optimizations should not hinder the debugging experience, and Clang's don't mention optimization flags at all.
This commit is contained in:
@@ -42,16 +42,18 @@ else()
|
|||||||
-fsanitize=alignment -fsanitize=null -fsanitize=address)
|
-fsanitize=alignment -fsanitize=null -fsanitize=address)
|
||||||
add_compile_options(${SAN_FLAGS})
|
add_compile_options(${SAN_FLAGS})
|
||||||
link_libraries(${SAN_FLAGS})
|
link_libraries(${SAN_FLAGS})
|
||||||
|
# A non-zero optimization level is desired in debug mode, but allow overriding it nonetheless
|
||||||
|
# TODO: this overrides anything previously set... that's a bit sloppy!
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "-g -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MORE_WARNINGS)
|
if(MORE_WARNINGS)
|
||||||
add_compile_options(-Werror -Wextra
|
add_compile_options(-Werror -Wextra
|
||||||
-Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond
|
-Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond
|
||||||
-Wfloat-equal -Winline -Wlogical-op -Wnested-externs -Wold-style-definition
|
-Wfloat-equal -Winline -Wlogical-op -Wnested-externs -Wnull-dereference
|
||||||
-Wshift-overflow=2
|
-Wold-style-definition -Wshift-overflow=2 -Wstrict-overflow=5
|
||||||
-Wstrict-overflow=5 -Wstrict-prototypes -Wundef -Wuninitialized -Wunused
|
-Wstrict-prototypes -Wstringop-overflow=4 -Wundef -Wuninitialized -Wunused
|
||||||
-Wshadow # TODO: -Wshadow=compatible-local ?
|
-Wshadow # TODO: -Wshadow=compatible-local ?
|
||||||
-Wnull-dereference -Wstringop-overflow=4 # TODO: would work better with optimizations
|
|
||||||
-Wno-sign-compare # TODO: fix those warnings
|
-Wno-sign-compare # TODO: fix those warnings
|
||||||
-Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1
|
-Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1
|
||||||
-Wno-format-nonliteral # We have a couple of "dynamic" prints
|
-Wno-format-nonliteral # We have a couple of "dynamic" prints
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -230,7 +230,7 @@ develop:
|
|||||||
-fsanitize=signed-integer-overflow -fsanitize=bounds \
|
-fsanitize=signed-integer-overflow -fsanitize=bounds \
|
||||||
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
|
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
|
||||||
-fsanitize=alignment -fsanitize=null -fsanitize=address" \
|
-fsanitize=alignment -fsanitize=null -fsanitize=address" \
|
||||||
CFLAGS="-ggdb3 -O0"
|
CFLAGS="-ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls"
|
||||||
|
|
||||||
# Targets for the project maintainer to easily create Windows exes.
|
# Targets for the project maintainer to easily create Windows exes.
|
||||||
# This is not for Windows users!
|
# This is not for Windows users!
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ void output_png_file(const struct Options *opts,
|
|||||||
if (!f)
|
if (!f)
|
||||||
err("Opening output png file '%s' failed", outfile);
|
err("Opening output png file '%s' failed", outfile);
|
||||||
|
|
||||||
|
if (opts->debug)
|
||||||
|
free(outfile);
|
||||||
|
|
||||||
img.png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
img.png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (!img.png)
|
if (!img.png)
|
||||||
@@ -135,9 +138,6 @@ void output_png_file(const struct Options *opts,
|
|||||||
|
|
||||||
png_destroy_write_struct(&img.png, &img.info);
|
png_destroy_write_struct(&img.png, &img.info);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (opts->debug)
|
|
||||||
free(outfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_raw_image(struct RawIndexedImage **raw_image_ptr_ptr)
|
void destroy_raw_image(struct RawIndexedImage **raw_image_ptr_ptr)
|
||||||
|
|||||||
Reference in New Issue
Block a user