armdevvel / mxe-STATIC

MXE (M cross environment) (For ARM32 Windows development)
https://mxe.cc
Other
4 stars 2 forks source link

harfbuzz requires -lpthread, breaking the cairo_win32_surface_create_with_format check #5

Closed treeswift closed 2 years ago

treeswift commented 2 years ago

My initial attempt to build gtk3 on WSL hit the following ./configure error:

Failed to build package gtk3 for target armv7-w64-mingw32!
------------------------------------------------------------
checking for CAIRO... yes
checking for cairo_win32_surface_create_with_format in -lcairo... no
configure: error: cairo_win32_surface_create_with_format is not found in cairo library
You need a cairo snapshot 1.15.x or 1.16.x release or newer
make[1]: *** [Makefile:861: build-only-gtk3_armv7-w64-mingw32] Error 1
make[1]: Leaving directory '/home/username/Code/WoA32/mxe'

The configure log looks as follows:

configure:19427: checking for cairo_win32_surface_create_with_format in -lcairo
configure:19452: armv7-w64-mingw32-gcc -o conftest.exe -g -O2 -Wall -mms-bitfields -I/home/username/Code/WoA32/mxe/usr/armv7-w64-mingw32/include  conftest.c -lcairo   -lharfbuzz -lcairo -lgobject-2.0 -lffi -lfontconfig -lfreetype -lusp10 -lmsimg32 -lgdi32 -lpixman-1 -lexpat -lbz2 -lpng16 -lharfbuzz_too -lfreetype_too -lglib-2.0 -lintl -liconv -lpcre -lws2_32 -lole32 -lwinmm -lshlwapi -lm -lz    >&5
lld-link: error: undefined symbol: pthread_mutex_destroy
>>> referenced by libharfbuzz.a(libharfbuzz_la-hb-buffer.o):(hb_mutex_t::fini())
>>> referenced by libharfbuzz.a(libharfbuzz_la-hb-font.o)
>>> referenced by libharfbuzz.a(libharfbuzz_la-hb-set.o)

IOW, a missing Cairo symbol is mistakenly reported because a different (pthread) symbol is missing from the linker input.

For myself, I kinda quickfixed the build by providing -lpthread in freetype2.pc:Libs.private. However, since cairo.mk contains --disable-pthread, I assume the intention was to get rid of PThread in Cairo+dependencies. Therefore, I need a clarification what a desired permanent fix should be (either declare the pthread dependency or get rid of it in libhafbuzz).

My build environment is WSL v2, Ubuntu 20.04 on Windows 10. No Docker.

pahaze commented 2 years ago

Wow! I didn't realize that was the issue. Flew right over my head. I think personally that including pthreads instead of getting rid of it would be a better idea. That's just me, though.

pahaze commented 2 years ago

The intention never was to remove pthreads though. No clue why it's removed from the build.

treeswift commented 2 years ago

git-blame says:

commit 7b2f8beb9d2663e6e04e4d11b8b899e74943c4c8
Author: Volker Grabsch
Date: 3/5/09, 7:54 AM

disable threading in package cairo, because it conflicts with glib's threading

In my understanding though,

Then the fix would probably be as narrow as adding -lpthread to freetype2.pc as described above. Once I finally build a GTK GUI app and see that it works, I can refine a pull request.

pahaze commented 2 years ago

Sounds good

pahaze commented 2 years ago

Looking into this now, likely going to just use sed to add -lpthread to freetype2.pc cause it just seems like a better alternative than likely adding more issues to building than it's worth

pahaze commented 2 years ago

Fixed