1
0
mirror of https://git.freebsd.org/ports.git synced 2026-06-02 11:08:52 +00:00

graphics/rawtherapee: Add GCC (14) build option, clean up

Clear the way for making GCC 15 the default GCC version for ports
(through USE_GCC=yes), and set USE_GCC=14 for this port.

GCC 15 and libc++ aren't compatible today because our (base) libc++'s
header files around C++ type traits are rejected by GCC 15, which wants
us to use library traits instead of (new) trait built-ins such as __decay
on function signatures.  This isn't trivial to fix, so use the version
pin to GCC 14 so that everyone else can benefit from 15.

(Using libstdc++ with GCC instead would require the C++ libraries that
expose C++ ABIs in the ports tree, Exiv2, Glib-derivatives be recompiled
in a libstdc++ flavour and possibly be duplicated in a separate install
path. Let's not go to these double efforts yet.)

WARNING: on FreeBSD 15.0 amd64, clang-compiled rawtherapee requires
twice as much CPU time on a certain test file batch conversion set than
the GCC-compiled rawtherapee, so if you can, leave the GCC option on.

While here, clean up the Makefile a bit.

NOTE: the clang default build needs options tweaked a bit differently,
and since the base compiler does not look into ${LOCALBASE}/include and
${LOCALBASE}/lib by default, we need to patch the rtengine/LibRaw.cmake
wrapper to pass down proper -I and -L flags to libraw's
autoconf/automake/libtool rig; we obtain them through pkg-config because
cmake, although it already knows where to look, does not expose them
through variables, as of 2026-02-22's ports cmake version.

PR:		292692 (making GCC 15 default version)
PR:		293329 (rawtherapee)
Reported by:	salvadore@
Pull Request:	https://github.com/freebsd/freebsd-ports/pull/504
This commit is contained in:
Matthias Andree
2026-02-22 21:51:27 +01:00
committed by Gleb Popov
parent 53275e99c7
commit b16813c9c2
3 changed files with 88 additions and 41 deletions
+45 -41
View File
@@ -1,6 +1,6 @@
PORTNAME= rawtherapee
PORTVERSION= 5.12
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= graphics
MASTER_SITES= https://github.com/RawTherapee/RawTherapee/releases/download/${PORTVERSION}/ \
https://rawtherapee.com/shared/source/ \
@@ -36,22 +36,6 @@ USES= autoreconf:build cmake desktop-file-utils compiler:c++11-lib gnome \
USE_GNOME= gtkmm30 librsvg2
_LTO_FLAGS= -flto=${MAKE_JOBS_NUMBER}
# gcc needs -flto=${MAKE_JOBS_NUMBER} for parallel link (fixed in GCC 10?)
# and does not understand -flto=thin
#
# llvm/clang needs -flto=thin and will automatically parallelize the link
# Fix <https://bugs.freebsd.org/251041>:
# 11.x has binutils that don't accept a --plugin option,
# and gcc-ar9 appears to grab those, so make sure that USE_BINUTILS
# override those in /usr/bin which usually is first in the PATH,
# before ${LOCALBASE}/bin.
# (For some reason, poudriere does not trigger this.)
BINARY_ALIAS+= ar=${AR} ranlib=${RANLIB}
#
_AR= ${CC:S/gcc/gcc-ar/}
_RANLIB= ${CC:S/gcc/gcc-ranlib/}
CMAKE_ARGS+= -DDOCDIR="${DOCSDIR}" \
-DCREDITSDIR="${DOCSDIR}" \
-DLICENCEDIR="${DOCSDIR}" \
@@ -62,7 +46,7 @@ CMAKE_ARGS+= -DDOCDIR="${DOCSDIR}" \
-DCMAKE_AR:FILEPATH=${_AR} \
-DCMAKE_RANLIB:FILEPATH=${_RANLIB} \
-DCMAKE_POLICY_DEFAULT_CMP0056:STRING=NEW
CONFIGURE_ENV+= AR=${_AR} RANLIB=${_RANLIB} # for embedded RawTherapee
CONFIGURE_ENV+= AR=${_AR} RANLIB=${_RANLIB} # for embedded LibRaw
# 3.4.x: CMAKE_EXE_LINKER_FLAGS is not passed to TRY_COMPILE by default
# any more. The CMP0056 policy must be explicitly set to NEW to ensure
# linker flags are passed. Else -lomp is not found with clang.
@@ -70,14 +54,25 @@ CONFIGURE_ENV+= AR=${_AR} RANLIB=${_RANLIB} # for embedded RawTherapee
CFLAGS+= -I${LOCALBASE}/include -fPIC ${_OPT_FLAGS}
LDFLAGS+= -Wl,--as-needed -lpthread ${_OPT_FLAGS}
PIE_UNSAFE= yes
# Fix <https://bugs.freebsd.org/251041>:
# Make sure that USE_BINUTILS override those in /usr/bin
# which usually is first in the PATH, before ${LOCALBASE}/bin:
# (For some reason, poudriere does not trigger this.)
BINARY_ALIAS+= ar=${_AR} ranlib=${_RANLIB}
.if defined(PACKAGE_BUILDING) && empty(CFLAGS:M-march*) && (${ARCH} == i386 || ${ARCH} == amd64 || ${ARCH} == aarch64)
# this gets translated to -mtune=generic, see ${WRKSRC}/ProcessorTargets.cmake
# and as of GCC 8.3, it appears that among FreeBSD's supported architectures,
# only the three listed above support this GCC option.
CMAKE_ARGS+= -DPROC_TARGET_NUMBER="1"
.endif
OPTIONS_DEFINE= DOCS GCC LTO NATIVE
OPTIONS_DEFINE_amd64= OPENMP
OPTIONS_DEFINE_i386= OPENMP
OPTIONS_DEFAULT= OPENMP GCC LTO
GCC_DESC= Build with ports's GCC 14 (newer fail with libc++)
NATIVE_DESC= Use -march=native (avoid for generic packages!)
OPENMP_DESC= Enable OpenMP parallel processing (i386/amd64 only)
LTO_CFLAGS= ${_LTO_FLAGS}
LTO_LDFLAGS= ${_LTO_FLAGS}
NATIVE_CMAKE_ON= -DPROC_TARGET_NUMBER="2"
OPENMP_CMAKE_BOOL= OPTION_OMP
OPENMP_LDFLAGS= -lm -lomp
# For gcc-based builds, rawtherapee's cmake ends up with GCC's absolute path
# in the CC/CXX variables, effectively disabling ccache. Wrap compiler in ccache explicitly.
@@ -90,30 +85,39 @@ CMAKE_ARGS+= -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE_BIN} \
-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_BIN}
.endif
OPTIONS_DEFINE= DOCS NATIVE LTO
OPTIONS_DEFINE_amd64= OPENMP
OPTIONS_DEFINE_i386= OPENMP
OPTIONS_DEFAULT= OPENMP LTO
NATIVE_DESC= Use -march=native (avoid for generic packages!)
OPENMP_DESC= Enable OpenMP parallel processing (i386/amd64 only)
LTO_CFLAGS= ${_LTO_FLAGS}
LTO_LDFLAGS= ${_LTO_FLAGS}
NATIVE_CMAKE_ON= -DPROC_TARGET_NUMBER="2"
OPENMP_CMAKE_BOOL= OPTION_OMP
OPENMP_LDFLAGS= -lm -lomp
.include <bsd.port.options.mk>
# -------------------------------------------------------------------
# Older clang versions (for instance clang 9.0, as of 2019-09-29),
# were known to miscompile RawTherapee, causing SIGSEGV or SIBGUS.
# As of 2024-02, GCC-12.3 compiled RawTherapee appears to be
# up to twice as fast as clang-16.0 compiled code.
# So we shall stick to a modern GCC for now.
#
USE_GCC= yes # default
# However, as of 2026-02-20, GCC-15 fails to build with
# -stdlib=libc++, and without it, we get link-time failures
# because the C++ libraries such as Exiv2 and Glib-related
# use the libc++ ABI, so we can't move to GCC 15.
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293329 (port)
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292692 (meta)
#
.if !empty(PORT_OPTIONS:MGCC)
USE_GCC= 14 # pin 14 for now, 15 incompatible
_LTO_FLAGS= -flto=${MAKE_JOBS_NUMBER}
_AR= ${CC:S/gcc/gcc-ar/}
_RANLIB= ${CC:S/gcc/gcc-ranlib/}
.else
# default path, usually clang
_LTO_FLAGS= -flto=thin
_AR= ${AR}
_RANLIB= ${RANLIB}
.endif
.if empty(PORT_OPTIONS:MNATIVE) && empty(CFLAGS:M-march*) && (${ARCH} == i386 || ${ARCH} == amd64 || ${ARCH} == aarch64)
# this gets translated to -mtune=generic, see ${WRKSRC}/ProcessorTargets.cmake
# and as of GCC 8.3, it appears that among FreeBSD's supported architectures,
# only the three listed above support this GCC option.
CMAKE_ARGS+= -DPROC_TARGET_NUMBER="1"
.endif
.if (${OPSYS} == FreeBSD) && (${OSVERSION} >= 1500000)
# don't waste everybody's time with Tier-2 and moving targets.
@@ -0,0 +1,13 @@
Strip warnings we don't need to see as packagers:
--- CMakeLists.txt.orig 2025-05-28 01:02:22 UTC
+++ CMakeLists.txt
@@ -662,7 +662,7 @@ set(CMAKE_CXX_FLAGS
endif()
set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result -Wunused-macros"
+ "${CMAKE_CXX_FLAGS} -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result"
)
if(OPTION_OMP)
find_package(OpenMP)
@@ -0,0 +1,30 @@
--- rtengine/LibRaw.cmake.orig 2025-05-28 01:02:22 UTC
+++ rtengine/LibRaw.cmake
@@ -33,6 +33,27 @@ execute_process(
# Configuration commands.
message(STATUS "Configuring LibRaw")
execute_process(
+ COMMAND pkg-config --cflags-only-I libjpeg
+ RESULT_VARIABLE PROCESS_RESULT
+ OUTPUT_VARIABLE JPEG_BIGI_FLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+if(PROCESS_RESULT AND NOT PROCESS_RESULT EQUAL 0)
+ message(FATAL_ERROR "Could not obtain libjpeg -I flags from pkg-config")
+endif()
+execute_process(
+ COMMAND pkg-config --libs-only-L libjpeg
+ RESULT_VARIABLE PROCESS_RESULT
+ OUTPUT_VARIABLE JPEG_BIGL_FLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+if(PROCESS_RESULT AND NOT PROCESS_RESULT EQUAL 0)
+ message(FATAL_ERROR "Could not obtain libjpeg -L flags from pkg-config")
+endif()
+message(STATUS "libjpeg flags (from pkg-config): CFLAGS=\"${JPEG_BIGI_FLAGS}\" LIBS=\"${JPEG_BIGL_FLAGS}\"")
+set(CONFIGURE_FLAGS "${CONFIGURE_FLAGS} CFLAGS=\"${CFLAGS} ${JPEG_BIGI_FLAGS}\"")
+set(CONFIGURE_FLAGS "${CONFIGURE_FLAGS} LIBS=\"${LIBS} ${JPEG_BIGL_FLAGS}\"")
+execute_process(
COMMAND cp -p -R "${CMAKE_CURRENT_SOURCE_DIR}/libraw" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
RESULT_VARIABLE PROCESS_RESULT