tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Patch for graphics/lcms2 (alignment issues on sparc)
PS: I will drop a note/PR to upstream on this as well...
Hi,
The thread that started me on this is that print/ghostscript-agpl
dies with a bus error during colour management (e.g. gs -sDEVICE=x11
golfer.eps). Running with -dUseFastColor=true, which bypasses lcms2, avoids it.
The cause is in lcms2, not gs. lcms2's internal suballocator aligns
blocks to CMS_PTR_ALIGNMENT, which defaults to sizeof(void *) = 4 on sparc32.
Doubles stored in those blocks need 8-byte alignment on SPARC, so the access
traps. Upstream's own comment in src/lcms2_internal.h notes that SPARC needs 8,
but the default doesn't act on it. Ghostscript's bundled fork (lcms2mt) already
sets 8 when sparc is defined, but pkgsrc ghostscript-agpl package removes the
bundled copy and links against graphics/lcms2, so it never got that fix.
The patch below defines CMS_PTR_ALIGNMENT=8 on MACHINE_ARCH sparc only. The
macro is used only inside the library (not in the public headers), so the
library interface doesn't change and dependents don't need rebuilding. sparc64
is unaffected because sizeof(void *) is already 8 there.
Tested: built lcms2-2.19.1nb1 and installed it on a real SS10 with the existing
ghostscript-agpl package; the bus error is gone and golfer.eps renders under
X11. I'll also send the fix upstream to Little-CMS so this can be dropped later.
Ghostscript bug history (i.e. when I thought it was gs not lcms2): https://bugs.ghostscript.com/show_bug.cgi?id=707915
Index: graphics/lcms2/Makefile
--- graphics/lcms2/Makefile
+++ graphics/lcms2/Makefile
@@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.26 2026/05/12 16:09:35 gdt Exp $
DISTNAME= lcms2-2.19.1
+PKGREVISION= 1
CATEGORIES= graphics
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=lcms/}
@@ -29,6 +30,14 @@
# if present. Therefore, we don't enjoin lcms from finding zlib, but
# don't include it via bl3.
+.include "../../mk/bsd.prefs.mk"
+
+# lcms2's suballocator defaults to sizeof(void *) alignment; 32-bit SPARC
+# needs 8 for doubles (Ghostscript's bundled lcms2mt already does this).
+.if ${MACHINE_ARCH} == "sparc"
+CPPFLAGS+= -DCMS_PTR_ALIGNMENT=8
+.endif
+
.include "../../graphics/tiff/buildlink3.mk"
.include "../../mk/jpeg.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
Home |
Main Index |
Thread Index |
Old Index