Commit cfc3985f authored by Debarshi Ray's avatar Debarshi Ray

build: Restore optimized builds by default

Building with AX_CHECK_ENABLE_DEBUG([yes]), which is what happens by
default for non-release builds, turns off compiler optimizations and
overrides any optimization specified via CFLAGS in the build
environment. This means that the nightly Flatpaks, and almost all
other non-release builds, are built without any optimization. It's
very likely that this has a negative impact on the image processing
loops in the built-in GeglOperations.

It can be useful to turn off compiler optimizations to get a better
debugging experience, but it becomes a problem if it stomps over the
build environment while doing so. The person doing the builds should
should get to decide between ease of debugging and reasonable
performance. After all, debugging is not the only thing that a
developer does. Performance measurements are important too, and one can
use GDB reasonably well with the Autoconf default, which also happens
to be what most distributions use, of "-g O2".

This wouldn't have been such a problem if AX_CHECK_ENABLE_DEBUG
attached its flags before the values from the environment instead of
after, because in case of multiple -O options, the last such option is
the one that's effective.

Thankfully, "no" doesn't override the environment, which is what
happens for release builds, and distributions generally set their own
CFLAGS. Otherwise every single user-facing build would have been
broken. Note that any release build without CFLAGS set in the
environment would neither get debug symbols (ie., no "-g") nor any
compiler optimization because AX_CHECK_ENABLE_DEBUG always suppresses
the Autoconf defaults of "-g -O2".

One solution could have been to default to "info" for non-release
builds and recommend the use of --enable-debug=info while building from
Git, but that would not address release builds without CFLAGS.

Given that the only other thing the macro does is to define the NDEBUG
pre-processor macro when debugging is set to "no", which isn't widely
used in the GLib-based GNOME platform [1], it seems better to just
remove it altogether.

Interestingly, this also seems to unmask some valid cases of
-Wclobbered and -Wmaybe-uninitialized with Fedora's
gcc-7.3.1-6.fc27.x86_64 build.

Fallout from 8f6fb686. The deprecated
GNOME_DEBUG_CHECK macro didn't set any debugging or optimization flags.

[1] glib/gio/xdgmime is the only widely used code path where assert(3)
    is used. It's also used in gio/kqueue/dep-list.c, which is
    *BSD-specific and in GTK+'s Broadway backend. All those can
    probably be replaced with g_assert*.
parent a32315f3
......@@ -17,7 +17,6 @@ AM_MAINTAINER_MODE([enable])
AX_IS_RELEASE([git-directory])
AX_CHECK_ENABLE_DEBUG([yes],,, [$ax_is_release])
AX_COMPILER_FLAGS([WARN_CFLAGS],
[WARN_LDFLAGS],
[$ax_is_release],
......
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
#
# DESCRIPTION
#
# Check for the presence of an --enable-debug option to configure, with
# the specified default value used when the option is not present. Return
# the value in the variable $ax_enable_debug.
#
# Specifying 'yes' adds '-g -O0' to the compilation flags for all
# languages. Specifying 'info' adds '-g' to the compilation flags.
# Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
# the linking flags. Otherwise, nothing is added.
#
# Define the variables listed in the second argument if debug is enabled,
# defaulting to no variables. Defines the variables listed in the third
# argument if debug is disabled, defaulting to NDEBUG. All lists of
# variables should be space-separated.
#
# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
# Should be invoked prior to any AC_PROG_* compiler checks.
#
# IS-RELEASE can be used to change the default to 'no' when making a
# release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
# uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
# macro, there is no need to pass this parameter.
#
# AX_IS_RELEASE([git-directory])
# AX_CHECK_ENABLE_DEBUG()
#
# LICENSE
#
# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
#serial 8
AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
AC_BEFORE([$0],[AC_PROG_CC])dnl
AC_BEFORE([$0],[AC_PROG_CXX])dnl
AC_BEFORE([$0],[AC_PROG_F77])dnl
AC_BEFORE([$0],[AC_PROG_FC])dnl
AC_MSG_CHECKING(whether to enable debugging)
ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
[$ax_is_release],
[$4])))
# If this is a release, override the default.
AS_IF([test "$ax_enable_debug_is_release" = "yes"],
[ax_enable_debug_default="no"])
m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
[],enable_debug=$ax_enable_debug_default)
# empty mean debug yes
AS_IF([test "x$enable_debug" = "x"],
[enable_debug="yes"])
# case of debug
AS_CASE([$enable_debug],
[yes],[
AC_MSG_RESULT(yes)
CFLAGS="${CFLAGS} -g -O0"
CXXFLAGS="${CXXFLAGS} -g -O0"
FFLAGS="${FFLAGS} -g -O0"
FCFLAGS="${FCFLAGS} -g -O0"
OBJCFLAGS="${OBJCFLAGS} -g -O0"
],
[info],[
AC_MSG_RESULT(info)
CFLAGS="${CFLAGS} -g"
CXXFLAGS="${CXXFLAGS} -g"
FFLAGS="${FFLAGS} -g"
FCFLAGS="${FCFLAGS} -g"
OBJCFLAGS="${OBJCFLAGS} -g"
],
[profile],[
AC_MSG_RESULT(profile)
CFLAGS="${CFLAGS} -g -pg"
CXXFLAGS="${CXXFLAGS} -g -pg"
FFLAGS="${FFLAGS} -g -pg"
FCFLAGS="${FCFLAGS} -g -pg"
OBJCFLAGS="${OBJCFLAGS} -g -pg"
LDFLAGS="${LDFLAGS} -pg"
],
[
AC_MSG_RESULT(no)
dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
dnl by setting any unset environment flag variables
AS_IF([test "x${CFLAGS+set}" != "xset"],
[CFLAGS=""])
AS_IF([test "x${CXXFLAGS+set}" != "xset"],
[CXXFLAGS=""])
AS_IF([test "x${FFLAGS+set}" != "xset"],
[FFLAGS=""])
AS_IF([test "x${FCFLAGS+set}" != "xset"],
[FCFLAGS=""])
AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
[OBJCFLAGS=""])
])
dnl Define various variables if debugging is disabled.
dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
AS_IF([test "x$enable_debug" = "xyes"],
[m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
[m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
ax_enable_debug=$enable_debug
])
......@@ -132,13 +132,14 @@ photos_image_view_calculate_best_fit_zoom (PhotosImageView *self, gdouble *out_z
gint allocation_width_scaled;
gint scale_factor;
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
if (!photos_image_view_has_allocation_and_extent (self))
goto out;
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
bbox = *gegl_buffer_get_extent (self->buffer);
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
allocation_height_scaled = allocation.height * scale_factor;
allocation_width_scaled = allocation.width * scale_factor;
......
......@@ -117,7 +117,10 @@ photos_operation_png_guess_sizes_count (GeglBuffer *buffer,
goto out;
if (setjmp (png_jmpbuf (png_ptr)))
goto out;
{
ret_val = 0;
goto out;
}
if (compression >= 0)
png_set_compression_level (png_ptr, compression);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment