Skip to content

Commit

Permalink
Upgrade to libvips v8.13.0-rc1 (#144)
Browse files Browse the repository at this point in the history
* Switch libvips build to meson
* Always pass the `--static` flag to pkg-config
* Remove unused build dependencies
  • Loading branch information
kleisauke authored Jun 22, 2022
1 parent 2b748b4 commit 3e4fd28
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 76 deletions.
2 changes: 1 addition & 1 deletion LIBVIPS_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.12.2
8.13.0-rc1
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ for flavour in darwin-x64 darwin-arm64v8; do
export VERSION_VIPS
export PLATFORM

# Use pkg-config provided by Homebrew
export PKG_CONFIG="$(brew --prefix)/bin/pkg-config --static"

# 10.9 should be a good minimal release target
export MACOSX_DEPLOYMENT_TARGET="10.9"

Expand Down
56 changes: 32 additions & 24 deletions build/lin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export LDFLAGS="-L${TARGET}/lib"
# On Linux, we need to create a relocatable library
# Note: this is handled for macOS using the `install_name_tool` (see below)
if [ "$LINUX" = true ]; then
export LDFLAGS+=" -Wl,--gc-sections -Wl,-rpath='\$\$ORIGIN/'"
export LDFLAGS+=" -Wl,--gc-sections -Wl,-rpath=\$ORIGIN/"
fi

if [ "$DARWIN" = true ]; then
Expand All @@ -61,8 +61,6 @@ if [ "$DARWIN" = true ]; then
export PATH="${CARGO_HOME}/bin:${PATH}"
if [ "$PLATFORM" == "darwin-arm64v8" ]; then
export DARWIN_ARM=true
# We need to explicitly tell meson about pkg-config when cross compiling on macOS
export PKG_CONFIG="$(brew --prefix)/bin/pkg-config"
fi
fi

Expand Down Expand Up @@ -184,9 +182,8 @@ if [ "$DARWIN" = true ]; then
fi

if [ "${PLATFORM%-*}" == "linuxmusl" ] || [ "$DARWIN" = true ]; then
# musl includes support for gettext by default, but since we have libintl installed, it favors that.
# macOS requires the standalone intl support library of gettext, since it's not provided by libc.
# In both cases: we use a stub version of gettext instead, since we don't need any of the i18n features.
# musl and macOS requires the standalone intl support library of gettext, since it's not provided by libc (like GNU).
# We use a stub version of gettext instead, since we don't need any of the i18n features.
mkdir ${DEPS}/proxy-libintl
$CURL https://github.com/frida/proxy-libintl/archive/${VERSION_PROXY_LIBINTL}.tar.gz | tar xzC ${DEPS}/proxy-libintl --strip-components=1
cd ${DEPS}/proxy-libintl
Expand Down Expand Up @@ -443,10 +440,12 @@ sed -i'.bak' "/SCRIPTS = /d" Makefile.in
if [[ $CARGO_BUILD_TARGET ]]; then
sed -i'.bak' "s/@RUST_TARGET_SUBDIR@/$CARGO_BUILD_TARGET\/@RUST_TARGET_SUBDIR@/" Makefile.in
fi
./configure --host=${CHOST} --prefix=${TARGET} --enable-static --disable-shared --disable-dependency-tracking \
# Remove the --static flag from the PKG_CONFIG env since Rust does not
# support that. Build with PKG_CONFIG_ALL_STATIC=1 instead.
PKG_CONFIG=${PKG_CONFIG/ --static/} ./configure --host=${CHOST} --prefix=${TARGET} --enable-static --disable-shared --disable-dependency-tracking \
--disable-introspection --disable-tools --disable-pixbuf-loader --disable-nls --without-libiconv-prefix --without-libintl-prefix \
${DARWIN:+--disable-Bsymbolic}
make install-strip
PKG_CONFIG_ALL_STATIC=1 make install-strip

mkdir ${DEPS}/cgif
$CURL https://github.com/dloebl/cgif/archive/V${VERSION_CGIF}.tar.gz | tar xzC ${DEPS}/cgif --strip-components=1
Expand All @@ -457,24 +456,33 @@ ninja -C _build
ninja -C _build install

mkdir ${DEPS}/vips
$CURL https://github.com/libvips/libvips/releases/download/v${VERSION_VIPS}/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
# TODO: Use the tarball for the next release https://github.com/libvips/libvips/issues/2876
#$CURL https://github.com/libvips/libvips/releases/download/v${VERSION_VIPS}/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
$CURL https://github.com/libvips/libvips/archive/refs/tags/v${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
cd ${DEPS}/vips
# Prevent exporting the g_param_spec_types symbol to avoid collisions with shared libraries
printf "{\n\
local:\n\
g_param_spec_types;\n\
};" > vips.map
PKG_CONFIG="pkg-config --static" CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" ./configure \
--host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \
--disable-debug --disable-deprecated --disable-introspection --disable-modules --without-doxygen \
--without-analyze --without-cfitsio --without-fftw --without-libjxl --without-libopenjp2 \
--without-magick --without-matio --without-nifti --without-OpenEXR \
--without-openslide --without-pdfium --without-poppler --without-ppm --without-radiance
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_removing_rpath
sed -i'.bak' 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
# Link libvips.so.42 statically into libvips-cpp.so.42
make -C 'libvips' install-strip LDFLAGS="-static $LDFLAGS"
make -C 'cplusplus' install-strip ${LINUX:+LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions -Wl,--version-script=$DEPS/vips/vips.map"}
sed -i'.bak' "s/library('vips'/static_&/" libvips/meson.build
sed -i'.bak' "/version: library_version/{N;d;}" libvips/meson.build
if [ "$LINUX" = true ]; then
# Ensure symbols from external libs (except for libglib-2.0.a and libgobject-2.0.a) are not exposed
EXCLUDE_LIBS=$(find ${TARGET}/lib -maxdepth 1 -name '*.a' ! -name 'libglib-2.0.a' ! -name 'libgobject-2.0.a' -printf "-Wl,--exclude-libs=%f ")
EXCLUDE_LIBS=${EXCLUDE_LIBS%?}
# Localize the g_param_spec_types symbol to avoid collisions with shared libraries
# See: https://github.com/lovell/sharp/issues/2535#issuecomment-766400693
printf "{local:g_param_spec_types;};" > vips.map
elif [ "$DARWIN" = true ]; then
# https://github.com/pybind/pybind11/issues/595
export STRIP="strip -x"
fi
# Disable building man pages, gettext po files, tools, and (fuzz-)tests
sed -i'.bak' "/subdir('man')/{N;N;N;N;d;}" meson.build
CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" meson setup _build --default-library=shared --buildtype=release --strip --prefix=${TARGET} ${MESON} \
-Ddeprecated=false -Dintrospection=false -Dmodules=disabled -Dcfitsio=disabled -Dfftw=disabled -Djpeg-xl=disabled \
-Dmagick=disabled -Dmatio=disabled -Dnifti=disabled -Dopenexr=disabled -Dopenjpeg=disabled -Dopenslide=disabled \
-Dpdfium=disabled -Dpoppler=disabled -Dquantizr=disabled -Dppm=false -Danalyze=false -Dradiance=false \
${LINUX:+-Dcpp_link_args="$LDFLAGS -Wl,-Bsymbolic-functions -Wl,--version-script=$DEPS/vips/vips.map $EXCLUDE_LIBS"}
ninja -C _build
ninja -C _build install

# Cleanup
rm -rf ${TARGET}/lib/{pkgconfig,.libs,*.la,cmake}
Expand Down
2 changes: 1 addition & 1 deletion build/win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case ${PLATFORM} in
esac

FILENAME="vips-dev-${ARCH}-web-${VERSION_VIPS}-static.zip"
URL="https://github.com/libvips/build-win64-mxe/releases/download/v${VERSION_VIPS}-build2/${FILENAME}"
URL="https://github.com/libvips/build-win64-mxe/releases/download/v${VERSION_VIPS}/${FILENAME}"
echo "Downloading $URL"
$CURL -O $URL
unzip $FILENAME
Expand Down
6 changes: 1 addition & 5 deletions darwin-arm64v8/meson.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ c = 'clang'
cpp = 'clang++'
objc = 'clang'
objcpp = 'clang++'
ar = 'ar'
strip = 'strip'

pkg-config = 'pkg-config'
cmake = 'cmake'
strip = ['strip', '-x']
6 changes: 1 addition & 5 deletions linux-arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ RUN \
# FIXME: Update to devtoolset-11, see: https://bugs.centos.org/view.php?id=18393
devtoolset-10-gcc \
devtoolset-10-gcc-c++ \
glib2-devel \
gobject-introspection-devel \
gperf \
gtk-doc \
jq \
nasm \
prelink \
python3 \
&& \
curl https://sh.rustup.rs -sSf | sh -s -- -y \
Expand All @@ -41,6 +36,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="pkg-config --static" \
PLATFORM="linux-arm64v8" \
CARGO_BUILD_TARGET="aarch64-unknown-linux-gnu" \
FLAGS="-march=armv8-a" \
Expand Down
2 changes: 1 addition & 1 deletion linux-arm64v8/meson.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[binaries]
strip = 'strip'
pkgconfig = 'pkg-config'
pkgconfig = ['pkg-config', '--static']

[built-in options]
libdir = 'lib'
9 changes: 2 additions & 7 deletions linux-armv6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@ RUN \
cmake \
gettext \
git \
gobject-introspection \
gperf \
gtk-doc-tools \
intltool \
jq \
libglib2.0-dev \
libtool \
nasm \
ninja-build \
pkg-config \
python3-pip \
texinfo \
&& \
mkdir /root/tools && \
curl -Ls https://github.com/rvagg/rpi-newer-crosstools/archive/master.tar.gz | tar xzC /root/tools --strip-components=1 && \
Expand All @@ -46,7 +41,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="arm-linux-gnueabihf-pkg-config" \
PKG_CONFIG="arm-linux-gnueabihf-pkg-config --static" \
PLATFORM="linux-armv6" \
CHOST="arm-rpi-linux-gnueabihf" \
RUST_TARGET="arm-unknown-linux-gnueabihf" \
Expand Down
2 changes: 1 addition & 1 deletion linux-armv6/meson.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nm = 'arm-rpi-linux-gnueabihf-gcc-nm'
ld = 'arm-rpi-linux-gnueabihf-gcc-ld'
strip = 'arm-rpi-linux-gnueabihf-strip'
ranlib = 'arm-rpi-linux-gnueabihf-gcc-ranlib'
pkgconfig = 'arm-linux-gnueabihf-pkg-config'
pkgconfig = ['arm-linux-gnueabihf-pkg-config', '--static']

[built-in options]
libdir = 'lib'
9 changes: 2 additions & 7 deletions linux-armv7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ RUN \
crossbuild-essential-armhf \
gettext \
git \
gobject-introspection \
gperf \
gtk-doc-tools \
intltool \
jq \
libglib2.0-dev \
libtool \
nasm \
ninja-build \
pkg-config \
python3-pip \
texinfo \
&& \
curl https://sh.rustup.rs -sSf | sh -s -- -y \
--no-modify-path \
Expand All @@ -45,7 +40,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="arm-linux-gnueabihf-pkg-config" \
PKG_CONFIG="arm-linux-gnueabihf-pkg-config --static" \
PLATFORM="linux-armv7" \
CHOST="arm-linux-gnueabihf" \
RUST_TARGET="arm-unknown-linux-gnueabihf" \
Expand Down
2 changes: 1 addition & 1 deletion linux-armv7/meson.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nm = 'arm-linux-gnueabihf-gcc-nm'
ld = 'arm-linux-gnueabihf-gcc-ld'
strip = 'arm-linux-gnueabihf-strip'
ranlib = 'arm-linux-gnueabihf-gcc-ranlib'
pkgconfig = 'arm-linux-gnueabihf-pkg-config'
pkgconfig = ['arm-linux-gnueabihf-pkg-config', '--static']

[built-in options]
libdir = 'lib'
6 changes: 1 addition & 5 deletions linux-x64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ RUN \
cmake3 \
devtoolset-11-gcc \
devtoolset-11-gcc-c++ \
glib2-devel \
gobject-introspection-devel \
gperf \
gtk-doc \
jq \
nasm \
ninja-build \
prelink \
python3 \
&& \
curl https://sh.rustup.rs -sSf | sh -s -- -y \
Expand All @@ -39,6 +34,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="pkg-config --static" \
PLATFORM="linux-x64" \
FLAGS="-march=westmere" \
MESON="--cross-file=/root/meson.ini"
Expand Down
2 changes: 1 addition & 1 deletion linux-x64/meson.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[binaries]
strip = 'strip'
pkgconfig = 'pkg-config'
pkgconfig = ['pkg-config', '--static']

[built-in options]
libdir = 'lib'
12 changes: 3 additions & 9 deletions linuxmusl-arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ RUN \
curl \
findutils \
git \
glib-dev \
gobject-introspection-dev \
gperf \
gtk-doc \
intltool \
jq \
libtool \
linux-headers \
nasm \
ninja \
python3 \
pkgconf \
py3-pip \
shared-mime-info \
texinfo \
python3 \
&& \
apk --update --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ add advancecomp && \
curl -Ls https://github.com/lovell/aarch64-linux-musl-crosstools/archive/main.tar.gz | tar -hxzC / --strip-components=2 && \
Expand All @@ -50,7 +44,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="aarch64-linux-musl-pkg-config" \
PKG_CONFIG="aarch64-linux-musl-pkg-config --static" \
PLATFORM="linuxmusl-arm64v8" \
CHOST="aarch64-linux-musl" \
RUST_TARGET="aarch64-unknown-linux-musl" \
Expand Down
2 changes: 1 addition & 1 deletion linuxmusl-arm64v8/meson.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nm = 'aarch64-linux-musl-nm'
ld = 'aarch64-linux-musl-ld'
strip = 'aarch64-linux-musl-strip'
ranlib = 'aarch64-linux-musl-ranlib'
pkgconfig = 'aarch64-linux-musl-pkg-config'
pkgconfig = ['aarch64-linux-musl-pkg-config', '--static']

[built-in options]
libdir = 'lib'
9 changes: 2 additions & 7 deletions linuxmusl-x64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ RUN \
curl \
findutils \
git \
glib-dev \
gobject-introspection-dev \
gperf \
gtk-doc \
intltool \
jq \
libtool \
linux-headers \
nasm \
ninja \
pkgconf \
py3-pip \
python3 \
shared-mime-info \
texinfo \
&& \
apk --update --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ add advancecomp && \
curl https://sh.rustup.rs -sSf | sh -s -- -y \
Expand All @@ -47,6 +41,7 @@ RUN \

# Compiler settings
ENV \
PKG_CONFIG="pkg-config --static" \
PLATFORM="linuxmusl-x64" \
FLAGS="-march=westmere"

Expand Down

0 comments on commit 3e4fd28

Please sign in to comment.