From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Authentication-Results: plum.tunbury.org; dkim=pass (1024-bit key; unprotected) header.d=inria.fr header.i=@inria.fr header.a=rsa-sha256 header.s=dc header.b=aQV0kv67; dkim=pass (2048-bit key; unprotected) header.d=college-de-france.fr header.i=@college-de-france.fr header.a=rsa-sha256 header.s=05BE819C-8883-4F62-9828-EF4D49272C46 header.b=FvU1fuyG; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.134.164.83; helo=mail2-relais-roc.national.inria.fr; envelope-from=caml-list-owner@inria.fr; receiver=tunbury.org Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by plum.tunbury.org (Postfix) with ESMTPS id 6910E417D0 for ; Thu, 12 Dec 2024 17:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=mime-version:references:in-reply-to:from:date:message-id: to:cc:subject:reply-to:sender:list-id:list-help: list-subscribe:list-unsubscribe:list-post:list-owner: list-archive; bh=tO19T+ilw75mGyCzDc+1Weke9CrirGjCEeaMooJJIF0=; b=aQV0kv67pbKvixgC9XOnPvDGSxalC51rX5A4x3jQ1JOyUL3QYhVyKUPc evzt56mav3RwkAC9w6HXroDzUfKHGPvpWwm96QjvSETnlaMhYq+MhYgre cVD0pj9gxYyEMFtutZRBdS8Tpo/S27kPhOppPpEwBkllWgUM/5IeWq3+o o=; Received-SPF: Pass (mail2-relais-roc.national.inria.fr: domain of caml-list-owner@inria.fr designates 128.93.162.160 as permitted sender) identity=mailfrom; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="caml-list-owner@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 include:mailout.safebrands.com a:basic-mail.safebrands.com a:basic-mail01.safebrands.com a:basic-mail02.safebrands.com ip4:128.93.142.0/24 ip4:192.134.164.0/24 ip4:128.93.162.160 ip4:128.93.162.3 ip4:128.93.162.88 ip4:89.107.174.7 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@sympa.inria.fr) identity=helo; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="postmaster@sympa.inria.fr"; x-conformance=spf_only Authentication-Results: mail2-relais-roc.national.inria.fr; spf=Pass smtp.mailfrom=caml-list-owner@inria.fr; spf=None smtp.helo=postmaster@sympa.inria.fr; dkim=pass (signature verified) header.i=@college-de-france.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208,217";a="198892240" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 12 Dec 2024 18:31:58 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id AA597E0077; Thu, 12 Dec 2024 18:31:58 +0100 (CET) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 4437BE0077 for ; Thu, 12 Dec 2024 18:31:52 +0100 (CET) IronPort-SDR: 675b1e07_gGH9N7tOfhiiBTYby1UMzTBaK9Q5ZjzEqBVoPNSNB0rMZMb RGVXGm0hU2yRv7yrG+fXxPuTTmJ8PUYhJYH0dbA== X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208,217";a="104189938" X-MGA-submission: =?us-ascii?q?MDGVlvvdak78JanHrY4gIWRnpRUqzYPJVHdaG5?= =?us-ascii?q?jqhp7dEuv/uBF64xxHR0nIjan+3zAOLwgjmryljwlB6dxGxGvauQvhm9?= =?us-ascii?q?FSZNyyVb8BQoM1Rr0gl+y72vAMH82+7VujAUjJIUhzFXBvr+JsYr0Ica?= =?us-ascii?q?igATwJPsR+nAuNXnAQdSYBvw=3D=3D?= Received: from smtpout02-ext4.partage.renater.fr ([194.254.241.31]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 18:31:53 +0100 Received: from zmtaauth04.partage.renater.fr (zmtaauth04.partage.renater.fr [194.254.241.26]) by smtpout20.partage.renater.fr (Postfix) with ESMTP id A54B3BFC9E for ; Thu, 12 Dec 2024 18:31:50 +0100 (CET) Received: from zmtaauth04.partage.renater.fr (localhost [127.0.0.1]) by zmtaauth04.partage.renater.fr (Postfix) with ESMTPS id 9DA7D1C030D for ; Thu, 12 Dec 2024 18:31:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zmtaauth04.partage.renater.fr (Postfix) with ESMTP id 8D6741C0338 for ; Thu, 12 Dec 2024 18:31:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zmtaauth04.partage.renater.fr 8D6741C0338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=college-de-france.fr; s=05BE819C-8883-4F62-9828-EF4D49272C46; t=1734024710; bh=tO19T+ilw75mGyCzDc+1Weke9CrirGjCEeaMooJJIF0=; h=MIME-Version:From:Date:Message-ID:To; b=FvU1fuyGIcMflOl//5y+dv4d6muh2mDKlrN6gS4lxTilU7+tdvUfP+LuoXPYAZscZ Fc3/TvGCnXkcXrMg/iITUE+a52CCBHQI6Ryt1JUwGFQ2VZbs0SixP6kPRkWB7nvBVP 74LgBswHrKXR4Rp1kABpCyAAeHrzmFkssTSs7fJUeyDi5IybQECnebra48FiQOcwue Kun8woRzuYhgbDFZNZ7hXhnlHebxGyOmjLlVFvTwmSkY7Neu6/UOpgfNo7ubd6mjZb dyY3skRImYnRLWrdFVspsWL1UuvrmtY+h3CJSedxfVAD85x8HY2IdBoBbvaAyMiSrF qlcrcqo8b58Jw== Received: from zmtaauth04.partage.renater.fr ([127.0.0.1]) by localhost (zmtaauth04.partage.renater.fr [127.0.0.1]) (amavis, port 10026) with ESMTP id 0OG2o_993JZx for ; Thu, 12 Dec 2024 18:31:50 +0100 (CET) Received: from 209.85.222.178 (unknown [194.254.241.249]) by zmtaauth04.partage.renater.fr (Postfix) with ESMTPA id 5AA8F1C030D for ; Thu, 12 Dec 2024 18:31:50 +0100 (CET) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7b6f1be1daeso71202785a.0 for ; Thu, 12 Dec 2024 09:31:50 -0800 (PST) X-Gm-Message-State: AOJu0YwWi/cAlOFjMAu8ivW0eRNamUmV2j546jjF8gOvjKKc4tIwwQgN OPRIdhTH3tU/9fndGKQzj0us5ja5EJi5qFeW5eJs9B9QJP+WDPUyx9Dn2rl19L3Qu87SEkYd4cQ 07+xO7HJZ427NbRDwLQn1nTwIn5o= X-Google-Smtp-Source: AGHT+IHn5bakere+URJ1zx9Kf+4kMSq+B/T+9dLVnbA4WHM3q7EO1zY44ZGSum/GL9PRVFgLfpHM1PTZMEo0wlHUs6s= X-Received: by 2002:a05:620a:3904:b0:7b6:cf4d:c43c with SMTP id af79cd13be357-7b6f89f43ecmr210672585a.55.1734024709393; Thu, 12 Dec 2024 09:31:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Xavier Leroy Date: Thu, 12 Dec 2024 18:31:22 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Andreas Rossberg Cc: "caml-list@inria.fr" Content-Type: multipart/alternative; boundary="000000000000d5e33606291616ed" X-Virus-Scanned: clamav-milter 0.103.8 at clamav01 X-Virus-Status: Clean X-Renater-Ptge-SpamState: clean X-Renater-Ptge-SpamScore: -100 X-Renater-Ptge-SpamCause: gggruggvucftvghtrhhoucdtuddrgeefuddrkeehgddutddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecutffgpfetvffgtfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepgghfjgfhfffkuffvvegtsegrtderredttdejnecuhfhrohhmpegirghvihgvrhcunfgvrhhohicuoeigrghvihgvrhdrlhgvrhhohiestgholhhlvghgvgdquggvqdhfrhgrnhgtvgdrfhhrqeenucggtffrrghtthgvrhhnpeehteehfeevffffueffudfgieeggeetkeeifeegjeeivedutddtfeefueffuedtvdenucffohhmrghinhepghhithhhuhgsrdgtohhmpdgtohhnfhhighhurhgvrdgrtgenucfkphepudelgedrvdehgedrvdeguddrvdegleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleegrddvheegrddvgedurddvgeelpdhhvghlohepvddtledrkeehrddvvddvrddujeekpdhmrghilhhfrhhomhepgigrvhhivghrrdhlvghrohihsegtohhllhgvghgvqdguvgdqfhhrrghntggvrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopegtrghmlhdqlhhishhtsehinhhrihgrrdhfrh Subject: Re: [Caml-list] Static linking with Mingw and dune Reply-To: Xavier Leroy X-Loop: caml-list@inria.fr X-Sequence: 19229 Errors-To: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --000000000000d5e33606291616ed Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 12, 2024 at 8:46=E2=80=AFAM Andreas Rossberg wrote: > Good to know, thank you for the suggestions! > > However, I=E2=80=99m afraid that hacking the compiler and tool chain for = this > purpose is not an option =E2=80=94 that would require everybody else who = wants to > build the project to do the same, which is infeasible. > > It=E2=80=99s a bit disappointing that there seems to be no easy solution = for this > problem. I would expect it to be a common pain point for folks using OCam= l > 5 to develop and publish application binaries for Windows. Or am I just > alien? > OCaml's dependency on winpthreads will probably go away in the near future, see https://github.com/ocaml/ocaml/pull/13416 . But, more generally, static linking of C libraries is getting more and more difficult -- even from C, not just OCaml. For example, under Linux, it's essentially impossible to statically link with the glibc C standard library; a musl-based distribution must be used if static linking is desired. It looks as if the consensus was that static linking of libraries is a bad idea and must be prevented. I don't think it is, but that's something way beyond OCaml's control. Best, - Xavier Leroy > > Cheers, > /Andreas > > > > On 2. Dec 2024, at 09:25, Antonin D=C3=A9cimo > wrote: > > > >> Regarding OCaml 5.3/mingw64 you shouldn't need to have to do anything > with libwinpthreads because it's only used for the msvc port, not the min= gw > one. > > > > That is not quite exact, winpthreads is used with mingw-w64, but found > > in the system installation, and linked to. It is vendored for the MSVC > > port and we *statically* link into the runtime only the parts we're > > interested in. > > > > To statically link with winpthreads, I suggest you do all of it manuall= y: > > - clone winpthreads sources at https://github.com/mingw-w64/mingw-w64, > > go to mingw-w64-libraries/winpthreads, and build a static version of > > the library with your preferred toolchain; > > > > - hack the OCaml compiler / Makefile to *not* use `-lpthreads`: > > > https://github.com/ocaml/ocaml/blob/5a5eb481c7a9d0f039e3169aa8ed19c9b926e= 982/configure.ac#L2372-L2373 > > Maybe it's just sufficient to set PTHREAD_LIBS when invoking > > configure; however seeing this line makes me think that winpthreads is > > already statically linked with the runtime. > > > > PTHREAD_LIBS=3D"-l:libpthread.a $link_gcc_eh"] > > > > Haven't dug further. > > > > -- Antonin > > --000000000000d5e33606291616ed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Dec 12, 2024 at 8:46=E2=80=AFAM Andre= as Rossberg <rossberg@mpi-sws.or= g> wrote:
Good to know, thank you for the suggestions!

However, I=E2=80=99m afraid that hacking the compiler and tool chain for th= is purpose is not an option =E2=80=94 that would require everybody else who= wants to build the project to do the same, which is infeasible.

It=E2=80=99s a bit disappointing that there seems to be no easy solution fo= r this problem. I would expect it to be a common pain point for folks using= OCaml 5 to develop and publish application binaries for Windows. Or am I j= ust alien?

OCaml's depende= ncy on winpthreads will probably go away in the near future, see https://github.com/ocaml/ocaml/= pull/13416 .

But, more generally, stat= ic linking of C libraries is getting more and more difficult -- even from C= , not just OCaml.=C2=A0 For example, under Linux, it's essentially impo= ssible to statically link with the glibc C standard library; a musl-based d= istribution must be used if static linking is desired.=C2=A0 It looks as if= the consensus was that static linking of libraries is a bad idea and must = be prevented.=C2=A0 I don't think it is, but that's something way b= eyond OCaml's control.

Best,

- Xavier Leroy


=C2=A0

Cheers,
/Andreas


> On 2. Dec 2024, at 09:25, Antonin D=C3=A9cimo <antonin.decimo@gmail.com> = wrote:
>
>> Regarding OCaml 5.3/mingw64 you shouldn't need to have to do a= nything with libwinpthreads because it's only used for the msvc port, n= ot the mingw one.
>
> That is not quite exact, winpthreads is used with mingw-w64, but found=
> in the system installation, and linked to. It is vendored for the MSVC=
> port and we *statically* link into the runtime only the parts we'r= e
> interested in.
>
> To statically link with winpthreads, I suggest you do all of it manual= ly:
> - clone winpthreads sources at https://github.com/mingw-w= 64/mingw-w64,
> go to mingw-w64-libraries/winpthreads, and build a static version of > the library with your preferred toolchain;
>
> - hack the OCaml compiler / Makefile to *not* use `-lpthreads`:
>=C2=A0 https://github.com/ocaml/ocaml/blob/5a5eb481c7a9d0f039e3169aa8e= d19c9b926e982/configure.ac#L2372-L2373
>=C2=A0 Maybe it's just sufficient to set PTHREAD_LIBS when invoking=
> configure; however seeing this line makes me think that winpthreads is=
> already statically linked with the runtime.
>
>=C2=A0 =C2=A0 =C2=A0PTHREAD_LIBS=3D"-l:libpthread.a $link_gcc_eh&q= uot;]
>
>=C2=A0 Haven't dug further.
>
> -- Antonin

--000000000000d5e33606291616ed--