Subject: Fontconfig issues in Java applications that use fonts

From: Fabien SK <[email-masked]>
Date: Sun, 3 Jan 2021 15:48:17 +0100

I faced the issue when running josm (downloaded from 
josm.openstreetmap.de, not the guix package). Using "strace" showed me 
that it failed because it cannot load "libfontconfig.so" (it tries in 
several directories). If I add the directory of libfontconfig.so to 
LD_LIBRARY_PATH, then it starts.
I have limited knowledge about how shared libraries are found. I tried 
to understand how "geany" manages to load libfontconfig.so. It looks 
like it depends on libgeany, libgtk3 and libpango which depend on 
libfontconfig. When I do a "readelf -a" on these libraries, I can see in 
their "RUNPATH" the path of "libfontconfig.so":
0x000000000000001d (RUNPATH)            Bibliothèque 
runpath:[/gnu/store/avjxs6qgyginkiq6qpk9280zakkaj35h-graphite2-1.3.13/lib:/gnu/store/xwl0p4m34bcan0v9vkjkyzwi6znsv4dm-pixman-0.38.4/lib:/gnu/store/y9fdy234r6hqiacd7hgwlmbdsngbp8p1-fontconfig-2.13.1/lib:…

Regarding Java, I think (but I'm not sure) that it's loaded by 
"libawt_xawt.so". In fontpath.c [1], there is a dlopen of libfontconfig. 
But if I do a "ldd" on the shared library itself, it looks like it does 
not depend on libfontconfig.so.
[1] 
https://github.com/openjdk/jdk16/blob/37043b05576c8b81b43ac41a8f06de0d0bbb3f5b/src/java.desktop/unix/native/common/awt/fontpath.c#L566
Also libfontconfig is not on its RUNPATH:

0x000000000000001d (RUNPATH)            Bibliothèque 
runpath:[$ORIGIN:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib:/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib:/gnu/store/w09mqfj1yy32r2fr02nndzs34m4f9ipp-libxext-1.3.4/lib:/gnu/store/4ildmh169dixyn05mlgjz07x4d2hcq2g-libx11-1.6.A/lib:/gnu/store/8m6368gv4z10n6i31ppbr8nxziwmlp3f-libxrender-0.9.10/lib:/gnu/store/cgsk20z1gcw78fdm7bwlb2l49xh7bmzk-libxtst-1.2.3/lib:/gnu/store/b4dk2y4vf98dhxnr0p6f5h4d86vqndkc-libxi-1.7.10/lib:/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../..]

I'm quite a beginner in term of Guix (I only played with it in a VM), 
and I hope this information will be useful to somebody. I don't 
understand how the dependencies between executable and libraries are 
supposed to be done in Guix. I can see that sometimes in /gnu/store 
there are symbolic links of shared libraries into other packages. I 
assume that sometimes this RUNPATH is used.