Skip to content

Commit

Permalink
Select optimisation level per dependency (#56)
Browse files Browse the repository at this point in the history
Use a default optimisation level of `-Os`, selectively compile with
`-O3` for dependencies that benefit.

Resolves: #55.
  • Loading branch information
kleisauke committed Sep 30, 2023
1 parent 41e8e1c commit df96594
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions build/cgif.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $(PKG)_GH_CONF := dloebl/cgif/tags,V
$(PKG)_DEPS := cc meson-wrapper

define $(PKG)_BUILD
$(eval export CFLAGS += -O3)

$(MXE_MESON_WRAPPER) \
-Dtests=false \
'$(SOURCE_DIR)' \
Expand Down
3 changes: 3 additions & 0 deletions build/highway.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ $(PKG)_DEPS := cc
# Dynamic dispatch requires Linux to detect CPU capabilities on both Armv7
# and AArch64.
define $(PKG)_BUILD
$(eval export CFLAGS += -O3)
$(eval export CXXFLAGS += -O3)

cd '$(BUILD_DIR)' && $(TARGET)-cmake \
-DBUILD_TESTING=OFF \
-DHWY_ENABLE_CONTRIB=OFF \
Expand Down
3 changes: 3 additions & 0 deletions build/libheif.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ $(PKG)_GH_CONF := strukturag/libheif/releases,v
$(PKG)_DEPS := cc aom

define $(PKG)_BUILD
$(eval export CFLAGS += -O3)
$(eval export CXXFLAGS += -O3)

# Disable multithreading when building with Win32 threads to
# avoid a dependency on mingw-std-threads (which we only use
# in the "all" variant). Disabling multithreading only affects
Expand Down
2 changes: 2 additions & 0 deletions build/libimagequant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $(PKG)_GH_CONF := lovell/libimagequant/tags,v
$(PKG)_DEPS := cc meson-wrapper

define $(PKG)_BUILD
$(eval export CFLAGS += -O3)

$(MXE_MESON_WRAPPER) '$(SOURCE_DIR)' '$(BUILD_DIR)'

$(MXE_NINJA) -C '$(BUILD_DIR)' -j '$(JOBS)' install
Expand Down
2 changes: 2 additions & 0 deletions build/libspng.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $(PKG)_GH_CONF := randy408/libspng/tags,v
$(PKG)_DEPS := cc meson-wrapper zlib

define $(PKG)_BUILD
$(eval export CFLAGS += -O3)

# -Denable_opt=false is a workaround for:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109504
$(MXE_MESON_WRAPPER) \
Expand Down
2 changes: 2 additions & 0 deletions build/overrides.mk
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ endef
# build with -DCMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT to avoid a
# horrible hack (we don't target pre-Windows XP, so it should be safe)
define lcms_BUILD
$(eval export CFLAGS += -O3)

$(MXE_MESON_WRAPPER) \
-Djpeg=disabled \
-Dtiff=disabled \
Expand Down
2 changes: 2 additions & 0 deletions build/plugins/zlib-ng/zlib-ng.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $(PKG)_GH_CONF := zlib-ng/zlib-ng/tags
$(PKG)_DEPS := cc

define $(PKG)_BUILD
$(eval export CFLAGS += -O3)

cd '$(BUILD_DIR)' && '$(TARGET)-cmake' \
-DZLIB_COMPAT=ON \
-DZLIB_ENABLE_TESTS=OFF \
Expand Down
6 changes: 4 additions & 2 deletions build/settings/gcc-release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
MXE_TMP := /var/tmp

# Special flags for compiler.
export CFLAGS := -s -O3 -fPIC
export CXXFLAGS := -s -O3 -fPIC
# Default optimisation level is for binary size (-Os).
# Overriden to performance (-O3) for select dependencies that benefit.
export CFLAGS := -s -Os -fPIC
export CXXFLAGS := -s -Os -fPIC
export LDFLAGS := -Wl,-s

# Special flags for Rust.
Expand Down
6 changes: 4 additions & 2 deletions build/settings/llvm-release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
MXE_TMP := /var/tmp

# Special flags for compiler.
export CFLAGS := -O3 -g -gcodeview -fdata-sections -ffunction-sections
export CXXFLAGS := -O3 -g -gcodeview -fdata-sections -ffunction-sections
# Default optimisation level is for binary size (-Os).
# Overriden to performance (-O3) for select dependencies that benefit.
export CFLAGS := -Os -g -gcodeview -fdata-sections -ffunction-sections
export CXXFLAGS := -Os -g -gcodeview -fdata-sections -ffunction-sections
export LDFLAGS := -Wl,--pdb= -Wl,--gc-sections -Wl,-s

# Special flags for Rust.
Expand Down
3 changes: 3 additions & 0 deletions build/vips-all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ endef
define $(PKG)_BUILD
$($(PKG)_PRE_CONFIGURE)

$(eval export CFLAGS += -O3)
$(eval export CXXFLAGS += -O3)

$(MXE_MESON_WRAPPER) \
-Ddeprecated=false \
-Dexamples=false \
Expand Down
3 changes: 3 additions & 0 deletions build/vips-web.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ endef
define $(PKG)_BUILD
$($(PKG)_PRE_CONFIGURE)

$(eval export CFLAGS += -O3)
$(eval export CXXFLAGS += -O3)

# Always build as shared library, we need
# libvips-42.dll for the language bindings.
$(MXE_MESON_WRAPPER) \
Expand Down

0 comments on commit df96594

Please sign in to comment.