void-linux / void-packages

The Void source packages collection
https://voidlinux.org
Other
2.46k stars 2.09k forks source link

Cross building packages with `libgomp-devel` in makedepends breaks the masterdir #31055

Open ericonr opened 3 years ago

ericonr commented 3 years ago

From xlocate libgomp.spec:

[...]
cross-x86_64-linux-musl-libc-0.34_1     /usr/x86_64-linux-musl/usr/lib/libgomp.spec
libgomp-devel-10.2.1pre1_3      /usr/lib/libgomp.spec

makedepends are installed in the cross root after the cross toolchain is installed in the host, which means libgomp-devel replaces libgomp.spec from the cross toolchain. Then, when the dependencies are removed, all the usr/lib/libgomp* files are removed, leaving the cross toolchain broken (xbps-pkgdb complains).

@q66 suggested fixing this by adding libgomp related stuff to cross-vpkg-dummy, so that it would be resolved to cross-vpkg-dummy, but that doesn't fix things, since it apparently breaks how XBPS resolves libraries (might be a xbps bug too, @Chocimier and @Duncaen):

My patch:

diff --git a/srcpkgs/cross-vpkg-dummy/template b/srcpkgs/cross-vpkg-dummy/template
index 9de559bce0..a0125a8ef9 100644
--- a/srcpkgs/cross-vpkg-dummy/template
+++ b/srcpkgs/cross-vpkg-dummy/template
@@ -1,6 +1,6 @@
 # Template file for 'cross-vpkg-dummy'
 pkgname=cross-vpkg-dummy
-version=0.37
+version=0.38
 revision=1
 build_style=meta
 short_desc="Dummy meta-pkg for cross building packages with xbps-src"
@@ -23,6 +23,8 @@ provides="
    libgfortran-devel-9999_1
    libgo-9999_1
    libgo-devel-9999_1
+   libgomp-9999_1
+   libgomp-devel-9999_1
    libobjc-9999_1
    libobjc-devel-9999_1
    gcc-9999_1
@@ -44,6 +46,8 @@ conflicts="
    libgfortran-devel>=0
    libgo>=0
    libgo-devel>=0
+   libgomp>=0
+   libgomp-devel>=0
    libobjc>=0
    libobjc-devel>=0
    gcc>=0
@@ -56,6 +60,7 @@ shlib_provides="
    libgcc_s.so.1
    libgnat-10.so
    libgnarl-10.so
+   libgomp.so.1
    libstdc++.so.6
    libgfortran.so.5"

Result of trying to install something and a package that's replaced by cross-vpkg-dummy (this is what happens in the makedepends install step):

<bps-install -c host/repocache-aarch64-musl/ -r usr/aarch64-linux-musl/ alsa-lib libgomp-devel
acl-2.3.1_1: broken, unresolvable shlib `libc.so'
alsa-lib-1.2.4_2: broken, unresolvable shlib `libc.so'
Transaction aborted due to unresolved shlibs.

This would lead me to assume there's a limitation in how cross-vpkg-dummy works in that you can't use it to replace things in makedepends, and, furthermore, that our unusual split of "full featured cross toolchains" and "separate subpackage for each feature in native toolchains" leads to breakage in this scenario.

This can also be observed if one removes nocross from gnustep-base, where it also fails in the makedepends installation step due to libobjc-devel.

A heavy handed solution is adding such libraries to hostmakedepends or conditionally to makedepends only when not cross building, but that's very ugly.

tornaria commented 2 years ago

What would happen if we add libgomp-devel as a dependency to cross-vpkg-dummy (and maybe to base-chroot, while we are at it).

In this way, libgomp-devel is always available, just like gcc or glibc. Are there any downsides of that?

In #34469 it seems I can "fix" the issue when building siril by just adding libgomp-devel to makedepends (unconditionally) which I think would be implicit in what I suggested above.

What I don't understand is why siril needs libgomp.spec when building cross but it doesn't need it when building native.

tornaria commented 2 years ago

A different solution (which also seems to work) is to run

$XBPS_INSTALL_CMD -Ayf cross-$XBPS_CROSS_TRIPLET-libc

when cross building, but this seems more costly.

ericonr commented 2 years ago

In this way, libgomp-devel is always available, just like gcc or glibc. Are there any downsides of that?

I think this would make disabling libgomp in some cases harder. I don't know the exact implications of that, though.

What I don't understand is why siril needs libgomp.spec when building cross but it doesn't need it when building native.

I remember running across something like that when I was debugging this stuff, don't remember my conclusions...

when cross building, but this seems more costly.

Shouldn't be too much; just unpacking is generally pretty fast, IMO.

tornaria commented 2 years ago

I know what happens with siril:

$ grep Libs: /usr/aarch64-linux-gnu/usr/lib/pkgconfig/libraw.pc 
Libs: -L${libdir} -lraw -lstdc++ -fopenmp

Since siril links to libraw, it will inherit the -fopenmp flag thus requiring libgomp-devel.

Normally for cross builds this is not a problem since libgomp-devel is implicit. But note that for non-cross builds on aarch64 this would still be a problem.

Maybe a package having -fopenmp in its pkgconfig should depend on libgomp-devel to avoid this breakage.

Why is this happening? My guess is that when cross building libraw detects openmp is available at compile time so it uses it. When nocross building libraw doesn't use openmp.

Random thoughts:

Chocimier commented 2 years ago

Xbps behaviour seen here is that while installing libgomp-devel, it sees cross-vpkg-dummy currently installed with provides=libgomp-devel. So it wants to remove cross-vpkg-dummy. That, in turn, makes libc.so of shlib-provides not available, and transactions is declined.

I think it would be enough to fix https://github.com/void-linux/xbps/issues/363. Then, cross-vpkg-dummy would satisfy dependency on libgomp-devel, not install it, and cross-*-libc files would be used during build.

github-actions[bot] commented 2 years ago

Issues become stale 90 days after last activity and are closed 14 days after that. If this issue is still relevant bump it or assign it.

oreo639 commented 5 months ago

I looked in to this a bit regarding the gcc 13.2 update. (it was brought up on IRC at the time, I didn't notice this issue until now)

I did try adding libgomp to cross-vpkg-dummy and noticed the behavior described by Chocimier.

I added a rm for libgomp to void-cross: (not --disable since the headers don't conflict and are necessary) https://github.com/void-linux/void-packages/blob/master/common/build-style/void-cross.sh#L646