R-macos / recipes

System for building static dependent libraries for CRAN packages
43 stars 15 forks source link

Freetype recipe conflicts with freetype from the xQuartz on the same server #22

Closed jeroen closed 2 years ago

jeroen commented 2 years ago

The systemfonts package has a linking error about a missing symbol from harfbuzz, however this package doesn't actually link to harfbuzz: https://www.r-project.org/nosvn/R.check/r-oldrel-macos-x86_64/systemfonts-00install.html

The systemfonts package does everything correct: it calls pkg-config --libs --static freetype to get the linker flags on your server to link to freetype.

The problem is that you have two freetypes on your server, each with their own .pc file: one is provided by xquartz in /opt/X11/ and that one gets picked up by pkg-config. This one does not depend on harfbuzz. Then you have another freetype recipe which you (probably unintentionally) have built against harfbuzz. You can confirm this from its .pc file.

Because you hardcode -L/usr/local/lib when building the R package, it ends up linking to the recipe freetype, even though pkg-config has given us the flags needed to link to the xQuartz freetype.

Possible solutions 1

Prepend /usr/local/lib/pkgconfig to your PKG_CONFIG_PATH. This way pkg-config will find the .pc files from your recipes first, before falling back to the xquartz ones.

Possible solutions 2

Rebuild your freetype recipe --without-harfbuzz to match the xquartz linker flags.

s-u commented 2 years ago

This has nothing to do with recipes, because the pkg-config output is as follows:

$ pkg-config --cflags fontconfig freetype2
-DPCRE_STATIC -I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include
$ pkg-config --libs fontconfig freetype2
-L/usr/local/lib -lfontconfig -lexpat -lfreetype -lbz2 -lpng16 -lz -lharfbuzz -lm -lglib-2.0 -lintl -liconv -lm -Wl,-framework,CoreFoundation -Wl,-framework,Carbon -Wl,-framework,Foundation -Wl,-framework,AppKit -lpcre

so the flags are correct. An entirely separate issue is how systemfonts obtains incorrect flags on the build machine. The build process explicitly makes sure that the local .pcs come before XQuartz, so I'll close this and trace the build.

jeroen commented 2 years ago

The configure script from systemfonts prints the output it gets from pkg-config to the install log, which shows something else from what you have above:

Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/opt/X11/include/freetype2
Using PKG_LIBS=-L/opt/X11/lib -lfreetype -lz -lbz2

Some somehow the PATH or PKG_CONFIG_PATH is different from within your R builds.

jeroen commented 2 years ago

For future reference, this may be fixed via https://github.com/r-devel/r-dev-web/commit/6de8b693728bf94b47f6d5d762fd441349348e26

s-u commented 2 years ago

Ah, nice, I didn't realize you also mirror R-dev-web or I would have posed the diff link ...