Bug 501769 - Build uses -Werror=undef, which makes it fail
Summary: Build uses -Werror=undef, which makes it fail
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Portability-Compilation (show other bugs)
Version: 8.6.0
Platform: NetBSD pkgsrc NetBSD
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-19 23:05 UTC by Thomas Klausner
Modified: 2025-03-20 13:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 8.7.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Klausner 2025-03-19 23:05:05 UTC
When compiling digikam 8.6.0 using dependencies from pkgsrc on NetBSD 10.99.12/x86_64, in particular x265-4.1 and jasper-4.2.4, I see the following compilation error:

In file included from /scratch/wip/digikam/work/.buildlink/include/jasper/jas_version.h:73,
                 from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dialogs/libsinfodlg.cpp:119:
/scratch/wip/digikam/work/.buildlink/include/jasper/jas_config.h:116:6: error: "__STDC_VERSION__" is not defined, evaluates to 0 [-Werror=undef]
  116 | #if (__STDC_VERSION__ - 0 < JAS_STDC_VERSION)
      |      ^~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/jasper/jas_config.h:117:2: warning: #warning "Your code is being built against an older version of the C standard than JasPer was.  Although this is supported, this may require some extra preprocessor defines when building." [-Wcpp]
  117 | #warning "Your code is being built against an older version of the C standard than JasPer was.  Although this is supported, this may require some extra preprocessor defines when building."
      |  ^~~~~~~
In file included from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dialogs/libsinfodlg.cpp:151:
/scratch/wip/digikam/work/.buildlink/include/x265.h:35:5: error: "_MSC_VER" is not defined, evaluates to 0 [-Werror=undef]
   35 | #if _MSC_VER
      |     ^~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:186:5: error: "X265_DEPTH" is not defined, evaluates to 0 [-Werror=undef]
  186 | #if X265_DEPTH < 10
      |     ^~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:643:5: error: "ENABLE_MULTIVIEW" is not defined, evaluates to 0 [-Werror=undef]
  643 | #if ENABLE_MULTIVIEW
      |     ^~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:650:5: error: "ENABLE_ALPHA" is not defined, evaluates to 0 [-Werror=undef]
  650 | #if ENABLE_ALPHA
      |     ^~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:656:5: error: "ENABLE_ALPHA" is not defined, evaluates to 0 [-Werror=undef]
  656 | #if ENABLE_ALPHA || ENABLE_MULTIVIEW
      |     ^~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:656:21: error: "ENABLE_MULTIVIEW" is not defined, evaluates to 0 [-Werror=undef]
  656 | #if ENABLE_ALPHA || ENABLE_MULTIVIEW
      |                     ^~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:665:5: error: "ENABLE_SCC_EXT" is not defined, evaluates to 0 [-Werror=undef]
  665 | #if ENABLE_SCC_EXT
      |     ^~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:2400:5: error: "ENABLE_SCC_EXT" is not defined, evaluates to 0 [-Werror=undef]
 2400 | #if ENABLE_SCC_EXT
      |     ^~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:2618:5: error: "ENABLE_LIBVMAF" is not defined, evaluates to 0 [-Werror=undef]
 2618 | #if ENABLE_LIBVMAF
      |     ^~~~~~~~~~~~~~
/scratch/wip/digikam/work/.buildlink/include/x265.h:2690:5: error: "ENABLE_LIBVMAF" is not defined, evaluates to 0 [-Werror=undef]
 2690 | #if ENABLE_LIBVMAF
      |     ^~~~~~~~~~~~~~

Removing -Werror=undef (via the pkgsrc compiler wrapper) allows the build to finish.

I must confess I'm not sure where it originates from. Grepping the digikam sources I can't find it being set, but after running cmake, it is there all over the place, e.g.

work/digikam-8.6.0/_KDE_build/CMakeFiles/CMakeConfigureLog.yaml:      CMAKE_CXX_FLAGS: "-O2 -g -fstack-clash-protection -pthread -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/ImageMagick-7 -I/usr/pkg/include/freet
ype2 -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/harfbuzz -I/usr/pkg/include/opencv4 -I/usr/pkg/include/ffmpeg6 -I/usr/pkg/include/libdrm -I/usr/pkg/qt6/
include -I/usr/pkg/include/gstreamer-1.0 -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -
Werror=return-type -Werror=init-self -Werror=undef -Wvla"

or

work/digikam-8.6.0/_KDE_build/build.ninja:  FLAGS = -O2 -g -fstack-clash-protection -pthread -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/ImageMagick-7 -I/usr/pkg/include/freetype2 -I/usr/pkg/include/glib-2.0 -I/
usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/harfbuzz -I/usr/pkg/include/opencv4 -I/usr/pkg/include/ffmpeg6 -I/usr/pkg/include/libdrm -I/usr/pkg/qt6/include -I/usr/pkg/include/gstreamer
-1.0 -fno-operator-names -Wall -Wextra  -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Werror=undef -Wvla -Wdate-
time  -Wlogical-op   -Wmissing-include-dirs -fdiagnostics-color=always -Wno-deprecated-copy -fexceptions -fexceptions -std=c++20 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden

In the cmake output I even see:

-- Remove GCC compiler option -Wundef from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/rawengine

so it seems a similar problem was already addressed before.
Perhaps you have some advice on where it comes from or how to avoid it.

(I have a workaround in place for pkgsrc, but thought that users compiling outside pkgsrc might stuble over this, so I thought it better to report this.)
Comment 1 caulier.gilles 2025-03-20 03:49:09 UTC
It's a problem in libjapser, an open source codec for JPEG2000 images.

https://github.com/jasper-software/jasper/issues

Please report this problem as UPSTREAM too.

Note: there is a workaround in digiKam already for this problem, but it's not included all possible compilation cases.

https://invent.kde.org/graphics/digikam/-/blob/master/core/dplugins/dimg/jpeg2000/dimgjpeg2000loader_p.h?ref_type=heads#L53

Gilles Caulier
Comment 2 caulier.gilles 2025-03-20 03:58:24 UTC
Git commit 82eb6e5fe3f1d2c0e4c70887877b52aab757116f by Gilles Caulier.
Committed on 20/03/2025 at 03:57.
Pushed by cgilles into branch 'master'.

fix broken compilation with Jasper under NETBSD

M  +1    -0    core/dplugins/dimg/jpeg2000/dimgjpeg2000loader_p.h

https://invent.kde.org/graphics/digikam/-/commit/82eb6e5fe3f1d2c0e4c70887877b52aab757116f
Comment 3 caulier.gilles 2025-03-20 03:58:59 UTC
Please try my last fix to see if compilation pass as well...
Comment 4 Thomas Klausner 2025-03-20 07:50:37 UTC
jasper already had a bug report about this, and I mentioned the digikam problem there:
https://github.com/jasper-software/jasper/issues/393

The patch is not enough, sadly.

I see other locations e.g.

/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XML_Node.cpp:11:5: error: "AdobePrivate" is not defined, evaluates to 0 [-Werror=undef]
   11 | #if AdobePrivate
      |     ^~~~~~~~~~~~
In file included from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XML_Node.cpp:32:
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMP_Environment.h:23:5: error: "AdobePrivate" is not defined, evaluates to 0 [-Werror=undef]
   23 | #if AdobePrivate
      |     ^~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMP_Environment.h:233:9: error: "_WIN64" is not defined, evaluates to 0 [-Werror=undef]
  233 |     #if _WIN64 || defined(_LP64)
      |         ^~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMP_Environment.h:288:6: error: "XMP_DynamicBuild" is not defined, evaluates to 0 [-Werror=undef]
  288 | #if (XMP_DynamicBuild)
      |      ^~~~~~~~~~~~~~~~
In file included from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCore/XMPCoreDefines.h:25,
                 from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMP_Const.h:2071,
                 from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMLParserAdapter.hpp:52,
                 from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XML_Node.cpp:33:
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCommon/XMPCommonDefines.h:110:14: error: "__clang__" is not defined, evaluates to 0 [-Werror=undef]
  110 |         # if __clang__
      |              ^~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCommon/XMPCommonDefines.h:149:9: error: "SOURCE_COMPILING_XMP_ALL" is not defined, evaluates to 0 [-Werror=undef]
  149 |     #if SOURCE_COMPILING_XMP_ALL || SOURCE_COMPILING_XMPCORE_LIB || SOURCE_COMPILING_XMPCOMPAREANDMERGE_LIB || SOURCE_COMPILING_XMPEXTENSIONS_LIB
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCommon/XMPCommonDefines.h:149:37: error: "SOURCE_COMPILING_XMPCORE_LIB" is not defined, evaluates to 0 [-Werror=undef]
  149 |     #if SOURCE_COMPILING_XMP_ALL || SOURCE_COMPILING_XMPCORE_LIB || SOURCE_COMPILING_XMPCOMPAREANDMERGE_LIB || SOURCE_COMPILING_XMPEXTENSIONS_LIB
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCommon/XMPCommonDefines.h:149:69: error: "SOURCE_COMPILING_XMPCOMPAREANDMERGE_LIB" is not defined, evaluates to 0 [-Werror=undef
]
  149 |     #if SOURCE_COMPILING_XMP_ALL || SOURCE_COMPILING_XMPCORE_LIB || SOURCE_COMPILING_XMPCOMPAREANDMERGE_LIB || SOURCE_COMPILING_XMPEXTENSIONS_LIB
      |                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/public/include/XMPCommon/XMPCommonDefines.h:149:112: error: "SOURCE_COMPILING_XMPEXTENSIONS_LIB" is not defined, evaluates to 0 [-Werror=undef]
  149 |     #if SOURCE_COMPILING_XMP_ALL || SOURCE_COMPILING_XMPCORE_LIB || SOURCE_COMPILING_XMPCOMPAREANDMERGE_LIB || SOURCE_COMPILING_XMPEXTENSIONS_LIB
      |                                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMLParserAdapter.hpp:54:                                                                          08:47:35 [720/1974]
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:390:5: error: "UseNoLock" is not defined, evaluates to 0 [-Werror=undef]
  390 | #if UseNoLock
      |     ^~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:403:7: error: "UseGlobalLibraryLock" is not defined, evaluates to 0 [-Werror=undef]
  403 | #elif UseGlobalLibraryLock
      |       ^~~~~~~~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:418:7: error: "UseBoostLock" is not defined, evaluates to 0 [-Werror=undef]
  418 | #elif UseBoostLock
      |       ^~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:432:7: error: "UsePThreadLock" is not defined, evaluates to 0 [-Werror=undef]
  432 | #elif UsePThreadLock
      |       ^~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:457:7: error: "UseWinSlimLock" is not defined, evaluates to 0 [-Werror=undef]
  457 | #elif UseWinSlimLock
      |       ^~~~~~~~~~~~~~
/scratch/wip/digikam/work/digikam-8.6.0/core/libs/dngwriter/extra/xmp_sdk/source/XMP_LibUtils.hpp:584:5: error: "UseGlobalLibraryLock" is not defined, evaluates to 0 [-Werror=undef]
  584 | #if UseGlobalLibraryLock
      |     ^~~~~~~~~~~~~~~~~~~~


and the one I reported is still there even though libsinfodlg.cpp already has the same pragma, and the compiler reaches that line. I don't understand that.

I.e. in core/libs/dialogs/libsinfodlg.cpp there is
#   if !defined(Q_OS_DARWIN) && defined(Q_CC_GNU)
#       pragma GCC diagnostic push
#       pragma GCC diagnostic ignored "-Wcpp"
#       pragma GCC diagnostic ignored "-Wundef"
#   endif

...

#   include <jasper/jas_version.h>
and I made sure, the compiler executes the first block, but I still get these errors:

In file included from /scratch/wip/digikam/work/.buildlink/include/jasper/jas_version.h:73,
                 from /scratch/wip/digikam/work/digikam-8.6.0/core/libs/dialogs/libsinfodlg.cpp:119:
/scratch/wip/digikam/work/.buildlink/include/jasper/jas_config.h:116:6: error: "__STDC_VERSION__" is not defined, evaluates to 0 [-Werror=undef]
  116 | #if (__STDC_VERSION__ - 0 < JAS_STDC_VERSION)
      |      ^~~~~~~~~~~~~~~~

(and the same for x265.h).
Comment 5 caulier.gilles 2025-03-20 11:46:53 UTC
Git commit a9017f1e2b8fd52eaa73fda38c90119bd357e81f by Gilles Caulier.
Committed on 20/03/2025 at 11:45.
Pushed by cgilles into branch 'master'.

disable this GCC warnings everywhere which break NETBSD compilation

M  +3    -0    core/CMakeLists.txt

https://invent.kde.org/graphics/digikam/-/commit/a9017f1e2b8fd52eaa73fda38c90119bd357e81f
Comment 6 caulier.gilles 2025-03-20 11:47:24 UTC
And with my last commit ?
Comment 7 Thomas Klausner 2025-03-20 12:24:53 UTC
Thank you! Your latest commit applied to 8.6.0 fixes the problem for me.