Opened 21 months ago

Last modified 21 months ago

#66888 assigned defect

graphene @1.10.8_0+universal: arm64/x86_64 fails due to conflicting pkgconfig files

Reported by: kencu (Ken) Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: graphene

Description

when building graphene for arm64 and x86_64 universally, the two builds are quite different and the pkgconfig files don't match.

The arm64 arch builds with neon active, and the x86_64 arch builds with SSE2 and a number of enabling flags.

% diff -u ./destroot-intel/opt/local/lib/pkgconfig/ ./destroot-arm64/opt/local/lib/pkgconfig/
diff -u ./destroot-intel/opt/local/lib/pkgconfig/graphene-1.0.pc ./destroot-arm64/opt/local/lib/pkgconfig/graphene-1.0.pc
--- ./destroot-intel/opt/local/lib/pkgconfig/graphene-1.0.pc	2023-02-10 18:07:50
+++ ./destroot-arm64/opt/local/lib/pkgconfig/graphene-1.0.pc	2023-02-10 18:07:47
@@ -2,9 +2,9 @@
 includedir=${prefix}/include
 libdir=${prefix}/lib
 
-graphene_has_sse2=1
+graphene_has_sse2=0
 graphene_has_gcc=0
-graphene_has_neon=0
+graphene_has_neon=1
 graphene_has_scalar=1
 
 Name: Graphene
@@ -14,4 +14,4 @@
 Requires.private: gobject-2.0 >=  2.30.0
 Libs: -L${libdir} -lgraphene-1.0
 Libs.private: -lm
-Cflags: -I${includedir}/graphene-1.0 -I${libdir}/graphene-1.0/include -mfpmath=sse -msse -msse2
+Cflags: -I${includedir}/graphene-1.0 -I${libdir}/graphene-1.0/include
diff -u ./destroot-intel/opt/local/lib/pkgconfig/graphene-gobject-1.0.pc ./destroot-arm64/opt/local/lib/pkgconfig/graphene-gobject-1.0.pc
--- ./destroot-intel/opt/local/lib/pkgconfig/graphene-gobject-1.0.pc	2023-02-10 18:07:50
+++ ./destroot-arm64/opt/local/lib/pkgconfig/graphene-gobject-1.0.pc	2023-02-10 18:07:47
@@ -1,9 +1,9 @@
 prefix=/opt/local
 includedir=${prefix}/include
 
-graphene_has_sse2=1
+graphene_has_sse2=0
 graphene_has_gcc=0
-graphene_has_neon=0
+graphene_has_neon=1
 graphene_has_scalar=1
 
 Name: Graphene-GObject

unfortunately pkgconfig still has no "-target" option or "-arch" option to control the returned flags. According to the current muniversal PortGroup functionality, we are expected to find a way to merge these meaningfully.

For the CFLAGS, it's easy. Clang will just ignore the flags that don't apply to the arch it is building for, so sending SSE2 flags into an arm64/neon build is no problem. So that part is easy enough to unify.

Then maybe we can get away with this? :

graphene_has_sse2=1
graphene_has_neon=1
...

I wonder what any software would use those pkgconfig items for anyway (if they can even query them...)

Change History (2)

comment:1 Changed 21 months ago by kencu (Ken)

well, unfortunately not going to be so simple.

I built graphene +universal without trouble by telling muniversal to not diff the pkgconfig files:

% port -v installed | grep graphene
  graphene @1.10.8_1+universal (active) requested_variants='+universal' platform='darwin 22' archs='arm64 x86_64' date='2023-02-10T21:00:47-0800'

and then replaced them with these:

% cat /opt/local/lib/pkgconfig/graphene-1.0.pc
prefix=/opt/local
includedir=${prefix}/include
libdir=${prefix}/lib

graphene_has_sse2=1
graphene_has_gcc=0
graphene_has_neon=1
graphene_has_scalar=1

Name: Graphene
Description: Math classes for graphic libraries
URL: https://ebassi.github.io/graphene
Version: 1.10.8
Requires.private: gobject-2.0 >=  2.30.0
Libs: -L${libdir} -lgraphene-1.0
Libs.private: -lm
Cflags: -I${includedir}/graphene-1.0 -I${libdir}/graphene-1.0/include -mfpmath=sse -msse -msse2

% cat /opt/local/lib/pkgconfig/graphene-gobject-1.0.pc
prefix=/opt/local
includedir=${prefix}/include

graphene_has_sse2=1
graphene_has_gcc=0
graphene_has_neon=1
graphene_has_scalar=1

Name: Graphene-GObject
Description: GObject types for Graphene
Version: 1.10.8
Requires: graphene-1.0, gobject-2.0
Cflags: -I${includedir}/graphene-1.0

but during the build of the arm64 slice of a universal build of gtk4, the compiler errors out on one of the sse flags after all:

[20/1069] /usr/bin/clang -Igdk/x11/libgdk-x11.a.p -Igdk/x11 -I../gtk-4.8.2-arm64/gdk/x11 -I. -I../gtk-4.8.2-arm64 -Igdk -I../gtk-4.8.2-arm64/gdk -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/libpng16 -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include/freetype2 -I/opt/local/include/pango-1.0 -I/opt/local/include/fribidi -I/opt/local/include/harfbuzz -I/opt/local/include/graphene-1.0 -I/opt/local/lib/graphene-1.0/include -I/opt/local/include/gio-unix-2.0 -I/opt/local/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -DG_LOG_USE_STRUCTURED=1 -DGLIB_DISABLE_DEPRECATION_WARNINGS '-DGTK_VERSION="4.8.2"' -D_GNU_SOURCE -DG_ENABLE_DEBUG -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -arch arm64 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -mfpmath=sse -msse -msse2 -DGTK_COMPILATION '-DG_LOG_DOMAIN="Gdk"' -fno-strict-aliasing -Wno-c++11-extensions -Wno-missing-include-dirs -Wno-typedef-redefinition -Wformat=2 -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-function-declaration -Wmisleading-indentation -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-fallthrough -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=missing-prototypes -Werror=nonnull -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=vla -Werror=write-strings -Wnull-dereference -fvisibility=hidden -MD -MQ gdk/x11/libgdk-x11.a.p/gdkdevice-xi2.c.o -MF gdk/x11/libgdk-x11.a.p/gdkdevice-xi2.c.o.d -o gdk/x11/libgdk-x11.a.p/gdkdevice-xi2.c.o -c ../gtk-4.8.2-arm64/gdk/x11/gdkdevice-xi2.c
FAILED: gdk/x11/libgdk-x11.a.p/gdkdevice-xi2.c.o 
clang: warning: argument unused during compilation: '-msse' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
error: unknown FP unit 'sse'

so that approach is not going to work, like that at least...

Last edited 21 months ago by kencu (Ken) (previous) (diff)

comment:2 Changed 21 months ago by kencu (Ken)

I stripped out all the SSE and NEON stuff from the pkgconfig files, and that gets past those errors of course. So disabling all the SIMD optimizations is one way to unify the pkgconfig files.. not a very ideal way, but one way.

The universal build of gtk4 then fails for other, unrelated reasons.

Note: See TracTickets for help on using tickets.