[Bug 274061] graphics/gdal Fix TILEDB knob, tame a bit of overzealous cmake auto-feature creep for good measure

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 24 Sep 2023 04:54:48 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274061

            Bug ID: 274061
           Summary: graphics/gdal Fix TILEDB knob, tame a bit of
                    overzealous cmake auto-feature creep for good measure
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: sunpoet@FreeBSD.org
          Reporter: alt2600@icloud.com
             Flags: maintainer-feedback?(sunpoet@FreeBSD.org)
          Assignee: sunpoet@FreeBSD.org

Created attachment 245176
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=245176&action=edit
git-fixtiledb-tamecmake.diff

amd64 13.2, live system building

With the update to tiledb the knob broke in gdal with the following error
during the tiledb module build

FAILED: frmts/tiledb/CMakeFiles/gdal_TileDB.dir/tiledbcommon.cpp.o 
/usr/bin/c++ -DDONT_DEPRECATE_SPRINTF -DGDAL_COMPILATION -DTILEDB_DEPRECATED=""
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/apps
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/alg
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/gcore
-I/usr/ports/graphics/gdal/work/.build/gcore
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/port
-I/usr/ports/graphics/gdal/work/.build/port
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/ogr
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/ogr/ogrsf_frmts
-I/usr/ports/graphics/gdal/work/gdal-3.7.2/frmts -O2 -pipe -march=westmere 
-DInt64=uint64_t -DLIBICONV_PLUG -fstack-protector-strong -isystem
/usr/local/include -fno-strict-aliasing   -DLIBICONV_PLUG -isystem
/usr/local/include -std=c++17 -fno-finite-math-only -fvisibility=hidden -O2
-pipe -march=westmere  -DInt64=uint64_t -DLIBICONV_PLUG
-fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  
-DLIBICONV_PLUG -isystem /usr/local/include -std=c++17  -DNDEBUG -std=c++17
-flto=thin -fPIC -Wall -Wextra -Winit-self -Wunused-parameter
-Wmissing-declarations -Wshorten-64-to-32 -Wshadow -Wshadow-field
-Wmissing-include-dirs -Wformat -Werror=format-security -Wno-format-nonliteral
-Werror=vla -Wdate-time -Wnull-dereference -Wextra-semi -Wcomma
-Wfloat-conversion -Wdocumentation -Wno-documentation-deprecated-sync
-Wunused-private-field -Wnon-virtual-dtor -Woverloaded-virtual
-Wsuggest-override -fno-operator-names -Wzero-as-null-pointer-constant -MD -MT
frmts/tiledb/CMakeFiles/gdal_TileDB.dir/tiledbcommon.cpp.o -MF
frmts/tiledb/CMakeFiles/gdal_TileDB.dir/tiledbcommon.cpp.o.d -o
frmts/tiledb/CMakeFiles/gdal_TileDB.dir/tiledbcommon.cpp.o -c
/usr/ports/graphics/gdal/work/gdal-3.7.2/frmts/tiledb/tiledbcommon.cpp
In file included from
/usr/ports/graphics/gdal/work/gdal-3.7.2/frmts/tiledb/tiledbcommon.cpp:29:
In file included from
/usr/ports/graphics/gdal/work/gdal-3.7.2/frmts/tiledb/tiledbheaders.h:50:
In file included from /usr/local/include/tiledb/tiledb:49:
In file included from /usr/local/include/tiledb/array.h:38:
In file included from /usr/local/include/tiledb/array_schema.h:38:
In file included from /usr/local/include/tiledb/attribute.h:38:
In file included from /usr/local/include/tiledb/context.h:38:
In file included from /usr/local/include/tiledb/config.h:39:
In file included from /usr/local/include/tiledb/utils.h:36:
In file included from /usr/local/include/tiledb/exception.h:39:
/usr/local/include/tiledb/type.h:51:9: error: token is not a valid binary
operator in a preprocessor subexpression
#if not defined(__clang__) && __GNUG__ && __GNUC__ < 5
    ~~~ ^
1 error generated.

after stubbing the pre-processor code into a test stub file and trying all the
compile options until the error stopped it building I found it was because
cmake compiler checks included in gdal explicitly auto enable this flag if
supported by the compiler -fno-operator-names . this is a problem because
tiledb type.h above uses not instead of ! to fix an issue for old gcc versions,
and that flag explicitly dis-allows using not over !. after fighting with cmake
I eventually found TILEDB_CMAKE_BOOL_OFF= HAVE_FLAG_NO_OPERATOR_NAMES to
disable that check when tiledb is turned on and it now builds, and things like
qgis use it fine. Gdal upstream should likely disable that check entirely if
they want to support tiledb, I have no idea why a person would want that on,
unless its a standards thing, then maybe tiledb should change their header, but
maybe can't given its for an old gcc version, I don't know. Given how many
times I ran make clean configure i noticed a few other greedy checks and so
found was to tame them. Basically disabling finding swig, python, jni, and java
given no bindings are listed, and it could cause issues given it doesn't
necessarily find the default python anyway, since python.mk is never invoked.
Quality of life for live system ports builders to get closer to pkg repo
builds, though I tried some of these first as my initial thought was python
3.10 instead of 3.9 being found was somehow breaking the TILEDB knob, but it
appears unrelated. I think it will lead to wild and painful debugging should
someone stumble onto unregistered dependencies breaking their builds or having
unpredictable builds because of cmake greed.

#On live system builds, triggers potential PR 262109 issue if swig is found, by
also calling FindPython routines. 
#If python alone is found it also triggers the issue. Disable explicitly for
consistent builds given no bindings are built here, as well as jni/java for
good measure
CMAKE_ARGS+= -DCMAKE_DISABLE_FIND_PACKAGE_SWIG:BOOL=true
-DCMAKE_DISABLE_FIND_PACKAGE_Python:BOOL=true
-DCMAKE_DISABLE_FIND_PACKAGE_JNI:BOOL=true
-DCMAKE_DISABLE_FIND_PACKAGE_Java:BOOL=true

I also found that Jpeg-XL is greedily added in, but at least it seems to be an
option maybe a knob can be added for GDAL_USE_JXL, I didn't disable at this
time as it wasn't causing issues, when it breaks I'll post a patch for the
knob. I figured that would require a PORTREVISION. I also found that it seems
to automatically be doing LTO, but likely this is going to happen with the repo
builds too as it is likely just a compiler check. Unlike tiledb, its AVX checks
do not seem to auto add AVX compiler flags, or maybe just lucky this isn't
doing much vector math. cmake is a wild build system.

anyway, TILEDB knob is now working again with the posted patch. I think
limiting the scope of cmake's wild finds is a good idea too, but you can chose
to use or not use as you see fit. Not sure if technically turning off python
finding should be a PORTREVISION, but since Swig wouldn't be there, I don't
think it would be doing any python in the port.

-- 
You are receiving this mail because:
You are the assignee for the bug.