Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GDAL] switch build to CMake #5423

Merged
merged 8 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 29 additions & 61 deletions G/GDAL/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using BinaryBuilder, Pkg

name = "GDAL"
upstream_version = v"3.5.1"
version_offset = v"0.0.0"
version_offset = v"0.0.1"
version = VersionNumber(upstream_version.major * 100 + version_offset.major,
upstream_version.minor * 100 + version_offset.minor,
upstream_version.patch * 100 + version_offset.patch)
Expand All @@ -13,74 +13,42 @@ version = VersionNumber(upstream_version.major * 100 + version_offset.major,
sources = [
ArchiveSource("https://github.com/OSGeo/gdal/releases/download/v$upstream_version/gdal-$upstream_version.tar.gz",
"7c4406ca010dc8632703a0a326f39e9db25d9f1f6ebaaeca64a963e3fac123d1"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/gdal-*/
mkdir build
cd build

if [[ ${target} == *mingw* ]]; then
export LDFLAGS="-L${libdir}"
# Apply patch to customise PROJ library
atomic_patch -p1 "$WORKSPACE/srcdir/patches/configure_ac_proj_libs.patch"
autoreconf -vi
export PROJ_LIBS="proj_9_1"
elif [[ "${target}" == *-linux-* ]]; then
# Hint to find libstdc++, required to link against C++ libs when using C compiler
if [[ "${nbits}" == 32 ]]; then
export CFLAGS="-Wl,-rpath-link,/opt/${target}/${target}/lib"
else
export CFLAGS="-Wl,-rpath-link,/opt/${target}/${target}/lib64"
fi
# Use same flags also for GEOS
atomic_patch -p1 "$WORKSPACE/srcdir/patches/geos-m4-extra-cflags.patch"
export EXTRA_GEOS_CFLAGS="${CFLAGS}"
if [[ "${target}" == powerpc64le-* ]]; then
atomic_patch -p1 "$WORKSPACE/srcdir/patches/sqlite3-m4-extra-libs.patch"
export EXTRA_GEOS_LIBS="${EXTRA_GEOS_LIBS} -lm"
export EXTRA_SQLITE3_LIBS="-lm"
# libpthread and libldl are needed for libgdal, so let's always use them
export LDFLAGS="$LDFLAGS -lpthread -ldl"
fi
autoreconf -vi
if [[ "${target}" == *-freebsd* ]]; then
# Our FreeBSD libc has `environ` as undefined symbol, so the linker will
# complain if this symbol is used in the built library, even if this won't
# be a problem at runtime. This flag allows having undefined symbols.
export LDFLAGS="-undefined"
Comment on lines +24 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're shifting a linking time error to a runtime error, it doesn't look like a great tradeoff

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's used in a posix_spawnp call. Interestingly that file got this FreeBSD patch recently: OSGeo/gdal@4ff30d5

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it'd probably be better to apply that patch than to change link flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that patch is already included. With or without it I get the same issue, I tried playing around with it a bit. In https://bugs.webkit.org/show_bug.cgi?id=138420 they resolved it by avoiding using environ altogether. Don't know if that is feasible. It is only used once, in this function:

https://github.com/OSGeo/gdal/blob/v3.5.1/port/cpl_spawn.cpp#L578-L612

On this line:

https://github.com/OSGeo/gdal/blob/v3.5.1/port/cpl_spawn.cpp#L708

fi

# same fix as used for PROJ
if [[ "${target}" == x86_64-linux-musl* ]]; then
export LDFLAGS="$LDFLAGS -lcurl"
fi

# Clear out `.la` files since they're often wrong and screw us up
rm -f ${prefix}/lib/*.la

# Read the options in the log file
./configure --help

./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} \
--with-geos=${bindir}/geos-config \
--with-proj=$prefix \
--with-tiff=$prefix \
--with-geotiff=$prefix \
--with-libz=$prefix \
--with-expat=$prefix \
--with-zstd=$prefix \
--with-sqlite3=$prefix \
--with-curl=${bindir}/curl-config \
--with-openjpeg \
--with-python=no \
--enable-shared \
--disable-static

# Make sure that some important libraries are found
grep "HAVE_GEOS='yes'" config.log
grep "HAVE_SQLITE='yes'" config.log
grep "CURL_SETTING='yes'" config.log
grep "ZSTD_SETTING='yes'" config.log
grep "HAVE_EXPAT='yes'" config.log
cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_PREFIX_PATH=${prefix} \
-DCMAKE_FIND_ROOT_PATH=${prefix} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_JAVA_BINDINGS=OFF \
-DBUILD_CSHARP_BINDINGS=OFF \
-DGDAL_USE_CURL=ON \
-DGDAL_USE_EXPAT=ON \
-DGDAL_USE_GEOTIFF=ON \
-DGDAL_USE_GEOS=ON \
-DGDAL_USE_OPENJPEG=ON \
-DGDAL_USE_SQLITE3=ON \
-DGDAL_USE_TIFF=ON \
-DGDAL_USE_ZLIB=ON \
-DGDAL_USE_ZSTD=ON \
..

make -j${nproc}
make install
cmake --build . -j${nproc}
cmake --build . -j${nproc} --target install
"""

# These are the platforms we will build for by default, unless further
Expand Down Expand Up @@ -127,4 +95,4 @@ dependencies = [

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.6", preferred_gcc_version=v"7")
julia_compat="1.6", preferred_gcc_version=v"8")
69 changes: 0 additions & 69 deletions G/GDAL/bundled/patches/configure_ac_proj_libs.patch

This file was deleted.

20 changes: 0 additions & 20 deletions G/GDAL/bundled/patches/geos-m4-extra-cflags.patch

This file was deleted.

20 changes: 0 additions & 20 deletions G/GDAL/bundled/patches/sqlite3-m4-extra-libs.patch

This file was deleted.