GNU bug report logs - #66699
zig: fail to link SDL2

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Nguyễn Gia Phong <cnx@HIDDEN>; Done: Nguyễn Gia Phong <mcsinyx@HIDDEN>; Maintainer for guix is bug-guix@HIDDEN.
bug closed, send any further explanations to 66699 <at> debbugs.gnu.org and Nguyễn Gia Phong <cnx@HIDDEN> Request was from Nguyễn Gia Phong <mcsinyx@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 66699 <at> debbugs.gnu.org:


Received: (at 66699) by debbugs.gnu.org; 11 Nov 2023 13:24:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 11 08:24:42 2023
Received: from localhost ([127.0.0.1]:52318 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r1nyb-0006Cr-NU
	for submit <at> debbugs.gnu.org; Sat, 11 Nov 2023 08:24:42 -0500
Received: from mail-4317.proton.ch ([185.70.43.17]:20505)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ekaitz@HIDDEN>) id 1r1nyY-0006Cd-Np
 for 66699 <at> debbugs.gnu.org; Sat, 11 Nov 2023 08:24:40 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech;
 s=protonmail2; t=1699709031; x=1699968231;
 bh=PB4rSJXF5TJs2ocn87XZ+pyyPufzz85OwZdii6Lhouw=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=NT1CkahCnX38AJ/KPA0AYGOmkANNWZWTxr5kOg/Zaio9W8wEhrihHc7NwtmxkD+6A
 DSFPadDtW90xCpvDP81y/R4Pj9EVCl8FrIJrKbDyCYGrGRVkY5TktvdOQotSL8uwHI
 GGKuTJMDMpBNbkfLI9FaCS6OqOuMsobpFMpR9lRcWp1T6588k1OM2zXYe0Not+iuul
 L/xqUkxoWifi2HLT1AzrHqiH9B8FIRgIPGdux7zY2G4dMFnixvUOADGHXRykLHQpHp
 agTDsChO9fL4IGFOq/TwJMGH/R6GkLmbUJ+BsYwKXXzAO+JNaDJsM8RJ6XtysXhQ9X
 ch4+NUCFYM3Uw==
Date: Sat, 11 Nov 2023 13:23:33 +0000
To: =?utf-8?Q?Nguy=E1=BB=85n_Gia_Phong?= <cnx@HIDDEN>
From: Ekaitz Zarraga <ekaitz@HIDDEN>
Subject: Re: zig: fail to link SDL2
Message-ID: <VogPLQH6oApxEQbHyfSSxYEip9tSK6qWCBObn_SEM4sLgh_BTC8l3MUACnrynd8-zc4QBmZl-31mLSXtfr_goHS9eG5bi7nUtEzCrO4bXf4=@elenq.tech>
In-Reply-To: <WpV4q86pbeIZROkO_ywSnbkSq4t2_A4QIyV0iLfIC2B0BsM738sOk3HC6BJspkrHljtZjU-oe8jsB_Qq4pKdNGNzn8gcdyoh3n4iS1Y6X_U=@elenq.tech>
References: <CWFN02XCWX0T.2T2PRVXKN89Y@guix>
 <MFUQhf68MW3SdqqcyO6PFuQ-Ih3I6BkV8N0wDS-xf52TunStisoYtvdxG6KUSOBBkLn-E_4tEJRlD8jvTSnbFUhR88uYuSk8b4l2GmcbFmk=@elenq.tech>
 <CWUUZFWJPNL0.20MWDY132FY6E@guix>
 <WpV4q86pbeIZROkO_ywSnbkSq4t2_A4QIyV0iLfIC2B0BsM738sOk3HC6BJspkrHljtZjU-oe8jsB_Qq4pKdNGNzn8gcdyoh3n4iS1Y6X_U=@elenq.tech>
Feedback-ID: 3263582:user:proton
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 66699
Cc: 66699 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

I tracked this pretty far:

This is a related issue that mentions the `mepo` package:
https://github.com/ziglang/zig/issues/12170

And I realized the problem comes from `pkg-config`. It's telling zig to use=
 the static library first.
Removing `pkg-config` from the `native-inputs` in your proposed package mak=
e it build but the `runpath` validation phase fails.

I'm not sure about what to do now.

In the issue the people working on freebsd-ports mention they did this:
https://github.com/freebsd/freebsd-ports/blob/16ada4d8d14a222bd92c4bf332d28=
b7c604af457/astro/mepo/Makefile#L31
But I don't know if we can replicate that.

I'll keep researching on this a little bit further.

Best,
Ekaitz




Information forwarded to bug-guix@HIDDEN:
bug#66699; Package guix. Full text available.

Message received at 66699 <at> debbugs.gnu.org:


Received: (at 66699) by debbugs.gnu.org; 10 Nov 2023 09:58:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 10 04:58:40 2023
Received: from localhost ([127.0.0.1]:49575 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r1OHg-0003it-5c
	for submit <at> debbugs.gnu.org; Fri, 10 Nov 2023 04:58:40 -0500
Received: from mail-4018.proton.ch ([185.70.40.18]:56029)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ekaitz@HIDDEN>) id 1r1OHa-0003iX-Ad
 for 66699 <at> debbugs.gnu.org; Fri, 10 Nov 2023 04:58:38 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech;
 s=protonmail2; t=1699610267; x=1699869467;
 bh=V3UrfOaYekr2vfV2VioU4cm/aNa1/R+v6/xLRhLo6SA=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=em21TeDzeAmN8pPnOOtmNX/POMEFHubpqxSe4aKI6KFzO1FlGqj1DO7G5PlBRyEH9
 KDqjj+koLmw1BRE2HqrXmP88LlJ6pLrv/WhoGn2QStDAtIlQs8cd9OUTVaIYxewor8
 PqaHtBLxZ3RvrkljplGzOln55CUSdh4FWZ1MVPXllyjfa+oMEYDPIG0IGareVZV2hS
 b9/xbvDybXvteyMaHA6olZx/5Bjrnb9YseZc6/KH8KxBX1q4+rd80l/uzAk7UyP/P7
 FWT8i/yleRo0VRO3/IgGfJ2ZZTaSRmd5tVYOwRQUk5zqGUraLGtYCJRNhaF1OFJ5wV
 P0modz5e2Xclw==
Date: Fri, 10 Nov 2023 09:57:43 +0000
To: =?utf-8?Q?Nguy=E1=BB=85n_Gia_Phong?= <cnx@HIDDEN>
From: Ekaitz Zarraga <ekaitz@HIDDEN>
Subject: Re: zig: fail to link SDL2
Message-ID: <WpV4q86pbeIZROkO_ywSnbkSq4t2_A4QIyV0iLfIC2B0BsM738sOk3HC6BJspkrHljtZjU-oe8jsB_Qq4pKdNGNzn8gcdyoh3n4iS1Y6X_U=@elenq.tech>
In-Reply-To: <CWUUZFWJPNL0.20MWDY132FY6E@guix>
References: <CWFN02XCWX0T.2T2PRVXKN89Y@guix>
 <MFUQhf68MW3SdqqcyO6PFuQ-Ih3I6BkV8N0wDS-xf52TunStisoYtvdxG6KUSOBBkLn-E_4tEJRlD8jvTSnbFUhR88uYuSk8b4l2GmcbFmk=@elenq.tech>
 <CWUUZFWJPNL0.20MWDY132FY6E@guix>
Feedback-ID: 3263582:user:proton
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Hi, On Friday, November 10th, 2023 at 06:01, Nguyễn Gia
   Phong <cnx@HIDDEN> wrote: > On 2023-11-01 at 20:52+00:00, Ekaitz Zarraga
    wrote: > > > On Monday, October 23rd, 2023 at 09:34, Nguyễn Gia Phong wrote:
    > > > > > I am trying to package Mepo, an OpenStreetMap frontend written
   i [...] 
 
 Content analysis details:   (1.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  1.7 URIBL_BLACK            Contains an URL listed in the URIBL blacklist
                             [URIs: libz.so]
  0.0 RCVD_IN_MSPIKE_H5      RBL: Excellent reputation (+5)
                             [185.70.40.18 listed in wl.mailspike.net]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
X-Debbugs-Envelope-To: 66699
Cc: 66699 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.7 (/)

Hi,


On Friday, November 10th, 2023 at 06:01, Nguy=E1=BB=85n Gia Phong <cnx@loan=
g.net> wrote:

> On 2023-11-01 at 20:52+00:00, Ekaitz Zarraga wrote:
>=20
> > On Monday, October 23rd, 2023 at 09:34, Nguy=E1=BB=85n Gia Phong wrote:
> >=20
> > > I am trying to package Mepo, an OpenStreetMap frontend written in Zig=
.
> > > The currently packaged Zig fails to find transitive dependencies of S=
DL2:
> > > https://paste.sr.ht/~cnx/db21e1ef9a6828f3ec898db43b790d71b5ef213a
> >=20
> > The problem is not Zig specific, look: [...]
> >=20
> > guix shell sdl2 sdl2-image gcc-toolchain glibc:static
> >=20
> > And tried to build: [...] The list of errors are basically the same
> > you have. Zig builds statically if I'm not mistaken
> > so it's triggering the same problem GCC would for that case.
> >=20
> > We need to research this further...
> >=20
> > I don't have the Zig knowledge to know how does all this work,
> > but I know it's not just the build-system's fault
> > because it happens in GCC too, and also with a normal shell
> > with `zig` available, and running the command by hand.
> > The build-system just replicates that behavior.
>=20
>=20
> Thanks, this clears it up for me. So far Zig does not offer a way
> to prefer dynamic or static and just search alphabetically:
> https://github.com/ziglang/zig/issues/14111

Maybe there are more flags for this, but I'm not sure.
=20
> On 2023-05-23 at 17:11Z, Michael Dusan wrote:
>=20
> > A workaround is if you are only using the zig cc driver,
> > the syntax -l:<FULLNAME> will find the first fully-named library file
> > that matches against search dirs. For example:
> >=20
> > * -lz will search dirs, prefer lib<BASENAME>.a over lib<BASENAME>.so
> > * -l:libz.so will search directly for libz.so
> > and not care about any other name permutations
>=20
>=20
> I do wonder though, if it's a generally good idea have separate
> shared and static outputs for e.g. SDL2. Obviously Zig programs
> would benefit from this, and specifying linkage preference
> under GCC is via the same -l:lib*.* flag.

I'm not very versed on this so I can't give you a proper answer.

> On 2023-11-01 at 20:52+00:00, Ekaitz Zarraga wrote:
>=20
> > I also checked Mepo, how do they manage to build directly?
>=20
> Sorry, could you rephrase this question?
> I don't get what you meant by directly here.

Yes, it was pretty badly phrased.
The question here was about how do the Mepo devs build mepo in other
linux distributions... They should have a similar problem to what we
have. Or other systems like Nix, how do they build?
In Nix the problem should appear too.

With *directly* I meant the Mepo repository doesn't contain the
transitive dependencies so... It would never work for us, but it
should be working for them.

Reading your message before seems like they manage to link against
the SDL .so so nothing of this happens...

I'll try to check all this with the Zig people to see if we can
fix.

Thanks!




Information forwarded to bug-guix@HIDDEN:
bug#66699; Package guix. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Nov 2023 20:53:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 01 16:53:38 2023
Received: from localhost ([127.0.0.1]:52719 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qyIDa-0004qu-7i
	for submit <at> debbugs.gnu.org; Wed, 01 Nov 2023 16:53:38 -0400
Received: from lists.gnu.org ([2001:470:142::17]:33796)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ekaitz@HIDDEN>) id 1qyIDX-0004qe-7q
 for submit <at> debbugs.gnu.org; Wed, 01 Nov 2023 16:53:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ekaitz@HIDDEN>) id 1qyICr-0003Ta-Td
 for bug-guix@HIDDEN; Wed, 01 Nov 2023 16:52:54 -0400
Received: from mail-4018.proton.ch ([185.70.40.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ekaitz@HIDDEN>) id 1qyICo-0003Ql-MJ
 for bug-guix@HIDDEN; Wed, 01 Nov 2023 16:52:53 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech;
 s=protonmail2; t=1698871965; x=1699131165;
 bh=KdBjoW8PUdg88AaM7JDMy5WKwp7nY+A6sucG/WTGXk0=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=hOfwnn0cmm+f1h5T9SBOiU0CbFXaal9u5a2D25c025FrVHK+5wsXW9tH4wXmPXbtP
 hzQ7wvkXWebAsXR4QL9Ku+i98e+4Sn6eXnZ968gfan64OfjTIIsUNNC90kXIPwljZi
 9EVdsJNS/Gyk+8h3L8aX79qba10iCnfWACENZDdgtBfoaCwZxpufob1jy42MwKZHFq
 bTRMUAXWvxJwnmGgeyrb54I8NTu8zKU7I1rguf40vYhjEsp21rSVW6hVB/dPNsPIMk
 BiEzDr89caNWm6v9NYLZB+eB6z0PfRpAPL8BAVzYga0dPOniLK22FWplUjW+PyN/Or
 UsjQ1AEQkoN6w==
Date: Wed, 01 Nov 2023 20:52:35 +0000
To: =?utf-8?Q?Nguy=E1=BB=85n_Gia_Phong?= <cnx@HIDDEN>
From: Ekaitz Zarraga <ekaitz@HIDDEN>
Subject: Re: zig: fail to link SDL2
Message-ID: <MFUQhf68MW3SdqqcyO6PFuQ-Ih3I6BkV8N0wDS-xf52TunStisoYtvdxG6KUSOBBkLn-E_4tEJRlD8jvTSnbFUhR88uYuSk8b4l2GmcbFmk=@elenq.tech>
In-Reply-To: <CWFN02XCWX0T.2T2PRVXKN89Y@guix>
References: <CWFN02XCWX0T.2T2PRVXKN89Y@guix>
Feedback-ID: 3263582:user:proton
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=185.70.40.18; envelope-from=ekaitz@HIDDEN;
 helo=mail-4018.proton.ch
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: bug-guix@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

------- Original Message -------
On Monday, October 23rd, 2023 at 09:34, Nguy=E1=BB=85n Gia Phong <cnx@loang=
.net> wrote:


> I am trying to package Mepo, an OpenStreetMap frontend written in Zig.
> The currently packaged Zig fails to find transitive dependencies of SDL2:
> https://paste.sr.ht/~cnx/db21e1ef9a6828f3ec898db43b790d71b5ef213a
>=20
> Here's a minimal reproducible Zig project:
>=20
> // main.zig
> const c =3D @cImport(@cInclude("SDL2/SDL.h"));
> pub fn main() !void {
> if (c.SDL_Init(c.SDL_INIT_VIDEO) !=3D 0)
> return error.SDLInitializationFailed;
> c.SDL_Quit();
> }
>=20
> // build.zig
> pub fn build(b: *@import("std").build.Builder) void {
> const exe =3D b.addExecutable("sdl2-smoke-test", "main.zig");
> exe.linkSystemLibrary("SDL2");
> exe.setTarget(b.standardTargetOptions(.{}));
> exe.setBuildMode(b.standardReleaseOptions());
> exe.install();
> }
>=20
> For convenience, here goes a manifest for use with guix build -f:
>=20
> (use-modules (guix build-system zig)
> (guix gexp)
> (guix licenses)
> (guix packages)
> (gnu packages pkg-config)
> (gnu packages sdl))
> (package
> (name "sdl2-smoke-test")
> (version "0.0.0")
> (source (local-file "." "sdl2-smoke-test" #:recursive? #t))
> (build-system zig-build-system)
> (arguments (list #:tests? #f
> #:zig-release-type "safe"))
> (native-inputs (list pkg-config))
> (inputs (list sdl2))
> (synopsis "Zig build system SDL2 linkage failure reproducer")
> (description
> (string-append "This is a reproducer of zig-build-system"
> " failing to link SDL2's transitive dependencies,"
> " as seen when trying to package mepo."))
> (home-page "https://larkspur.one/notice/Ab24w1IMGVoZ72J9xg")
> (license zlib))


Hi,

I have good and bad news for you.

I tried to replicate the problem, and I certainly did. I also managed to mi=
tigate the problem adding `exe.linkSystemLibrary()` lines to the build.zig =
with the transitive dependencies.
And later I wondered how did this all work in GCC, just in case.

(NOTE: take in account you also need to link with libc! for that you can ad=
d it as a linkSystemLibrary("c"))

The problem is not Zig specific, look:

I tried a random example from a repo in Github using SDL2 and SDL2-Image:=
=20
https://github.com/aminosbh/sdl2-image-sample/blob/master/src/main.c

Made a shell for it:

guix shell sdl2 sdl2-image gcc-toolchain glibc:static

And tried to build:

$ gcc a.c -static -lSDL2 -lSDL2_image -lm -lc 2>&1 | head
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_d=
ynapi.o):(.text+0x27d8): warning: Using 'dlopen' in statically linked appli=
cations requires at runtime the shared libraries from the glibc version use=
d for linking
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0x48f): undefined reference to `wl_proxy_get_version'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0xd3e): undefined reference to `wl_proxy_get_version'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0xd5a): undefined reference to `wl_proxy_marshal_flag=
s'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0xd73): undefined reference to `wl_proxy_add_listener=
'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0xeb9): undefined reference to `wl_proxy_get_version'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0xfa8): undefined reference to `wl_proxy_marshal_flag=
s'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0x1002): undefined reference to `wl_proxy_marshal_fla=
gs'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0x1071): undefined reference to `wl_proxy_add_listene=
r'
ld: /gnu/store/0mhh6ycg8dq6n43qwpvpvr2smbxlixpi-profile/lib/libSDL2.a(SDL_w=
aylandvideo.o):(.text+0x107e): undefined reference to `wl_proxy_set_tag'

The list of errors are basically the same you have.
Zig builds statically if I'm not mistaken so it's triggering the same probl=
em GCC would for that case.

We need to research this further...

I also checked Mepo, how do they manage to build directly?

I don't have the Zig knowledge to know how does all this work, but I know i=
t's not just the build-system's fault because it happens in GCC too, and al=
so with a normal shell with `zig` available, and running the command by han=
d. The build-system just replicates that behavior.

We need to dig on this further. Are you, Nguy=E1=BB=85n, a Zig programmer? =
Maybe you can help me figure out this?

Thanks for the report, the patience and the help!

All the best,
Ekaitz




Information forwarded to bug-guix@HIDDEN:
bug#66699; Package guix. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 Oct 2023 10:45:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 23 06:45:28 2023
Received: from localhost ([127.0.0.1]:49159 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qusR4-00019u-DJ
	for submit <at> debbugs.gnu.org; Mon, 23 Oct 2023 06:45:28 -0400
Received: from lists.gnu.org ([2001:470:142::17]:42054)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cnx@HIDDEN>) id 1quphj-0001Hh-MZ
 for submit <at> debbugs.gnu.org; Mon, 23 Oct 2023 03:50:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <cnx@HIDDEN>) id 1quphB-0006yj-61
 for bug-guix@HIDDEN; Mon, 23 Oct 2023 03:49:53 -0400
Received: from tem.loang.net ([2a03:3b40:100::1:2])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <cnx@HIDDEN>) id 1quph8-0003ek-IS
 for bug-guix@HIDDEN; Mon, 23 Oct 2023 03:49:52 -0400
DKIM-Signature: a=rsa-sha256; bh=K6ECZNWy5Lm8xE2Fc04JVEIS5fuzpuqwzgmVv/dAmQ8=; 
 c=relaxed/relaxed; d=loang.net;
 h=Subject:Subject:Sender:To:To:Cc:From:From:Date:Date:MIME-Version:Content-Type:Content-Type:Content-Transfer-Encoding:Reply-To:In-Reply-To:Message-Id:Message-Id:References:Autocrypt:Openpgp;
 i=@loang.net; s=default; t=1698046473; v=1; x=1698478473;
 b=M0EWvpyP1NKgJ82y6dvzFRgWz6bDE92q7pDRwR19qm5sLUa9cpAk4e0EK2UPWjzfGHUToQQi
 h9Zg00S/SGCuFAZq4Ugg6OwVMBvHzodYmpXh9y8TT12xtyR6YqfU2DAhakcFeeaX9m9RRzpEknj
 Y/AwvEk80/jWbdt+Ms8ImyvKhjbwKX3Yzdxomt5ORl9voCAjQ9UTGIylapGuH6rCKeqLar8veW+
 dR9wEqQwCbWtIE6+okUlSPDARdcN4Cxg3PMmCDjDsbJG9uLSkmcg61JM3KX6+RVMqZ4LDAilXUK
 kaHJe/vzGK3k6hgPFmT4/4HkiWL3geaTxPn+NK4wiMFWA==
Received: by tem.loang.net (envelope-sender <cnx@HIDDEN>) with ESMTPS id
 f7fc6f41; Mon, 23 Oct 2023 07:34:33 +0000
Content-Type: multipart/signed;
 boundary=6c6ec73e09820687a3edc06cbf781009aa05f1771125beda4beb2ecd18c9;
 micalg=pgp-sha256; protocol="application/pgp-signature"
Date: Mon, 23 Oct 2023 16:34:22 +0900
Subject: zig: fail to link SDL2
To: <bug-guix@HIDDEN>, <ekaitz@HIDDEN>
From: =?utf-8?q?Nguy=E1=BB=85n_Gia_Phong?= <cnx@HIDDEN>
Message-Id: <CWFN02XCWX0T.2T2PRVXKN89Y@guix>
X-Mailer: aerc 0.15.2
Received-SPF: pass client-ip=2a03:3b40:100::1:2; envelope-from=cnx@HIDDEN;
 helo=tem.loang.net
X-Spam_score_int: -12
X-Spam_score: -1.3
X-Spam_bar: -
X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 MIME_HEADER_CTYPE_ONLY=0.1, SPF_HELO_SOFTFAIL=0.732,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.1 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  I am trying to package Mepo,
 an OpenStreetMap frontend written
 in Zig. The currently packaged Zig fails to find transitive dependencies
 of SDL2: https://paste.sr.ht/~cnx/db21e1ef9a6828f3ec898db43b790d [...] 
 Content analysis details:   (1.1 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 0.1 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required
 MIME headers
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 23 Oct 2023 06:45:24 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.1 (/)

--6c6ec73e09820687a3edc06cbf781009aa05f1771125beda4beb2ecd18c9
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

I am trying to package Mepo, an OpenStreetMap frontend written in Zig.
The currently packaged Zig fails to find transitive dependencies of SDL2:
https://paste.sr.ht/~cnx/db21e1ef9a6828f3ec898db43b790d71b5ef213a

Here's a minimal reproducible Zig project:

// main.zig
const c =3D @cImport(@cInclude("SDL2/SDL.h"));
pub fn main() !void {
    if (c.SDL_Init(c.SDL_INIT_VIDEO) !=3D 0)
        return error.SDLInitializationFailed;
    c.SDL_Quit();
}

// build.zig
pub fn build(b: *@import("std").build.Builder) void {
    const exe =3D b.addExecutable("sdl2-smoke-test", "main.zig");
    exe.linkSystemLibrary("SDL2");
    exe.setTarget(b.standardTargetOptions(.{}));
    exe.setBuildMode(b.standardReleaseOptions());
    exe.install();
}

For convenience, here goes a manifest for use with guix build -f:

(use-modules (guix build-system zig)
             (guix gexp)
             (guix licenses)
             (guix packages)
             (gnu packages pkg-config)
             (gnu packages sdl))
(package
  (name "sdl2-smoke-test")
  (version "0.0.0")
  (source (local-file "." "sdl2-smoke-test" #:recursive? #t))
  (build-system zig-build-system)
  (arguments (list #:tests? #f
                   #:zig-release-type "safe"))
  (native-inputs (list pkg-config))
  (inputs (list sdl2))
  (synopsis "Zig build system SDL2 linkage failure reproducer")
  (description
    (string-append "This is a reproducer of zig-build-system"
                   " failing to link SDL2's transitive dependencies,"
                   " as seen when trying to package mepo."))
  (home-page "https://larkspur.one/notice/Ab24w1IMGVoZ72J9xg")
  (license zlib))

--6c6ec73e09820687a3edc06cbf781009aa05f1771125beda4beb2ecd18c9
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iIQEABYIACwWIQSDiv4NVdwHTjYPlDqEtpzm8/a3ZwUCZTYiAQ4cY254QGxvYW5n
Lm5ldAAKCRCEtpzm8/a3Z+agAP9boZoEOJcAnHgH6DVVEMXnqIGmL1n2lWAMRjP0
OsQ+TwD/R0ymTEfk1LkadSDLEOepRuVTKCuwT8EcvmHwmHFKTgI=
=jf6+
-----END PGP SIGNATURE-----

--6c6ec73e09820687a3edc06cbf781009aa05f1771125beda4beb2ecd18c9--




Acknowledgement sent to Nguyễn Gia Phong <cnx@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#66699; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 2 Apr 2025 01:45:08 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.